More questions. Sowwy. :)

3 posts

Flag Post

I recently figured out how to use tween classes and have been prettifying the game I am trying to make. But I have encountered a problem that I’m not really certain how to bypass.

I am trying to make new ‘screens’ fade in, and old screens fade out. I made the new screens fade in correctly by adding a TweenMax.fromTo() with an alpha and blur.

But I cannot seem to make them fade out.

public static function TweenOut(target_:Object) : void
{
TweenMax.fromTo(target_, 4, 
{ alpha:1, blurFilter: { blurX:0, blurY:0, quality:2 }},
{ alpha:0, blurFilter: { blurX:40, blurY:40, quality:2 }} );
}

public function EventHandler(event_:Event) : void
{
switch (event_.type)
{
case Event.ADDED_TO_STAGE:
TweenFactory.TweenIn(interactiveObject);
interactiveObject.removeEventListener(Event.ADDED_TO_STAGE, EventHandler);
interactiveObject.addEventListener(Event.REMOVED, EventHandler);
trace("I caught an " + event_.type);
break;
						
case Event.REMOVED:
TweenFactory.TweenOut(interactiveObject);
interactiveObject.removeEventListener(Event.REMOVED, EventHandler);
trace("I caught an " + event_.type);
break;
}
}

Now. On building it catches an addedToStage. But it never catches removed – but when I switch the Event.REMOVED to REMOVED_FROM_STAGE it catches it before I’ve even moved off the main menu, and ‘tweens’ the things out of existence (so I am just left with an empty screen).

Does anyone have any suggestions on how I can do what I want? Thanks in advance.

 
Flag Post

You are removing the object before it tweens it. Better make a function which is called instead of removing it directly. In that function fade out the object and let the tweenmax call another function on its completion, this function will remove the object from parent.

 
Flag Post

Yay.

Got it working now, thanks! :D