Groups | Blog | Home
all groups > flash actionscript > may 2004 >

flash actionscript : sliding a movie clip


Van Garnett
5/10/2004 11:50:18 PM
how do i make a mc slide across the stage and stop at specified location?

what i have done is at http://www.blookie.com/blookie/helpVan.htm. It is an
fla file.

I just can't figure this thing out!

Thanks.
Van

Ian
5/11/2004 9:13:12 AM
Hey Van,

[quoted text, click to view]

Try this.

Hey Van,

[quoted text, click to view]

Give this a try.

var mouseOverFlag_boo = false;
var limitX_num = 500;

ball_MC.onRollOver = function() {
mouseOverFlag_boo = true;
}

ball_MC.onRollOut = function() {
mouseOverFlag_boo = false;
}

// this function will execute on every frame
ball_MC.onEnterFrame = function() {
// move square_MC only if mouse is over ball_MC AND the _x
// of square_MC is less than or equal to the limit we set above
if (mouseOverFlag_boo == true && square_MC._x <= limitX_num) {
square_MC._x += 20;
}
//trace("!");
}

Ian

Van Garnett
5/11/2004 11:12:58 AM
Ian,
That worked, however, I need to do something a bit different.

I have a mc with some motion tweens. there are two frame lables in the mc,
"open" and "close". When the user goes over a button, it starts the "open"
animation, and on rollOut it plays "close". Unfortunatly, when you rollOver
and it starts to "open", if you rollOut before it is done moving it will
continue moving to finish the "open" animation.
What I really need is: on rollOver the "open" animation starts, and if the
mouse rolls out before the 30 frame animation is complete, the animation
will appear to 'reverse' smoothly.
Do you know how to do this?

If you have anymore questions please feel free to ask. I have been pulling
my hair out for 4 days over this. I an just not good enough.

I hope you can help. I have posted this same request 3 different ways but no
one responds. You are the first to respond and I am very grateful.

The file that I am really building is located here
http://www.blookie.com/blookie/helpVan.htm. It is a different one than you
saw before.

Thanks.
Van


[quoted text, click to view]

Ian
5/12/2004 2:56:39 PM
Hey Van,

[quoted text, click to view]

I think you would find it much simpler if you moved your movieclip using
code rather than frame labels and motion tweens.

If you add the following code to the initial demo file you supplied
[test001.fla] I think you'll be able to see how to achieve what you want.

var mouseOverFlag_boo = false;
var startX_num = square_MC._x;
var endX_num = 0;
var speed_num = 20;

ball_MC.onRollOver = function() {
mouseOverFlag_boo = true;
}

ball_MC.onRollOut = function() {
mouseOverFlag_boo = false;
}

// this function will execute on every frame
ball_MC.onEnterFrame = function() {

// moves the mc right to left as far as endX_num when the mouse is over our
button
if (mouseOverFlag_boo == true && square_MC._x >= endX_num) {
square_MC._x -= speed_num;
}

// moves the mc left to right as far as startX_num when the mouse is not
over our button
if (mouseOverFlag_boo == false && square_MC._x <= startX_num) {
square_MC._x += speed_num;
}
//trace("!");
}

[quoted text, click to view]

No problem. Let me know if you have any more difficulty.

Ian

AddThis Social Bookmark Button