Jump to content
GreenSock

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

Help, struggling! Flash timeline "playing" "stop" question

Recommended Posts

Hello!

I am building several tweened animations in Flash and then playing them in Adobe Director 11.5. The code I have in Director waits for the timeline to stop playing (playing = false) then advances to the next externally linked SWF.

 

All of the code I find for the TimelineMax and TweenMax is on one frame, and if I add more frames the tweens restart and act erratically. Is it possible to have the flash timeline longer so Director thinks it's still playing and then jump to a frame label that says stop(); when the Tween is finished? Here is what I have so far:

 

import com.greensock.*;
import com.greensock.easing.*;
import flash.events.*;
import flash.events.MouseEvent;
//create line
var line:Shape = new Shape();
addChild(line);
// variables for destination
var destx:Number = 1046;
var desty:Number = 480;
//position moving dot at first point
//be sure the instance name is mc
mc.x = p0.x;
mc.y = p0.y;
dest.x = destx;
dest.y = desty;
//kill existing line
line.graphics.clear();
//start new line at first point
line.graphics.lineStyle(5, 0xFF0000, .9);
line.graphics.moveTo(mc.x, mc.y);
var tl:TimelineMax = new TimelineMax({paused:false,onUpdate:drawLine});
tl.appendMultiple([
 TweenMax.to(fade2black, 2, {alpha:0}),
 TweenMax.to(mc, 2, {x:dest.x, y:dest.y}),
 TweenMax.to(blackfadeout, 1, {alpha:1, delay:2, onstart:clearLine, onComplete:endStop})
 ], 0, TweenAlign.SEQUENCE);
function drawLine()
{
line.graphics.lineTo(mc.x, mc.y);
}
function endStop() {
trace("End of Tween");
gotoAndPlay(20);
}
function clearLine() {
line.graphics.clear();
}

Link to comment
Share on other sites

Putting the onComplete callback in there is exactly what I would have recommended.

When you say the tweens start acting erratically, I can only imagine that perhaps your code on frame 1 is executing again. You should be able to have the flash main timeline advancing why the scripted tweens play without issue. Are you sure you have enough frames in your main timeline?

 

I would add

 

trace("frame1")

 

to frame 1. test your swf, does frame 1 get played again before your scripted timeline ends?

Link to comment
Share on other sites

Yes, it keeps looping back to Frame 1. Perhaps I need to add a whole lotta frames. :)

 

In Director there is a "go the frame" behavior where it can loop until released.

Is there such an animal in Flash AS3? Or is that a "gotoAndPlay(4)" when you're on 4 or 5?

 

I admit I haven't touched AS3 much. What I was hoping to rely on was a callback function to Director using the GetURL but that is now deprecated in AS3. I found a few helpful tips on writing a class but then that conflicts with the Tween class.

 

What my main goal is:

Tweens run...

End of all Tweens (onComplete) tell the timeline to stop(); or hop to a frame that says stop();

 

The one frame movie doesn't work because the playhead is 'done' after the one frame. Which causes the Director movie to say.. "hey, it's done, let's move on".

 

Pondering... but welcoming more feedback and guidance. :)

 

Cheers,

Monica

Link to comment
Share on other sites

Thank you! Your guidance with the frame checking led me down a path that solved my problem.

 

MUCH appreciated!

Cheers,

Monica

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