Hello Greensocks,
I have a very simple setup with one SWFLoader inside a class. All I want I would like to tween the scaleX scaleY when it is loaded. Unfortunately the onInit onComplete Events are never dispatched.
However, when I add a timer of 2 sec, timerHandler is dispatched and scaled perfectly.
Of course for slow connections it would be better to use the LoaderEvents.
What is going on here and how do I have to attach the events that it works?
Thank you,
Dennis
package
{
import com.greensock.*;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.*;
import flash.display.DisplayObject;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.TimerEvent;
import flash.utils.Timer;
[sWF(width="860", height="500", backgroundColor="#FFFFFF", frameRate="30")]
public class bannerLoader extends MovieClip
{
public var loader:SWFLoader;
public var container:MovieClip;
public function bannerLoader()
{
var myTimer:Timer = new Timer(1000, 1); // delay 1 second, repeats once
myTimer.start();
myTimer.addEventListener(TimerEvent.TIMER_COMPLETE, timerHandler);
container = new MovieClip();
container.name = "container";
this.addChild(container);
loader = new SWFLoader("http://www.encuentratugemelo.cl/dennistest2/assets/banner-cepech.swf", {
name:"bannerSWF",
x:0,
y:220,
fitWidth : 420,
fitHeight: 260,
scaleX: 0.5,
scaleY: 0.5,
autoPlay:true,
crop:true,
vAlign:"bottom",
hAlign:"left",
centerRegistration : true,
onInit:initHandler,
scaleMode : "noScale",
onComplete:initHandler,
estimatedBytes:95000});
loader.addEventListener(Event.ADDED_TO_STAGE, added);
container.addChild(loader.content);
loader.load();
}
private function added(e:Event):void
{
TweenMax.to(loader.content, 2.0, {y:0, scaleX:1,scaleY:1});
}
private function timerHandler(e:TimerEvent):void
{
TweenMax.to(loader.content, 2.0, {y:0, scaleX:1,scaleY:1});
}
public function initHandler(event:LoaderEvent):void
{
TweenMax.to(loader.content, 2.0, {y:0, scaleX:1,scaleY:1});
}
}
}