Hey, I know this tweening engine is the best. But, until yesterday i found something weird, the onComplete event does not fire.
here is my code:
import flash.events.MouseEvent;
import flash.display.Loader;
import flash.events.Event;
import flash.net.URLRequest;
import flash.display.MovieClip;
import flash.display.StageScaleMode;
import flash.display.StageAlign;
import com.greensock.TweenMax;
stop();
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
var basePath:String = "projects/";
var projectName:String = "Mandiri/";
var theSWF:String = "";
banners.banner1.addEventListener(MouseEvent.CLICK, onClick);
banners.banner2.addEventListener(MouseEvent.CLICK, onClick);
banners.banner3.addEventListener(MouseEvent.CLICK, onClick);
banners.banner4.addEventListener(MouseEvent.CLICK, onClick);
function onClick(me:MouseEvent):void{
//trace(sub_container.numChildren);
if(sub_container.numChildren > 0){
TweenMax.to(sub_container.getChildAt(0), 1, {alpha:0, onComplete:clearChildren, onCompleteParams:["Yayy"]});
}
switch(me.currentTarget.name){
case "banner1":
theSWF = "01.swf";
break;
case "banner2":
theSWF = "02.swf";
break;
case "banner3":
theSWF = "03.swf";
break;
case "banner4":
theSWF = "04.swf";
break;
}
var swfLoader:Loader = new Loader();
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadSubComplete);
swfLoader.load(new URLRequest(basePath + projectName + theSWF));
}
function clearChildren(param):void{
trace(param);
TweenMax.killTweensOf(sub_container);
sub_container.removeAllChildren();
trace(sub_container.numChildren);
}
function onLoadSubComplete(ev:Event):void{
var theLoaded:MovieClip = MovieClip(ev.target.content);
theLoaded.x = -theLoaded.width/2;
theLoaded.y = -theLoaded.height/2;
sub_container.addChild(theLoaded);
TweenMax.to(theLoaded, 1, {alpha:1});
}
stage.addEventListener (Event.RESIZE, resizeListener);
function resizeListener(ev:Event):void{
sub_container.x = stage.stageWidth/2;
sub_container.y = stage.stageHeight/2;
banners.x = stage.stageWidth/2 - banners.width/2;
}
DisplayObject.prototype.removeAllChildren = function(){
for(var j = this.numChildren-1; j >= 0; j--){
this.removeChildAt(j);
}
}
If you see that onComplete:clearChildren, onCompleteParams:["Yayy"] inside onClick function, it does not fire. But when I try onStart event, it fired perfectly normal.
Please help, thanks before.
And sorry, for my bad english.