|
-
How can I add actionscript easing to this code?
Hello. At the moment i have some code that checks for any movieclips that are to the right of a given movieclip and makes them move 60px to the left. At the moment it works fine but the movieclips simply jump 60px left, and I'd like them to ease out instead.
Code:
function autoShiftLeft(clipIn:MovieClip):Void {
// Loop all clips
for (mc in inventoryClip) {
// Store temporary reference to clip
var tMc:MovieClip = menuClip[mc];
// If this clip is to the right of the given clip
if (tMc._x>clipIn._x) {
// Shift it left the size of one slot
tMc._x -= 60;
}
}
}
I realise the part I have to change is:
but I'm not sure how I can apply an actionscript ease within my current function.
Does anyone know a good solid code for easing out that will fit inside my function?
Thank you
-
You can use the tween class, here is the code below.
Code:
//Import the tween class needed
import mx.transitions.Tween;
import mx.transitions.easing.*;
function autoShiftLeft(clipIn:MovieClip):Void {
// Loop all clips
for (mc in inventoryClip) {
// Store temporary reference to clip
var tMc:MovieClip = menuClip[mc];
// If this clip is to the right of the given clip
if (tMc._x>clipIn._x) {
// Shift it left the size of one slot
//Code to move the movie clip left 60px.
var myTween:Tween = new Tween(tMc, "_x", Strong.easeOut, tMc._x, tMc._x-60, 1, true);
}
}
}
Last edited by ilike2; 10-17-2009 at 09:02 AM.
Reason: typo
-
Works perfectly, thanks a million, ilike2.
-
It is also possible to use timers to control the movement of the movieclip, but the tween class the most easy.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|