Jump to content
GreenSock

jwiley

addCalback Not Acting as I ASSume

Recommended Posts

Here's what I have seen in the doc's:

//call myFunction when the "virtual playhead" travels past the 1.5-second point. myTimeline.addCallback(myFunction, 1.5); //add a tween to the beginning of the timeline, pushing all the other existing tweens back in time

myTimeline.prepend(new TweenLite(mc, 1, {tint:0xFF0000}));

 

Here's my code:

 
import com.greensock.*;
import com.greensock.easing.*;
import flash.display.MovieClip;
//MovieClip FLV Videos from Library
var mc:Array = new Array;
mc[0]= new MC1 as MovieClip;
mc[1]= new MC2 as MovieClip;
mc[2]= new MC2 as MovieClip;
var timeLine:TimelineMax=new TimelineMax({onComplete:done});
timeLine.addLabel("first", timeLine.duration);
timeLine.addCallback(addMovieFromLibrary(mc[0]),1);
function done():void{
    trace ("done");
}
function addMovieFromLibrary(mc:MovieClip){
addChild(mc);
}

 

I get this output:

Error: Cannot tween a null object.

at com.greensock::TweenLite()

at com.greensock::TimelineMax/addCallback()

at Test_main_timeLine_fla::MainTimeline/frame1()

Link to comment
Share on other sites

I'm a little rusty, but it looks like your not tweening anything.

Lookup delayedCall:

TweenLite.delayedCall(1.0, addMovieFromLibrary,[mc[0]] );

Link to comment
Share on other sites

Yes, you could add a delayed call to your timeline as pixeldroid suggested (thx) but addCallback allows you to do the same with less code.

 

When using addCallback() you need to separate the function from the parameters you want to pass in.

 

addCallback(function, insertionTime, params)

 

timeLine.addCallback(addMovieFromLibrary, 1, [mc[0]]);

 

The params must be in brackets as an Array.

 

Read more about addCallback here:

http://www.greensock.com/as/docs/tween/com/greensock/TimelineMax.html#addCallback()

Link to comment
Share on other sites

I modified Line 12 to:

timeLine.addCallback(addMovieFromLibrary,1, [(mc[0])]);

Hi Again,

I had to remove the function call parameters from the 'addCallback' 1st param and put it into the 3rd param as a array item.

 

The doc are extremely vague for this one.

 

A couple of posts earlier gave me the clue enough for trial and error testing. I did not try to reverse enginner you code.

 

Do I need to go to v12 ???

 

What would my code look like for functions with multiple param's? or a string of tweenmax's or even nested TimeleineMax's?

 

I am creating a series of instruction movies. They are in the form of: Title/Intro state, play movie, Instruction page , play movie, another Instruction page, play movie, ... ... , End instruction movie sequence.

 

After this is done, I add slider controls and time display assist in adding time captions to be added/removed.

 

I will even have to make a tutorial and a template for internal use and maybe modify it for an online tutorial too. It will help me with understanding my non/lite programmers that will have to use the template I make from this project.

 

Love this code suite. love the accessories.

 

Thanks,

Jim Wiley

Link to comment
Share on other sites

Thanks guys,

I will look up delayCall for a clue in the structure.

Carl love your instruction videos.

If I waited 30 min., you would have gotten me started on the road to making this work.

Thanks again,

Jim

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