hi…back one again, still working on that gallery and I need some help
I just finished learning how to use mx.tweens (before I was building the tweens by myself) and I really enjoy the simplicity of built in tweens.
The problem is I don’t know how to verify if a Tween is ended I searched the net and found that I have to add a listener to the tween, found some examples too but neither one is working or I found it in AS3 cuz if I try to run it it gives me some errors “the class or interface could not be loaded”
Basically I just wanna move an MC with mx tween and do some other stuff if the MC reached the desired position and the tween stopped.
myMC.onPress = function(){ myTween = new mx.transitions.Tween(this, “_x”, mx.transitions.easing.Strong.easeInOut, this._x, this._x+100,2, true); }
myTween.addEventListener(TweenEvent.MOTION_FINISH, doSomeStuff);
function doSomeStuff(e:TweenEvent):void{ trace(“the tween! She’s a’finished!”) }
the error is given on the line: function doSomeStuff(e:TweenEvent):void{ if I remove the e:TweenEvent there is no error message but nothing happens when the mc stopped moving (and I read that the e:TweenEvent is neccesary ).
You should import tween classes first.
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
And yes, tweenEvent is necessary.
You should import tween classes first.import fl.transitions.Tween;
And yes, tweenEvent is necessary.
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
I forgot to mention that the imports were done…. and still showing the error
class or interface fl.transitions.TweenEvent could not be loaded
(I use flash CS3 …)
- Author had a Free File of the Month
- Microlancer Beta Tester
- Beta Tester
- Contributed a Tutorial to a Tuts+ Site
- Won a Competition
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Item was Featured
- Author was Featured
- Referred between 1 and 9 users
It looks like you’re mixing AS2 with AS3 code, that’s why you’re getting all those errors.
- Author had a Free File of the Month
- Microlancer Beta Tester
- Beta Tester
- Contributed a Tutorial to a Tuts+ Site
- Won a Competition
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Item was Featured
- Author was Featured
- Referred between 1 and 9 users
The TweenEvent class is an AS3 class
- Author had a Free File of the Month
- Microlancer Beta Tester
- Beta Tester
- Contributed a Tutorial to a Tuts+ Site
- Won a Competition
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Item was Featured
- Author was Featured
- Referred between 1 and 9 users
If I was you, I’d use Jack Doyle’s TweenLite/Max tweening class, it’s really awesome! It features a special property – onComplete – which allows you to reference a function/method of your choice that you need to invoke once the tween is finished.
Long story short, IMHO that’s the best solution to your problem 
