Jump to content
Search Community

onComplete question

timaging test
Moderator Tag

Recommended Posts

Hi,

I have a swf that loads another external swf which is using greensock tweens. When this external swf completes, I want to go back to a certain scene and frame in the original swf. Is this even possible? I've tried a few things here but nothing seems to work.

 

thanks,

Dave

Link to comment
Share on other sites

ok. I never could figure out how to use the onComplete thing, so I just had to create a button to get back. Not very elegant, but I'm still not really finding any comprehensive instruction on how to do this stuff... just that you can do it, but not how.

 

thanks,

Dave

Link to comment
Share on other sites

When you say "the onComplete thing", what do you mean? Are you talking about doing something when your MovieClip finishes playing all of its frames? Or a TweenLite/Max that completes? Or a LoaderMax loader that completes loading an asset? What instructions are you looking for exactly?

Link to comment
Share on other sites

I have a swf that loads another external swf which is using greensock tweens. When this external swf completes, I want to go back to a certain scene and frame in the original swf.

 

so, basically I wanted to set some sort of thing where when all this completes, it goes back to the original swf. I don't know of any other way to word it, but can probably show you an example:

 

http://www.taylorimaging.com/clientArea/10-COR-069/

 

if you click on "Our Cities", it plays music and has animation. This is all done using Tweens, and the sound is just placed in there. when that sound and animation completes, I just wanted it to go back to frame 111 of the original scene.

 

So, for now I've just used snipped code from Flash in a button, but was hoping to have it switch back on it's own at the end.

 

Maybe this isn't something that's greensock, but when I google onComplete, most everything points to the Greensock forums. Then, when I read into it, I couldn't find any examples of how that code might work for my application.

Link to comment
Share on other sites

If all of your animation is done using TweenLite/Max, you could just put those tweens into a TimelineLite that has an onComplete, like:

 

var tl:TimelineLite = new TimelineLite({onComplete:myFunction});
tl.append( ... );
tl.append( ... );

function myFunction():void {
   this.parent.gotoAndPlay(...);
}

 

Watch the video at http://www.greensock.com/timeline-basics/ to learn the basics of TimelineLite.

Link to comment
Share on other sites

yep... watched that video several times and I still can't grasp the concept. Not your fault at all though. I find that every single video I've ever watched never really gives any analogies, or ever explains it so it can be understood. Everyone just says "do this" but it's never fully explained why, and it a way that a designer can understand.

Link to comment
Share on other sites

yep... watched that video several times and I still can't grasp the concept. Not your fault at all though. I find that every single video I've ever watched never really gives any analogies, or ever explains it so it can be understood. Everyone just says "do this" but it's never fully explained why, and it a way that a designer can understand.

Bummer. Well, I'm a designer, so I feel your pain. That's why I did those visual representations in the TimelineLite video where I showed what it would look like if the tweens were organized in different ways inside the TimelineLite. But I realize it's not a super easy concept to get right away. Plenty of developers don't typically think that way either, but once you "get it", you'll suddenly see how it opens up tons of possibilities and is actually quite intuitive. Think of a TimelineLite like a MovieClip timeline in the Flash IDE - it's where you place tweens and organize them over the course of time (start at frame 20, tween until frame 60, etc.). Maybe watch it a few more times and play around with building some super simple tweens in a TimelineLite and get them to sequence, etc.

Link to comment
Share on other sites

yeah, it's not even so much the product that you have-it's just the code in general. I find that to be the case with alot of tutorials. Certain amounts of understanding what coding is and does is taken for granted, so people just say "do this and it will work", but I still can't write a single line of code and know what I'm doing... always have to go find a project and copy/paste.

 

if anything, your product makes ALOT of stuff very easy. I could never know how to just write all this in actionscript. never.

 

Ideally, I'd like to be able to read it AND understand what I'm doing... I do to a certain level, but something as simple as making a movie go somewhere once it's done, or even knowing how to create a button over and out state would be nice.

Link to comment
Share on other sites

ok, so I just put this in and I get an error

var tl:TimelineLite = new TimelineLite({onComplete:myFunction});
tl.insert(TweenLite.from(photo, 2, {alpha:0, ease:Quad.easeOut, blurFilter:{blurX:20, blurY:20}, delay:30}));
tl.insert(TweenLite.from(cal, 2, {alpha:0, ease:Quad.easeOut, blurFilter:{blurX:20, blurY:20}, delay:30.5}));
tl.insert(TweenLite.from(block, 2, {alpha:0, ease:Quad.easeOut, blurFilter:{blurX:20, blurY:20}, delay:31}));
tl.insert(TweenLite.from(date, 2, {alpha:0, transformMatrix:{x:"-10"}, ease:Quad.easeInOut, blurFilter:{blurX:20, blurY:20}, delay:31.5}));
tl.insert(TweenLite.from(location, 2, {alpha:0, transformMatrix:{x:"-10"}, ease:Quad.easeInOut, blurFilter:{blurX:20, blurY:20}, delay:32}));

function myFunction():void {
  this.parent.gotoAndPlay(111, "Scene 1");
}


stop();

 

error says "Symbol 'toronto_comp', Layer 'Layer 5', Frame 1, Line 16 1061: Call to a possibly undefined method gotoAndPlay through a reference with static type flash.display:DisplayObject."

Link to comment
Share on other sites

That error has nothing to do with the tweening classes - it's just that the "parent" property of DisplayObjects is typed as a DisplayObject which doesn't have a gotoAndPlay() method, so the compiler complains. You need to cast it as a MovieClip (assuming you know for sure that it is a MovieClip).

 

BAD: this.parent.gotoAndPlay(111, "Scene 1");

GOOD: MovieClip(this.parent).gotoAndPlay(111, "Scene 1");

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