Skip to main content
chienbleu
Known Participant
January 27, 2023
Question

repeat until unclick

  • January 27, 2023
  • 2 replies
  • 330 views

I am a very inexpirenced coder using Actionscript 3.0 in keyframe. What is a way to make it so the code below repeats until I unclick?

 

This topic has been closed for replies.

2 replies

kglad
Community Expert
Community Expert
January 27, 2023

for others, you would start a loop (eg, enterframe) on mousedown and end that loop on mouseup:

 

stage.addEventListener(MouseEvent.MOUSE_DOWN,downF);

stage.addEventLsitener(MouseEvent.MOUSE_UP,upF);

 

function downF(e:MouseEvent):void{

this.addEventListener(Event.ENTER_FRAME,loopF);

square.x=mouseX;

square.y=mouseY;

}

function upF(e:MouseEvent):void{

this.removeEventListener(Event.ENTER_FRAME,loopF);

}

}

function loopF(e:Event):void{

square.x=mouseX;

square.y=mouseY;

}

 

chienbleu
chienbleuAuthor
Known Participant
January 27, 2023

ah that makes sense. I did something simmilar before your reply.

 

kglad
Community Expert
Community Expert
January 27, 2023

i don't see how anything will animate with that code.

 

p.s. copy and paste code here. ie, don't use screenshots for code.

chienbleu
chienbleuAuthor
Known Participant
January 27, 2023

ignore this because i cant delete this post i dont need the information anymore