• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 277
  • Last Modified:

Can't stop Movie Clip from looping

Hi Experts:

I have a strange problem. I am creating a presentation CD and it starts with a .flv file. Somehow I could not figure out how to do something when the .flv reched the finish... so instead I am waiting for the file to finish using this:

frame 1:
stop();
pause = setInterval(function () { clearInterval(pause);gotoAndPlay(8);}, 40000);

The movie is about 38 seconds so you get the point...



However, strangely enough ;-), some people want to skip the intro.... So of course I added a skip-intro Button like this:
frame 1:
on (release) {
      gotoAndPlay(8);
}



In Frame 8 I have a movie clip which fades from Black to white to transparent. To make sure the playhead is long enough there to display the fading effect, I do:
stop();
pause = setInterval(function () { clearInterval(pause);gotoAndPlay(10);}, 2000);

The actual presentation starts in frame 10.

MY PROBLEM:
=========
When the viedo plays to the end, everything seems to work. When the User clicks on "skip", also everything works fine except that after 40 seconds or so, the fading appears again and after 40 seconds again and.... Obviousely the playhead is sent back to frame 8 and it seems that the actionscript from frame 1 is doing this. I don't know how to stop it.

Can anyone see the problem here? Please help :-/

All the best,

Thomas

0
kracklt
Asked:
kracklt
1 Solution
 
Ramy_atefCommented:
There are a better way to detect the end of the flv

All you have to do is to click on the flv on stage and write this action

on(complete){
      trace("You can do whatever you want here!")
      }

Best Regards,
0
 
GuicCommented:
Hi,


use a setTimeout and a clearTimeout if you only want one loop.

Regards
0
 
rythmik1Commented:
agreed.  

also, if you have an flv with metadata you can also use the duration() and time() functions to trigger some commands at certain times.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
jack_p50Commented:
your skip intro button should also clear the interval. if it's not cleared, it will fire and go to your frame again
instead of:

pause = setInterval ....
on (release) {
     gotoAndPlay(8);
}

youneed to do

pause = setInterval ....
on (release) {
     clearInterval(pause);
     gotoAndPlay(8);
}
0
 
krackltAuthor Commented:
Hi All:

Thanks for your input. I looked at all possibilities:

Ramy_atef: I tried your solution but I could not use any actionscript on the flv. I turned it into a symbol (movieclip) but the on(complete) did not do anything :-(

Guic & rythmik1: I am sorry. I do not know enough about flash/actionscript to understand what you meant.

jack_p50: Perfekt! It works wonderfull. I must say I only copied the "pause"-script from some Web-Tipp, so I never really understood it. Your solution to my problem gets me a bit closer to understand what is going on there :-)

Thanks again to everybody.

Thomas :-)
0
 
jack_p50Commented:
You're welcome!

pause = setInterval(some_function, interval_in_milliseconds);

this code sets up an "interval", i.e. every interval_in_milliseconds, the some_function function will be called.
to be able to remove this interval (i.e., stop the regular some_function calls), setInterval returns an interval id, which is saved in the "pause" variable.
thus, you can clearInterval(pause) at any time and the interval won't be run again (or at all, if it hasn't been run yet). this is what you need because
when your user presses "skip intro", the gotoAndPlay interval has already been set up, so you've gotta clear it.
0
 
krackltAuthor Commented:
Dear Jack:

That helped. I understand now :-)

One thing I find strange though. this must be a function which is often used in Flash. Why is ther no action script commad like "pause(500);" or is there something like it?

All the best and thanks again,

Thomas :-)
0
 
jack_p50Commented:
kracklt, it's good to know that you understand it now ).

There's no such command. As to why, I think it must be difficult to implement, otherwise they would have made such a command.
I use code like this for doing something once after a while:

var temp_interval = setInterval(function() {
    clearInterval(temp_interval);
    // do something !
    some code ...
  }, 500);
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now