-
Moving mc with AS...for gallery.
On the main timeline i have a mc and two buttons.
The mc is just a bunch of pictures side by side - this mc is masked.
With the two buttons - next and previous - I want the mc to move and ease back and forth on the x-axis a certain number of pixels (584 actually), as these buttons are released.
So when i press the next button the mc moves 584 to the left, and if I press it again it moves another 584 px to the left. If I press the previous it moves 584px to the right.
I have this code which works fine one time - theres no previous code.
Code:
pixels = 584;
dX = (pics_mc._x-pixels); // X DESTINATION
mSpeed = 5; // THE SPEED - THE HIGHER THE NUMBER THE LOWER THE SPEED
function movenext () {
_root.pics_mc.onEnterFrame = function() {
pics_mc._x += (dX-pics_mc._x)/mSpeed;
}
}
Thank you
-
Senior Member
This is the line that is controlling where you move to:
dX = (pics_mc._x - pixels);
The problem is, it always sets dX (the destination X coordinate) to the same position (the current position minus 584).
Instead, start out with
dX = pics_mc._x;
When you want to move in one direction (say, on the click of a button), say:
dX = dX + 584;
And when you want to move in the other direction, say:
dX = dX - 584;
-
jbum to the rescue once again - thank you.
I actually found another AMAZING way of doing this while waiting for an answer here: http://www.actionscript.org/tutorial...ed/index.shtml
It seems there are some undocumented features of MX2004 which are absolutely perfect for what im doing and very powerful.
They consist of several new tween and ease methods - look at the link for all of them.
This is my code now:
code:
pixels = 584
right_bt.onRelease = function() {
tweenmc();
}
function tweenmc() {
easeType = mx.transitions.easing.Regular.easeOut;
var begin = pics_mc._x;
var end = pics_mc._x-pixels;
var time = .5;
var mc = pics_mc;
Tween = new mx.transitions.Tween(mc, "_x", easeType, begin, end, time, true);
}
left_bt.onRelease = function() {
tweenmcreverse();
}
function tweenmcreverse() {
easeType = mx.transitions.easing.Strong.easeOut;
var begin = pics_mc._x;
var end = pics_mc._x+pixels;
var time = .5;
var mc = pics_mc;
Tween = new mx.transitions.Tween(mc, "_x", easeType, begin, end, time, true);
}
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
|