all groups > flash actionscript > january 2006 >
You're in the

flash actionscript

group:

control the MC


control the MC StevenRAN
1/31/2006 8:23:09 PM
flash actionscript:
I need help with the following:

I have MC in frame 3 on my main time line.
I need 3 buttons to control the MC.

Button A
ON ROLLOVER start playing MC in reverse
ON PRESS play reverse skipping frames

Button B
ON CLICK ? stop MC

Button C
ON ROLLOVER start playing MC formard
ON PRESS play forward skipping frames

Note: when MC is first loaded I need the MC to start playing forward.

I have tried several different solutions I have found. Each solution helps me
with most of what I need, but not a 100%.

Re: control the MC Kaare
1/31/2006 8:43:18 PM
Hi Steven,

The following script should do it, or at least it's easy for you to adjust.
The MC to control is named anim_mc, and the buttons, quite streight forward,
a_bn, b_bn and c_bn.

There are a lot of handlers added, so you can just remove and/or adjust at
will ;)

Cheers,

Kaare


var iSkipFrames = 2;

function stopAnimation(){
delete anim_mc.onEnterFrame;
anim_mc.stop();
}

a_bn.onRollOver = function(){
anim_mc.onEnterFrame = function(){
if(this._currentframe > 1){
this.gotoAndStop(this._currentframe-1);
} else {
delete this.onEnterFrame;
this.gotoAndStop(1);
}
}
}
a_bn.onPress = function(){
anim_mc.onEnterFrame = function(){
if(this._currentframe > iSkipFrames){
this.gotoAndStop(this._currentframe-iSkipFrames);
} else {
delete this.onEnterFrame;
this.gotoAndStop(1);
}
}
}

c_bn.onRollOver = function(){
delete anim_mc.onEnterFrame;
anim_mc.play();
}
c_bn.onPress = function(){
anim_mc.onEnterFrame = function(){
if(this._currentframe < this._totalframes-iSkipFrames){
this.gotoAndStop(this._currentframe+iSkipFrames);
} else {
delete this.onEnterFrame;
this.gotoAndStop(this._totalframes);
}
}
}

a_bn.onRollOut = a_bn.onRelease = a_bn.onDragOut = stopAnimation;
b_bn.onRelease = stopAnimation;
c_bn.onRollOut = c_bn.onRelease = c_bn.onDragOut = stopAnimation;
Re: control the MC StevenRAN
2/1/2006 12:00:00 AM
This worked great. I can not tell you how much I appreciate this code.

I did make some changes.
I changed the var to 5.
I removed the a and c onRollOut = stopAnimation because I wan the mc to
continue playing after you roll off the buttons.

The one thing I could not figure out is..how to have the movie resume play at
normal speed after you release the PRESS.

As it is now, once you let go of the PRESS the movie stops, and to get the mc
to resume in the same direction at normal speed you need to rollout from the
button and then rollover it again.



AddThis Social Bookmark Button