skipallmighty / tweener

Automatically exported from code.google.com/p/tweener
1 stars 0 forks source link

Not a defect; it's the way actionscript works. #10

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. onComplete:functionname(someparameter)
2.
3.

What is the expected output? What do you see instead?

expect functionname to be called after tween 
instead function is called with correct parameter but
well before the tween completes possible at start of tween.

What version of the product are you using? On what operating system?
actionscript3 version , windows vista pro

Please provide any additional information below.

Original issue reported on code.google.com by mirki...@googlemail.com on 31 May 2007 at 2:03

GoogleCodeExporter commented 9 years ago
I've done more testing on this problem:
onComplete works perfectly if you pass it a function that takes no arguments.
If you pass a function with an argument then it is called at the wrong time, 
too early.

The reason I need to pass a parameter to the function is that I use Tweener on
many objects that share a function I want to perform onComplete so they pass
themselves to the function.

Could I also add my thanks to all who have worked on this project that may just 
keep
me from going crazy with the flawed tween class that ships with flash CS3. 

Original comment by mirki...@googlemail.com on 31 May 2007 at 2:12

GoogleCodeExporter commented 9 years ago
When you need to pass a function as a parameter in Actionscript, you can't use 
the
"functionname(parameters)" syntax. It's also a common mistake. This is wrong:

Tweener.addTween(this, {_x:10, time:1, onComplete:trace("finished") });

That will immediately execute the function and pass the return value (if any) 
as a
parameter instead. Tweener won't even know there was a function there.

The correct way is to pass the function reference *only*. If parameters are 
needed,
they're passed on the onCompleteParams parameter (it's an array). For example:

Tweener.addTween(this, {_x:10, time:1, onComplete:trace, 
onCompleteParams:["finished"]});

You can also wrap your function around other anonymous function:

Tweener.addTween(this, {_x:10, time:1, onComplete:function() { 
trace("finished"); });

Although the documentation is still lacking in many ways, please check it as 
this is
discussed there. Check the onStart description (onStart/onUpdate/onComplete use 
the
same syntax):

http://code.google.com/p/tweener/wiki/TweeningParameters

The mailing list is also better for discussion of the syntax as there's more 
people
who are able to help there. The issue list is more for verified bugs.

Oh, and thanks! :)

Original comment by zisfor...@gmail.com on 31 May 2007 at 2:22

GoogleCodeExporter commented 9 years ago
Perhaps I've not explained well enough

This works perfectly and at the correct time.

function test()
{
//do something
}
Tweener.addTween(<movieclip>,{y:100,time:5,transition:"easeOutQuad",onComplete:t
est});

This doesn't, it gets called before completion of the tween.
It works perfectly but at the wrong time.

function test(param:int)
{
//do something
}
Tweener.addTween(<movieclip>,{y:100,time:5,transition:"easeOutQuad",onComplete:t
est(20)});

Original comment by mirki...@googlemail.com on 31 May 2007 at 12:34

GoogleCodeExporter commented 9 years ago
I'm an idiot, I added the above comment because I thought my explanation was 
poor. I
just realised you already replied and set me straight. I'll give myself a slap 
on
your behalf.

Sorry again and thanks,
Alex.

Original comment by mirki...@googlemail.com on 31 May 2007 at 12:38

GoogleCodeExporter commented 9 years ago
Don't worry.

I also realized the issue questions were poor (we were still using the default 
google
code ones) and didn't ask for proper information such as code samples when 
submitting
an issue report. I've customized it now so hopefully in the future we'll get 
that out
of the way quicker.

Original comment by zisfor...@gmail.com on 31 May 2007 at 12:57