_global setInterval

I have my setInterval that is set this way:

pause = function () {
play();
clearInterval(stall);
}

stall = setInterval(pause, 1000);

I was wondering how I might change this to a “local” function instead of “_global”. I’ve been trying, but my syntax is either screwed up or just just plain doesn’t work.

Any suggestions?

Thanks ahead of time!

[AS]
MovieClip.prototype.pause = function() {
this.play()
clearInterval(stall);
}

stall = setInterval(pause, 1000);
[/AS]

I think

Nope… no dice. That’s not working either.

Maybe my problem lies elsewhere.

post a fla if you can

can’t use ‘pause’ as a function name

why not? Taken by flash already? On a similar note, does Flash MX support overloading of preexisting functions or user written functions?

Alright… do this… Only use the “Getting Started” and “Computer Setup” buttons. Click “Getting Started” when the project opens… after that let it run. You’ll notice that the loaded movie will stop at a sub-menu.

It works alright… But…

Goto the menu and hit the “Get Started” or “Computer Setup” buttons… and alternate as you wish.

Let the movie run again… you’ll notice that all the “setIntervals” won’t catch, and the movie totally ignores the stop at the end of the timeline.

I noticed that it only does it when I hit the buttons when the loaded movie is in the middle of a tween.

Take a look… I appreciate it.

http://www.expresiv.com/temp/NewPartnerTraining.zip

I looked in the index of “The Definitive Guide” and I didn’t see anything about flash using “pause” for any syntax… so, it should work fine. I’ve never had a problem with this script until I started loading the movie into other movies…

I have no idea about “overloading” or “user written” functions…

grandsp5: No Flash does not support overloading… unfortunately

mlkdesign: you CAN use pause, but it is not very good coding practice to use predefined actionscript features as variable or function names.

skillet: pause is a Sound Object feature. I will check out your .fla in a little bit and see if I can see what is up.

Oh man… I’m so glad you said that… cause I’m going to have to add audio later on… and that would have really messed my stuff up.

lost,
can you explain a little more about the pause feature for the sound object? I can’t find it in the AS dictionary. Is there a built in pause function for the sound object? That would mean I don’t have to build pause buttons anymore which would be nice.

No No… I’m going to add audio later… has nothing to do with this right now.

See my post where I attached the files… that will explain what is happening. If you still don’t understand what I mean, let me know and I’ll try to communicate it in a different way.

Wait i’m sorry, pause is NOT a Sound Object thing. It is an undocumented NetStream Object feature.

NetStream Object: http://chattyfig.figleaf.com/flashcoders-wiki/index.php?NetStream

[edit]skillet: i am not entirely sure I understand what the problem is :blush: [/edit]

Problem is… the pause function works fine as long as I hit the _root buttons when the loaded movie (the paused one) is either paused in a frame or stopped.

If I happen to hit the button while the loaded movie (paused movie) is in the middle of a tween, is totally cancels out the “pause function” and totally ignores my “stop();” at the end of the “loaded movie”

Understand what I’m saying? Hope that makes sense.

So… take the movies I sent you… use the “NewPartner” movie as the _root.

  1. Open the project… press the “Getting Started” button.

  2. Let the movie play until you see another “sub-menu” appear and stop.

  3. After that, press the “Getting Started” and “Computer Setup” buttons a bunch of times…

You’ll notice after that the movie will no longer hold it’s “pause functions” nor will it stop when the “sub-menu” appears.

Really, Really Weird…

Thanks for all the assistance…!