Jump to content
Search Community

TimelineMax/Lite not working for loaded swf

DigitalOne test
Moderator Tag

Recommended Posts

HI all,

 

I have an external movie that I load into may main. When external swf is done loading, it gets a movie clip(mcPage) associated with it so I can manipulate the external swf elsewhere.

 

But something strange is going on. When i try to animate the movie clip that the external swf sits in, I can only do it via

TweenLite.from(mcPage, 1, {y:200, autoAlpha:0, ease:Back.easeOut});

 

If I try to use a timeline setup, nothing happens, no errors, nothing.

 

here is my loader:

var pageLoader:Loader=new Loader();
pageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, pageLoaded);
var mcPage:MovieClip;

function pageLoaded(e:Event):void
{
mcPage = pageLoader.content as MovieClip;
}

 

here is how I now animate "mcPage":

function pageAnimIn(e:MouseEvent):void
{
mcPage.visible = true;
//mcPage will only animate after it is loaded.
pageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, delayAnim);

function delayAnim(e:Event):void
{
	pageLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, delayAnim);
	TweenLite.from(mcPage, 1, {y:200, autoAlpha:0, ease:Back.easeOut});
}
}

function pageAnimOut(e:MouseEvent):void
{
TweenLite.to(mcPage, 1, {y:200, autoAlpha:0, ease:Back.easeIn})
}

 

Here how I want to animate mcPage:

var pageAnimTimeline:TimelineMax = new TimelineMax({paused:true});
pageAnimTimeline.append(TweenMax.from(mcPage, 1, {y:200, autoAlpha:0, ease:Back.easeOut}));

function pageAnimIn(e:MouseEvent):void
{
mcPage.visible = true;
//mcPage will only animate after it is loaded.
pageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, delayAnim);

function delayAnim(e:Event):void
{
	pageLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, delayAnim);
	pageAnimTimeline.play();
}
}

function pageAnimOut(e:MouseEvent):void
{
[b]pageAnimTimeline.reverse();[/b]	
}

 

Well, I'm not sure if it really matters, but I'm definitely curious as to why....

 

any ideas?

Link to comment
Share on other sites

You're using a nested function. Don't do that. Nested functions are deleted as soon as their parent function has finished executing. You have scripts that are trying to call a nested function later (like when the Loader finishes), but by that time the function has been deleted. Can't work :)

 

I'd strongly recommend avoiding nested functions at all costs. They can cause all sorts of confusion.

Link to comment
Share on other sites

Ok, I understand the thing about nested functions expiring, so then why does

TweenLite.from(mcPage, 1, {y:200, autoAlpha:0, ease:Back.easeOut});

still work in a nested function but

animTimline.play()

will not? I declared the timeline constructor outside of any functions...

 

You got me thinking, why am I nesting the function? It can still be called without being nested....

 

btw Jack, great vid on timelineMax/Lite. It taught me a couple things I didn't realize about timeline

Link to comment
Share on other sites

Depends on where your code is. I'd need to see exactly what code you're using in its context to know how to answer your question. A sample FLA would be best (the simpler the better).

 

Glad to hear the video was useful - I plan to create a more advanced one too that should hopefully be even more useful.

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