¿eh?
- Started
- Last post
- 35 Responses
- jpolk
does any genius of flash out there know a way to pause/stop a block of code from executing?
i essentially need to pause a function until i tell it to resume.
- rabattski0
depends a little on the function you want to pause e.g. is it a function with a while loop or is it a function which always loops (e.g. 2 frame function with a gotoAndPlay(1) etc)?
you can build in an extra variable. for example: pause=false and the while loop is only executed if the pause is false. an external action, let's say a button click sets the pause=true which pauses the function. after another action pause=false again which should make the function continue again.
lots of combinations though. it really depends on what you're building / what needs to be executed.
- ozhanlion0
wrap it around afunction and use setinterval to pause that function ?
elaborate
- rabattski0
i'm not sure if you can use setinterval with a while function for instance.
- MR_T0
I think another posted said it, it really depends on what you are doing and how you are doing it.
When you say function, is this a function or a method? how is it executed, where does it live etc? A bit more info might help.
- jpolk0
hmm...
- MR_T0
hmmmm???????
- jpolk0
i really just want to pause a for loop...
for(x=1;x
- jpolk0
okay forget the code:
in a for loop:
command1
commmand2
pause 10 seconds
- MR_T0
then what?, do command 1 and 2 again?And how many times are you exectuing the for loop?
- rabattski0
can you rougly describe what you want to do? what does the function you want to pause and how you want to pause it?
for somebody that does need help you fer sure don't give enough info to advise :)
- jpolk0
thats the thing, the loop amount is dynamic, but i always want to pause between executions of the loop
here's what i was thinking...
- jpolk0
for this usage, the hold function will just space out the text so it appears to be typing.
unfortunately i need to reuse the holod function for tons of things throughout the application
- rabattski0
do you want a timed pause. whereas the function continues after a specified duration? or do you want a pause that continues after a certain user action?
- jpolk0
i actually need it to do both, depending on whether the user has selected autoplay or not.
i also need to be able to pause a multitude of functions...
i want a global function throughout the app that i can call from any function that will stop any block of code or movieclip in it's tracks, until a specified event occurs (ie: interval has passed, mouse click, key press, whatever...)
that's why i was wondering if there is a way to stop a function from executing
- rabattski0
that's going to be complex but doable.
well you can break any function. but a break really stops that function. if you restart that function it might not function like you want. unless it's dynamically build. e.g. you have a moving object which stops when you click somewhere and continues from the new position after 10 seconds.
like said before i would use a pause variable and depending on if it's true or false it continues to execute the script or not.
you can (re)set that variable either by user action or by a timed action.
it's smarter to build a function/listener who control this all. especially since you need more timed/pausable functions.
you also have to keep in mind, the more functions you have running, listeners working, the slower it gets (cpu wise). so a combo of listeners and dynamically oriented coding would be a way.
again it really depends on what you're trying to make.
- MX_OnD0
function = null;
function.delete
- jpolk0
can i reactivate it?
- MX_OnD0
should work, just tried it here in simplified form.....
- jpolk0
you mind shooting over your test?
- MX_OnD0
you got mail ;)