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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a delay in actionscript 1

Status
Not open for further replies.

simonWMC

Programmer
Dec 2, 2002
180
GB
Hello

I want to create a short delay using actionscript.

When the user presses a button I want the playhead to go to a certain frame wait for 5 seconds then goto anothoer frame.

is this possible ? I'm sure it is.....
 
my_btn.onRelease = function(){
gotoAndStop(...);
wait = setInterval(paused,5000);
function paused(){
clearInterval(wait);
gotoAndStop(...)
}
}
 
thanks Bill

I have this attached to the actual button, and am using it to control a movie clip.

The code i now have is :

onRelease = function(){
w_fback.play(2);
wait = setInterval(paused,5000);
function paused(){
clearInterval(wait);
w_fback.play(1);
}
}

I am getting a handler error on the first line. I tried :

on(release) = function(){

that doesn't work either.
I don't understand that first line - any ideas ?

thanks again

 
that code was for the button having an instance name and should have gone on main timeline


to attach to the button use

on(release){
_root.w_fback.gotoandplay(2);
wait = setInterval(paused,5000);
function paused(){
clearInterval(wait);
_root.w_fback.gotoandplay(1);
}
}
play() means something else

i think you mean to use gotoandplay or gotoandstop

 
silly me !!!

changed the first line back to

arrest.onRelease = function(){

and put in on the timeline - works perfectly

thanx bill !!!! have a star !
 
Code:
on(release){
    w_fback.gotoAndStop(2);
    wait = setInterval(paused,5000);
    function paused(){
        clearInterval(wait);
        w_fback.gotoAndStop(1);
    };
}


Regards,

cubalibre2.gif
 
Untested...

Code:
on(release){
    w_fback.gotoAndStop(2);
    wait = setInterval(paused,5000);
    function paused(){
        clearInterval(wait);
        w_fback.gotoAndStop(1);
    };
}


Regards,

cubalibre2.gif
 
yes - i have been using play(), as i changed it to movie clips rather than on the timeline.

cheers
 
if i want to add that same script to three buttons on the same frame is there an easy way to do it ? Or do I need to copy it underneath like this :

arrest.onRelease = function(){
w_fback.play(2);
wait = setInterval(paused,5000);
function paused(){
clearInterval(wait);
w_fback.play(1);
}
}
charge.onRelease = function(){
w_fback.play(2);
wait = setInterval(paused,5000);
function paused(){
clearInterval(wait);
w_fback.play(1);
}
}

 
one way

arrest.onRelease = charge.onRelease = function(){
w_fback.play(2);
wait = setInterval(paused,5000);
}

function paused(){
clearInterval(wait);
w_fback.play(1);
}
 
That works well, thankyou

Trouble is now, something else wierd has happened.

If the user clicks the button a second time, before the code has finished - ie, after the wait. It just loops and goes back to the start.

Is it possible to stop the second click until the wait time has elapsed.
Or can anyone think of a better way of doing it ?

Thanks all, i really appreciate your help
 
arrest.onRelease = charge.onRelease = function(){
clearInterval(wait)
w_fback.play(2);
wait = setInterval(paused,5000);
}

function paused(){
clearInterval(wait);
w_fback.play(1);
}

that should do it
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top