Jump to content
Search Community

Fading between External SWFs using TweenLite

erhabi test
Moderator Tag

Recommended Posts

Hello,

 

I have set up a very basic fla with 3 bts and 3 dummy swfs. Each bt loads an swf into a mc called 'loadmc' an empty container on the stage and fades it in using TweenLite.

 

But i ran into a roadblock here. i was thinking of makeing it function like this:

a) load 1st swf

B) on click fade out 1st swf and load 2nd swf.. and so on..

 

therefore, since i'm not well versed with as3, i wrote a fairly simple piece of code :

 

import com.greensock.*;
import com.greensock.easing.*;
import com.greensock.plugins.*;
TweenPlugin.activate([AutoAlphaPlugin]);
import flash.net.URLRequest;
import flash.display.Loader;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.events.MouseEvent;

var loader:Loader = new Loader();
addChild(loader);

bt1.addEventListener(MouseEvent.CLICK,onLoadClick);

function onLoadClick(evt:MouseEvent):void
{
       loadmc.alpha = 0;
       loader.load(new URLRequest("loadtest1.swf"));
       loadmc.addChild(loader);
       TweenLite.to(loadmc, 0.8, {autoAlpha:1, ease:Sine.easeIn});


}

bt2.addEventListener(MouseEvent.CLICK, onLoadClick2);

function onLoadClick2(evt:MouseEvent):void
{
       loadmc.alpha = 0;
       loader.load(new URLRequest("loadtest2.swf"));
       loadmc.addChild(loader);
       TweenLite.to(loadmc, 0.8, {autoAlpha:1, ease:Sine.easeIn});
}

bt3.addEventListener(MouseEvent.CLICK, onLoadClick3);

function onLoadClick3(evt:MouseEvent):void
{
       loadmc.alpha = 0;
       loader.load(new URLRequest("loadtest3.swf"));
       loadmc.addChild(loader);
       TweenLite.to(loadmc, 0.8, {autoAlpha:1, ease:Sine.easeIn});
}

 

However, i cant get the intended logic to execute here. With the above it just loads 1 swf into the container and fades it in, but in between the 2nd swf and the 1st there should be fading happening with each other (1st swf and 2nd swf), instead there's just a jump... :S

 

Since i am new to as3 and still learning, any help would be appreciated please. thanks.

Link to comment
Share on other sites

It sounds like you want 2 loaders to both show at the same time (one fading out, the other fading in) but your code reuses the same loader every time. You'd probably want to create a new Loader each time, start loading, wait for its COMPLETE event, and THEN fade it in while fading the other Loader out. You could use an onComplete in your tween to then removeChild() that old Loader and unload() it.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...