PDA

View Full Version : Movie Clip _x Direction - please help


Bifurd
03-27-2008, 03:09 PM
I have a movie clip (main_mc) moving from right to left, stopping on rollOver and continuing to move on rollOut like this:

onClipEvent (enterFrame)
{
_x+=(distance*speed);
if (_x > 0) _x=-641;
if (_x < -2197) _x=-688;
}

on(RollOver){
this.stopped = true
}
on(RollOut){
this.stopped = false
}
onClipEvent(enterFrame) {
if(!this.stopped){
speed = 2;
this._x -= speed;
}
}

I have 2 other separate movie clips (controlLeft_mc, and controlRight_mc) on the stage. How can I make these 2 movie clips control the x direction of the main_mc movie clip on rollOver?

Thanks

jorawar
03-28-2008, 10:53 AM
Hi,
make three movie clips on the stage .
name them as mainMc, mc_1, mc_2
and put this code on first frame of stage.

var stopAnim:Boolean = false;
mainMc.onRollOver = function() {
stopAnim = true;
};
mainMc.onRollOut = function() {
stopAnim = false;
};
function fun() {
if (!stopAnim) {
speed = 1;
mainMc._x -= speed;
mc_1._x -= speed*2;
mc_2._x -= speed+2;
if (mainMc._x<(0-mainMc._width)) {
mainMc._x = 800;
}
if (mc_1._x<(0-mc_1._width)) {
mc_1._x = 800;
}
if (mc_2._x<(0-mc_2._width)) {
mc_2._x = 800;
}
}
updateAfterEvent();
}
var Id:Number = setInterval(fun, 10);

always use to put the code on frames, that is easy to call or handle other instances.

jorawar
03-28-2008, 10:56 AM
Hi find the attach file . .. .