-
[F8] dead paus script
OK I have a "pause" script, but it's only working on the main time line.
I am trying to get it to work on a time line in a nested mc. The mc stops, but doesn't resume play after alloted time. why is that?
here's my script:
stop();
var myInterval = setInterval(function () {
play();
clearInterval(myInterval);
}, 2*1000);
Thanks,
RSB
-
Senior Member
my goodness that the incorrect way to use set interval ....the first parameter specifies which function to execute the second parameter tells setInterval how many milliseconds to wait before executing the function and as you guessed clear interval tells myInterval to stop executing.
Code:
stop();
var myInterval = setInterval(myfunc,2000)
function myfunc () {
play();
clearInterval(myInterval);
}
I think i will find another way its not my time to go.......I guess I'll die another day
Last edited by calmchess; 06-11-2007 at 08:27 PM.
~calmchess~
-
thanx
Thank you, I'll try that out tomorrow.
-
OK, I tried the script as laid out, and it doesn't work. Now it doesn't work on the main time line either.
-
So how can I get a script that will pause a script on a nested time line?
I've looked all over and nothing seems to work (they all are good on the main time line but not nested).
-
Try this code :
Code:
stop();
sec = 2;
var nInterval:Number = setInterval (countDown, 1000)
function countDown() {
sec -= 1;
if(sec == 0){
play();
clearInterval(nInterval);
}
}
i hope it helps you
-
That doesn't really work.
on the first pass it pauses ok but the on each pass after the pause is shorter and shorter.
What I need to know is this. Using the script I have, how can I get it to work on a nested time line? What dot notation do I use and where to select a nested time line.
The script is as follows:
stop();
sec = 2;
var nInterval:Number = setInterval (countDown, 1000)
function countDown() {
sec -= 1;
if(sec == 0){
play();
clearInterval(nInterval);
}
}
-
This uses two recursive functions, one to stop all movies and one to play all movies.
Code:
//
function stopAllMovies(instance) {
instance.stop();
for (var n in instance) {
if (typeof (instance[n]) == "movieclip") {
arguments.callee(instance[n]);
}
}
}
function playAllMovies(instance) {
instance.play();
for (var n in instance) {
if (typeof (instance[n]) == "movieclip") {
arguments.callee(instance[n]);
}
}
}
var sec, nInterval;
var myPath;
function countDown() {
sec -= 1;
if (sec == 0) {
playAllMovies(myPath);
clearInterval(nInterval);
}
}
// set myPath to movieclip that you want to start with
myPath = [_root];
stopAllMovies(myPath);
sec = 2;
nInterval = setInterval(countDown, 1000, myPath);
But you may find that you really don't want to start all of the nested movie clips playing. For example, movie clips that are used as buttons.
-
As you've seen, using the code stop(); only stops the timeline the code is in.
If you're on one timeline and want to stop another, you have to use a reference to that timeline. Usually this is done by instance names. So if you want to stop a movie clip with an instance name of "box", you use the code:
box.stop();
If you want to play that same clip, you use the code:
box.play();
-
I don't want to stop or play "all movies".
I just want to pause a time line nested on the main time line.
main time line
l
l
------------- nested time line
l
l
stop();
var nInterval = setInterval(Play, 5000);
function Play() {
clearInterval(nInterval);
gotoAndPlay(_currentframe+1);
}
Why doesn't this script work on the time line it is on? If I need to refrence the timline that contains the script why doesn't "this." work?
I don't want to make it a function. The reason is that I want to use it on different frames on different time lines with different pause times. If I make it a function I can't do that. When I call the function from various places the pause time will all be the same. I suppose I could create a different function for each pause, but that seems to defeat the purpose.
RSB
-
Code:
stop();
this.nInterval = setInterval(playMe, 2*1000, this);
function playMe(mc) {
clearInterval(mc.nInterval);
mc.gotoAndPlay(mc._currentframe + 1);
}
Instead of repeating the function, you can make it global and use it wherever you want...
Code:
_global.playMe = function(mc) {
clearInterval(mc.nInterval);
mc.gotoAndPlay(mc._currentframe + 1);
};
Last edited by dawsonk; 06-12-2007 at 03:28 PM.
Reason: Added more...
-
If the code you have isn't stopping the timeline it's in, you've got something else wrong in your file. There's no way to know without seeing the file.
As far as not wanting to set up a function, a function is a perfect way to code something once and have it affect many different things. It would be pretty easy to code a function that can be told which clip to stop and for how long.
-
Yes I realize a function would be good here, I was hopping that I could do it easier.
Noe one has been able to tell me why I can't use my initial code yet, why it works on the main time line but not nested.
RSB
-
Thanks for all the help every one, but the "prize" goes to dawsonk.
Thanks, it worked!!!!
-
it worked fine I think, but I have discovered a bug in cs3
Last edited by belotte; 06-12-2007 at 06:41 PM.
-
Update...
Dug through some old files, and this is how it was implemented. When using nested swfs, needed to be able to kill any intervals that might be running before removing the loaded swf.
On main timeline...
Code:
_global.intID = new Array();
_global.playMe = function(mc, num) {
clearInterval(intID[num]);
intID.splice(num, 1);
mc.gotoAndPlay(mc._currentframe + 1);
};
// call this to kill any Intervals that may still be running
_global.cleanUp = function() {
while (intID.length > 0) {
clearInterval(intID.pop());
}
};
On timeline you want to pause...
Code:
stop();
intID.push(setInterval(playMe, 2 * 1000, this, intID.length));
PS: What was the CS3 bug?
Last edited by dawsonk; 06-13-2007 at 05:31 PM.
Reason: Typo...
-
Thanks, so in your example the "2*1000" is passed as the pause interval? So each time you use it you can specify different pauses. is that correct?
The bug was that in the script browser flash cs3 was duplicating the action script from the first frame and placing it in all the other frames, and wasn't allowing me to delete or change the action scripts with out changing all of them.
It seems to work ok now, some times. Could be just a bugy computer as well though.
-
Yes, the 2*1000 is the pause interval, could also use just 2000, instead. Yes, each time you use it you can specify different a pause interval.
-
Thanks, that's cool, not sure I completely understand it, but I'm still not that good in AS (obviously).
Thanks a lot.
-
Flashmatics
you may find the snippet :: Pausing A Movie :: in my library handy for pausing a timeline
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|