Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
azuki

help with animation sequence in a loaded swf - please!

Recommended Posts

Hi,

 

After scouring the interweb for a solution, I'm at a loss and hoping someone here can help. I've run into what seems like a common speedbump for AS3 newbies like myself. That is, I'm trying to build a simple Flash site that has a main FLA with a nav. Each button in the nav loads a corresponding swf (for each page of the site) into the same area in my main FLA. I'm not sure why this is so difficult but this has caused me to rip way too much hair out from my head...

 

My goal is to eventually have transition animations between each of the pages. We've all seen it done: If you're on the 'Home' page and you click the 'About' page, the movieclips on the current page animate out and eventually disappear before the elements of the next page animate in. It all looks very cool and I want to learn how to do it! I'd like to use TweenLite and TimelineLite (or Max) to achieve this but I can't get past finding a way to load the swf files. Argh!

 

So I guess it breaks down to this:

 

1) What's the best way to load and unload external swfs?

 

2) How can I sequence an 'out animation' of the current page, before loading the next page, which I'd like to sequence an 'in animation' ?

 

Note: I've tried addChild and removeChild without success, primarily because the main Nav becomes covered up by the loaded swf. Using addChildAt(loader, 0), works for the loading but loading another swf does not replace the first one. Again, argh!

 

This is killing me so I'd really appreciate some help!

Thanks in advance. :)

Link to comment
Share on other sites

As far as loading, I'd recommend LoaderMax of course :) Have you watched the videos that Rich Shupe put together? http://www.greensock.com/loadermax-video/

 

As far as sequencing stuff, that's totally possible with TweenLite/Max and/or TimelineLite/Max. Here's a simple example of transitioning the current swf out (fading) and then loading the new one and fading it in:

 

TweenLite.to(currentSWFLoader.content, 1, {alpha:0, onComplete:loadNext, onCompleteParams:["myNextSWF.swf"]});

function loadNext(swfUrl:String):void {
   currentSWFLoader.dispose(true);
   currentSWFLoader = new SWFLoader(swfUrl, {x:100, y:50, alpha:0, onComplete:transitionIn});
   addChildAt(currentSWFLoader.content, 0);
   currentSWFLoader.load();
}

function transitionIn(event:LoaderEvent):void {
   TweenLite.to(currentSWFLoader.content, 1, {alpha:1});
}

 

Hope that helps.

Link to comment
Share on other sites

Thanks for the info. I had only been focusing on learning TweenLite/Max and TimelineLite/Max and didn't even know there was a LoaderMax! Greensock is the gift that keeps on giving :D

 

From what I can tell in the code you provided, 'content' is used to access a loaded swf? So, I'm guessing any movieclip within the loaded swf would be accessed like so:

 

currentSWFLoader.content.movieclip1

 

Is that right? I'd like to sequence an animation within the loaded swf. For example, if an 'About' link is clicked in the main nav, I'd like the 'about.swf' to load and have the elements within that swf animate into place (a basic page-build animation, I suppose).

 

Also, is this used to unload the previous swf: currentSWFLoader.dispose(true);

 

Thanks again for clarifying!

Link to comment
Share on other sites

From what I can tell in the code you provided, 'content' is used to access a loaded swf? So, I'm guessing any movieclip within the loaded swf would be accessed like so:

 

currentSWFLoader.content.movieclip1

 

Actually, SWFLoader wraps your swf in a ContentDisplay object (basically a fancy Sprite) in order to make it available immediately for placement in the display list, adding MouseEvent listeners, etc. Otherwise, you'd have to wait until your swf loaded before you could do anything like that. If you want to access the swf's root, just use the "rawContent" property instead of "content" like:

 

currentSWFLoader.rawContent.movieclip1;

 

Also, is this used to unload the previous swf: currentSWFLoader.dispose(true);

Exactamundo! (yes)

Link to comment
Share on other sites

Hi,

 

Could someone help me to understand the use of the following property?

 

1) "rawContent"

Link to comment
Share on other sites

http://www.greensock.com/as/docs/tween/ ... rawContent

 

Have you seen the ASDocs that are in all the downloads and on the web site? They explain pretty much every property and method. Plus there is some example code there as well.

 

If the description there (about rawContent) wasn't clear, just let me know and I'll try explaining it better.

Link to comment
Share on other sites

Thanks again for your help. I'm in the process of exploring all that LoaderMax has to offer and I've come across something I'm hoping you can help me with. Inside of a loaded swf, I have a subnav, a few buttons that will load their asscociated content (movieclips) from the library. The problem, as far as I can see, is the only way to load and unload movieclips from the library is to use addChild and removeChild.

 

I'm pretty sure LoaderMax doesn't handle movieclip loading but I wanted to be sure. If it doesn't, do you have any tips on handling the loading and unloading of movieclips from the library with control similar to what LoaderMax offers, specifically loading or animating the clip onto the stage and then removing it with an outro animation?

 

Thanks!

Link to comment
Share on other sites

What you're talking about isn't really "loading" a MovieClip since it's already in the swf - you're just talking about adding an instance of a library asset to the stage. That indeed has nothing to do with LoaderMax. I'd recommend reading Adobe's docs on the topic or Google it, like here's a few things that might help:

 

http://www.kirupa.com/developer/flashcs ... S3_pg1.htm

http://www.adobe.com/devnet/flash/quick ... y_as3.html

http://www.airtightinteractive.com/2007 ... ie-in-as3/

http://kirupa.com/forum/showthread.php?t=262096

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.
×