Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Repeat button action

Status
Not open for further replies.

radiostar

Programmer
Feb 23, 2004
14
AU
Hi,

I'm still kind of new to actionscript so I was wondering if someone could help me.

I've got a button that currently when pressed executes a function e.g.

myButton.onPress = function () {
myFunction (Parameter1,Parameter2,Parameter3);
};

How can I set it up so that whilst the button is pressed down it continues to execute the function repeatedly until the user releases it?

Any help would be very much appreciated. :)



 
The function that is to repeat over and over should be assigned to the movie's onEnterFrame when the button is pressed, and onEnterFrame should be set to NULL when the button is released.

I REALLY hope that helps.
Will
 
Thanks for the fast reponse though could you give me an example of the onEnterFrame function and how to set it to null?

I tried setting a variable on the button onPress and onRelease functions and using an if statement checking the variable value in the onEnterFrame and this works for simple functions, however when I try to set it to use my function the onRelease is never registered so the function just loops continuously. So I'm thinking perhaps this isn't the way to go. Any ideas?

Thanks.
 
Thanks! I got it now. I was using an onEnterFrame for the entire frame rather than within the button function itself. Cheers for that. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top