HELP Please!
I’m a beginner to Flash CS4 - AS3 and I’m stuck. I made a movie clip - designed to be a border around dynamic links. I want this border to slide up and down with ease after the link has been clicked. The border’s start position is set to where the first button is and changes to the position of the second button after clicking the second button. However, any clicks after the first (for instance, if I were to click on the first button again), result in an incomplete positioning of the border - it only goes halfway up or down and the only way to get it to where it should be is to click on the target button many times. I’m pretty sure the problem lies with the ease of motion coding, but where? Can anyone please help me diagnose this problem? Here is my code:
content_mc.stop();
var target:Number = button1.y + 3;
var speed:Number = 2;
button1.num = 1;
button2.num = 2;
button1.addEventListener(MouseEvent.CLICK,onClickListener);
button2.addEventListener(MouseEvent.CLICK,onClickListener);
function onClickListener(e:MouseEvent):void{
var frame:Number = e.currentTarget.num;
var target:Number = e.currentTarget.y + 3;
content_mc.addEventListener(Event.ENTER_FRAME, entFrame);
function entFrame() :void {
var difference:Number = target-current.y;
current.y += difference/speed;
if (difference == 0) {
content_mc.removeEventListener(Event.ENTER_FRAME, entFrame);
};
};
content_mc.gotoAndStop(frame);
};
Thanks in advance!!!