[AS2.0]- broadcasters and listeners help

Hello Kirupa groupies!
Im trying to teach myself AS for fun. Ive been lurking here for quite some time going through lots of the great tutorials. I decided to venture out on my own and work on a real life tutorial. Im trying to set up a very simple senario.
Here’s what i want to do:

read in xml file with a list of names to display. i have a loop set up to traverse the xml, determine the number of titles, then loop through and hold the current title in a var.
then, attachmovie ‘xyz’ which is 10 seconds long and display the current title.
at the end of the movie i want to send a message back to my script to say “hey, im done… you can continue.”

I think i want to use a broadcaster/listener senario… but im not sure. i have all the xml stuff working. I was able to use my php/xpath experience to pick that part up pretty easily. But, im kind of lost at this point. I have been reading every tutorial/chapter in my books on eventListeners and Broadcasters, but fail to grasp how the technique can apply to my senario.
At the end of my 10 second movie clip, how can i get a message back to my script and continue in my loop?
Many thanks for any input and direction.

Am I way offbase?

well you could have a function like next_name() and call that function on the last frame of your 10 second long movieclip.

… or you could use setimeout/setinterval to launch that function after/every 10 seconds, but this is not a very reliable way because the framerate is not usually consistent.

… or use the broadcaster/listener thingy which is more complicated and time consuming

Welcome to Kirupa BTW :wink:

I have simplified my code removing the xml loop and such. All that works. So far my code looks like this-

function loadMovie1(movName, movieVar){
var mov = _root.attachMovie(movName,movName, 1);
mov._x=100;
mov._y=100;
return movieComplete;
}
//Begin xml loop
//REMOVED FOR SIMPLIFICATION
xml_name = “Joe Smith”;
xml_title = “Manager”;

//load and play movie
loadMovie1(“mc_10sec_holder”, 100);

//Wait for movie to finish

trace ("Movie Variable: " +movieComplete);
//continue with loop

In my movie (mc_10sec_holder), on the last frame I set the var movieComplete to 1. Can anyone suggest a way to pause my ascript and wait for my movieComplete variable to change, then continue with the root script?

Thanks! Ive been hanging out here for about 3 months, reading and playing.
Im a helpdesk tech… and sometimes i have large amounts of time to kill. So, i figured i might as well learn something:)

[QUOTE=yamahammer;2326060]In my movie (mc_10sec_holder), on the last frame I set the var movieComplete to 1. Can anyone suggest a way to pause my ascript and wait for my movieComplete variable to change, then continue with the root script?[/QUOTE]

You can’t pause a script…

You can separate your code and launch the second part afterwards.

You can use an onenterframe loop and check the value of your movieComplete var and then act accordingly


this.onEnterFrame = function(){
  if(checker == 1){
  // do your thing
  delete this.onEnterFrame //maybe this syntax is not correct....
  }
}

BTW if you’re learning flash for fun I would suggest you to learn AS3 because AS2 will die in the next years.

thanks Pier25, that makes sense*.*
Im having one struggle… how do i pass the checker variable back to the main loop script from my movieclip? I have tried to trace _mc_10sec_holder.checker in my main loop script and get “undefined”. I assume this is very simple, but i am hindered by my lack of complete knowledge.

BTW if you’re learning flash for fun I would suggest you to learn AS3 because AS2 will die in the next years.

the workstation i inherited has MX2004 installed, so im kind of stuck with AS2.0 for now.