Flash Q: Movie Clip Tween Prototypes
- Started
- Last post
- 12 Responses
- CyBrainX
For those of you using Penner equations with the Movie Clip Tweening functions:
What in God's name does this "scope of call back function" mean???? I've tried all kinds of movie clip nesting and no combination of black magic will allow the simplest function to work.
This is from the documentation
function as callback
function onEnd(){
trace("onEnd");
}
my_mc.tween("_x",100,1,"linear...// scope of function is my_mc._parent
- lvl_130
scope, like when it get's to a certain point it tells trace to report it?
is that what you mean?
- CyBrainX0
No, I understand what the function does, but I don't know how to target the call back function (onEnd).
What timeline is it on?
Does this code go inside a movie clip?
Nothing works.
The hardest thing about Flash is always matter of scope. I don't know why this was set up to target the parent.
- Anarchitect0
you change the scope to a variable itself: target
and including it to the main function as a parameter.
that way you can target any movie with those functons.
- lvl_130
sorry cyber, i guess i didn't understand your question at first.
- Solid0
// scope of function is my_mc._parent
So it should be equivalent to
my_mc._parent.onEnd();
- CyBrainX0
I don't understand "you change the scope to a variable itself: target" (from Anarchitect) How can you change the scope?
and if it should be my_mc._parent.onEnd(); then does that mean you cannot put any movie clips to be tweened on the _root timeline? (since _root doesn't have a _parent) ?
- canuck0
....I find that this guys modified tween.as version is easier to call functions.
- Solid0
You can place movieclips (eg. my_mc) to be tweened on the _root timeline. The code would be place in a keyframe on the _root timeline.
So the '_parent' of 'my_mc' would be '_root' in the this case.
- CyBrainX0
Canuck, I got my script to work. I don't really understand it fully, but I'm happy for now.
I will look into your link more when I get the chance. That could be life-saving.
You're right about one thing.
onTweenComplete() is a lot more intuitive than the questions I posted for this thread.
- Solid0
Assuming your placing my_mc on the root timeline:
my_mc._parent.onEnd();
_root.onEnd()are the same thing.
- unformatted0
var cb = { scope:_root, func:"onEnd" };
my_mc.tween("_x",100 ,1,"linear",0, cb ) ;or
my_mc.tween("_x",100 ,1,"linear",0, { scope:_root, func:"onEnd" }) ;