Can someone help me understand this very simple script please?

I have a simple coding question that frustrates the heck out of me. . Basically, the script below moves button_mc. 100 px when you click top then down to 100px when you click it again. I know that the simple script below works but I do not know why

It seems that his say if the variable 'jumping' is 'true' move "button_mc" up to 100 px. "The part I do not understand why ' button_mc" move down to 100 px to second click.

seems to me that it ignores this first function, because 'Skip = false' run the second function and moves to the top of 100px. Then why in the second click it move down? wouldn t it theoretically just skip the first part of the function again?

I hope this makes sense and someone can help me.

I'm so frustrated!

Thank you!!!

var jump: Boolean = false;

button_mc.addEventListener (MouseEvent.CLICK, onClick);

function onClick(event:MouseEvent):void {}
If (Jumping)
{
Event.Target.y += 100;
jumping = false;
}
on the other
{
Event.Target.y-= 100;
jumping = true;
}
}

button_mc.butonMode = true;

Whenever a movement occurs, the break value is passed to the opposite value.  So if it starts wrong, it moves-100 pixels (which is the direction upwards) and the value is changed to true.  Similarly, when you click again, it moves 100 + in the direction down.

Tags: Adobe Animate

Similar Questions

Maybe you are looking for

  • Time machine disk disappeared launching parallels

    HelloWhen I run the word on Windows 10 on 11 Parallels on my iMac, my Time Machine drive icon disappeared from my office. The time machine software stops the backup of my HD since the drive has disappeared.It reappears when parallels is closed and th

  • Best way to kill your laptop?

    Hello Can someone tell me please the best way to kill my hp pavilion dv6-3078tx? Freeze it? It burns? Fill with dust? Fall into the water? Sledge Hammer out? Anything will help if you help me get a kudo and marked as soloution Im really angry against

  • Update video card for m8430f

    I currently have a Geoforce 8500GT. Is there a better update available. I have 300 w power, windows 7 64 bit, 8 MB of ram ddr2 and single slot pci express.

  • continue to be gfxui does not

    whenever I try to open I get message saying gfxui stopped working im not very has obtained on jargon for computers so in simple terms, can anyone help please. It does not affect anything else in the measure of the im aware.

  • I need to find an autoreplay repair

    I need to find a repair for automatic playback on a vista OS.  Is this one?