PDA

View Full Version : stalling actionscript for 5-6 seconds (as2.0)


udjamaflip
10-17-2008, 02:04 PM
Hi,

I have written this:


setInterval(gotoAndPlay(1),5000);


Which should force the script to wait 5000 miliseconds before it continues onto running the gotoAndPlay() however it doesn't.

Any ideas?

gnomeontherun
10-17-2008, 03:16 PM
I think the function called inside of setInterval has to be a custom function and not a command like gotoAndPlay(1);

So try something like this>

setInterval(playMovie(), 5000);

function playMovie() {
gotoAndPlay(1);
}

udjamaflip
10-17-2008, 03:23 PM
Unfortunately this doesn't work. any other ideas?

gnomeontherun
10-17-2008, 03:55 PM
If you aren't getting any errors, perhaps the function is placed somewhere it isn't being called?

Add this to my code and see if its getting called. Otherwise you need to post some relevant code or its impossible to know whats going on.

setInterval(playMovie(), 5000);

function playMovie() {
gotoAndPlay(1);
trace("Hey you called me.");
}

itsallkizza
10-17-2008, 05:41 PM
(accidental double post - dont know how to delete)

itsallkizza
10-17-2008, 05:43 PM
Ah, you guys are close.

this bit of code calls a function:
functionName()

this bit of code is the function:
functionName

You want to pass the actual function into setInterval, not what it returns.

This will do the trick:

setInterval(playMovie,5000);

gnomeontherun
10-17-2008, 05:45 PM
Ah, you guys are close.

function myFunction()

What?

Also upon review, if the function is getting called properly, then perhaps the gotoAndPlay function is not being attached to the proper object. For instance, if you want to gotoAndPlay on a movieClip named MC, do this

movieClip.gotoAndPlay(1);

or on the root put

_root.gotoAndPlay(1);

itsallkizza
10-17-2008, 05:57 PM
Sorry, for some reason my post got submitted while I was still in the middle of typing it out.

If you run
setInterval(playMovie(),5000)
then flashplayer will call/run playMovie a single time and grab it's return value.

You will see your trace a single time but will not repeat.

setInterval was designed for repeating commands, so if you don't want it to repeat, then you'll have to do something like this:

function runFunctionAfter(functionToRunOnce:Function,milliseconds:Number):Void
{
this.f = function(ref):Void
{
functionToRunOnce();
clearInterval(ref.intervalID);
delete ref;
}
this.intervalID = setInterval(this.f,milliseconds,this);
}

function myFunction1()
{
trace("hey1");
}

function myFunction2()
{
trace("hey2");
}

new runFunctionAfter(myFunction1,1000);
new runFunctionAfter(myFunction2,4000);

wangjiahua
10-20-2008, 01:40 AM
Cindy, is this the thing you were looking for?
www.liangdianup.com/computeraccessories_1.htm
It's on the list of computer accessories and parts. They have the DVI video thing to convert that jap monitor to work with your other computer. Just about any other kind of wire adaptor, usb connectors, monitor extension wires, ps2 extention wires, and all kinds of female and male swap connectors and things that I think would help your shop. If that above link don't work then goto www.lducompany.com and click on computer accessories. Let me know if that is what you need and give me your email address again.
I
:thumbsup: