Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0

Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
Old 10-31-2003, 02:08 PM   #1
eef
Registered User
 
eef's Avatar
 
Join Date: Oct 2003
Posts: 15
Question pause and resume movie

Hello, I am pretty clueless when It comes to action script (or any kind of script)... I am making a movie where there are parts where words come up and I want to give the watcher enough time to read the words. I know I can just put in tons of frames- but I was wondering if there is a pause and resume method I might be able to use with action script. Something to holed a movie at a certain frame for a certain amount of seconds and then resume until the next pause. Make sense?

If anyone knows a way to do this please help. And please speak and super ignorant laymens terms.

Thanks!
-eef
eef is offline   Reply With Quote
Old 10-31-2003, 08:33 PM   #2
nunomira
Senior Member
 
Join Date: Mar 2003
Location: portugal
Posts: 228
Default

hi,

you can define this function wait():
ActionScript Code:
function wait() {     stop();     var myInterval = setInterval(function () {         play();         clearInterval(myInterval);     }, 2*1000); // stop for 2 seconds }
and then, call the function from the frame where you want to movie to stop playing:
ActionScript Code:
wait();
nunomira is offline   Reply With Quote
Old 11-03-2003, 12:50 PM   #3
eef
Registered User
 
eef's Avatar
 
Join Date: Oct 2003
Posts: 15
Default

Thanks-
like I said I really don't know much more than the simplest of action scripting like stop play and goto and play type commands. All the other stuff is just confusing.

Could you explain to me how I use what you gave me- where do I set the amount of time I want my movie to pause- and how do I make it a function?

Hope I'm not wastin anyone's time. Thanks allot for helping.
-eef
eef is offline   Reply With Quote
Old 11-03-2003, 01:15 PM   #4
nunomira
Senior Member
 
Join Date: Mar 2003
Location: portugal
Posts: 228
Default

You attach the code that defines the function to the first frame of the main timeline.
And you attach the function call to the frame where you want the movie to pause.

The 2 in the function sets a 2 second pause. Change it as you wish

If you're calling the function from a different timeline, you can define a similar function but with parameters:
ActionScript Code:
function wait(mc, n) {     mc.stop();     var myInterval = setInterval(function () {         mc.play();         clearInterval(myInterval);     }, n * 1000);// stop for n seconds  }
as the first parameter you allways use this, and as the second parameter you use the number of seconds you want the movie to stop:
ActionScript Code:
_root.wait(this, n);
nunomira is offline   Reply With Quote
Old 11-03-2003, 01:47 PM   #5
eef
Registered User
 
eef's Avatar
 
Join Date: Oct 2003
Posts: 15
Default

THATS AMAZING! IT WORKED! THANK YOU FLASH MASTER!
-eef
eef is offline   Reply With Quote
Old 11-03-2003, 04:37 PM   #6
eef
Registered User
 
eef's Avatar
 
Join Date: Oct 2003
Posts: 15
Default

Ok- now that that problem is solved, here is problem 2-
Is there anyway to apply that to a movie clip that is animating also? I have a movie clip of a man walking across the screen and when the movie pauses he stops in his place, but he keeps walking in place and 2 seconds later starts moving again.

Can I apply that to my movie clip instance? Say the movie clip instance name is "man1."

thanks again for your help.
-eef
eef is offline   Reply With Quote
Old 11-03-2003, 06:30 PM   #7
nunomira
Senior Member
 
Join Date: Mar 2003
Location: portugal
Posts: 228
Default

something like:
ActionScript Code:
function wait(mc, n, other_mc) {         mc.stop(); other_mc.stop()         var myInterval = setInterval(function () {                 mc.play(); other_mc.play()                 clearInterval(myInterval);         }, n * 1000);// stop for n seconds }
and
ActionScript Code:
_root.wait(this, n, man1);
nunomira is offline   Reply With Quote
Old 11-03-2003, 07:35 PM   #8
eef
Registered User
 
eef's Avatar
 
Join Date: Oct 2003
Posts: 15
Default

You are my hero. Thanks so much. I dont understand how you did it but you did it and it worked.
-eef
eef is offline   Reply With Quote
Old 11-06-2003, 07:49 PM   #9
eef
Registered User
 
eef's Avatar
 
Join Date: Oct 2003
Posts: 15
Default

would you be willing to explain that code to me? It kind of makes sense but other parts just confuse me... or someone who understands?
-eef
eef is offline   Reply With Quote
Old 11-06-2003, 08:34 PM   #10
nunomira
Senior Member
 
Join Date: Mar 2003
Location: portugal
Posts: 228
Default

here's the explanation of the code
ActionScript Code:
/* Function definition: lets call it "wait" The function has 3 arguments: - mc -> the timeline you want to stop and then play - n -> the number of seconds you want to stop - other_mc -> the other mc you want to stop and then play */ function wait(mc, n, other_mc) {     mc.stop();     other_mc.stop();     // use setInterval to trigger something n seconds later     // and assign it a variable "myInterval" so you can clear it later     // otherwise it would repeat the same action forever     var myInterval = setInterval(function () {         mc.play();         other_mc.play();         clearInterval(myInterval); // now that everything is playing again, clear the interval     }, n * 1000); // n*1000 milliseconds = n seconds }

There are only two points here:
- the definition of a function.... you have to understand functions...
- the use of setInterval()...

Here, setInterval() is writen in a more complex way than usual...
I can give you a simple exampleof how write it in a more readable way:
ActionScript Code:
// this function just outputs "hello" function sayHello() {     trace("hello"); } // use setInterval to call the functon every 500 milliseconds setInterval(sayHello, 500);
And the same, but with the function defined inside setInterval(), like in the main piece of code, which is not so readable:
ActionScript Code:
setInterval(function () {     trace("hello"); }, 500);

The use of clearInterval():
ActionScript Code:
function sayGoodbye() {     trace("good bye");     clearInterval(myInterval); } myInterval = setInterval(sayGoodbye, 500);
The function is only called once because once it is called by the interval myInterval, clearInterval() is called and deletes the interval.
nunomira is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:42 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.
You Rated this Thread: