1

I'm new here and somewhat new to actionscript programming so I apologize for any mistakes. I'm using Adobe Flash CS6.

I'm working on a AS2 project and trying to dynamically load an external .SWF file and an accompanying .MP3 file in my main project .FLA.

What I have:

3 frames. On the 1st frame I have a simple button that advances to the next frame and a "stop();" code. On the 3rd frame I have just a simple drawing to know when I arrive at it and a "stop();" code.

...And on the 2nd frame I have a container (so, just a simple movie clip) with this code:

stop();

createEmptyMovieClip("intro_mc", 20);
intro_mc._x = 0;
intro_mc._y = 0;
loadMovie("TRANSICAO_LOGO.swf",intro_mc); 
audioClip = new Sound(); 
audioClip.loadSound("TRANSICAO_LOGO.mp3",true); 

onEnterFrame = function(){

    if(intro_mc.getBytesLoaded()==intro_mc.getBytesTotal() && intro_mc.getBytesTotal()>0 && intro_mc._currentframe==intro_mc._totalframes){
        delete onEnterFrame;
        nextFrame();
    }

}

...So, right now I can click on the button on the 1st frame and it will play me the SWF file alongside the MP3 file. The problem is, everytime that I test it, the SWF file (not the MP3) keeps looping. Only one of time it actually went to the 3rd frame.

I really don't understand what is wrong with this. I've been looking online and trying to figure out what is the problem. Does anyone know what might be causing this?

Thank you for the help!

1 Answers1

1

Looping is a natural behavior of MovieClip's.

Just place stop(); at last frame of your loaded swf. Or if it comes to you without sources place

intro_mc.stop();

inside your if(...){//here}; block

PS:

intro_mc._x = 0;
intro_mc._y = 0;

This code do nothing. Newly created MovieClip placed at 0,0 coordinates by default.

Aspiro
  • 552
  • 3
  • 7
  • Thanks. Unfortunately it didn't work. I tried it with a "stop();" at the end of the swf (before I export it and then load it dynamically in my .fla) and it plays, stops, then loops again. I also tried the "intro_mc.stop();" inside the IF but it keeps looping as well. If I add a "nextframe();" command it goes to the next frame, then loops. – NinjaBaseballBatMan Dec 03 '13 at 21:01
  • By looping you mean that your "TRANSICAO_LOGO.swf" keep changing frames inside it main timeline even if there is stops there? Could you please describe structure of you logo file? – Aspiro Dec 03 '13 at 21:09
  • I also tried "unloadMovieNum(1);" and "unloadMovieNum("TRANSICAO_LOGO");" and it still doesn't work. It's like some kind of looping-zombie and I have no idea how to stop it. – NinjaBaseballBatMan Dec 03 '13 at 21:10
  • Yes, that's what I mean. I exported it again to a .swf with a "stop();" at the end of the file and it does stop when loaded, but only for a second, before looping again. – NinjaBaseballBatMan Dec 03 '13 at 21:12
  • I ran tests with your code. My logo file is just 50 frames of shape animation with stop at the end. And all this work just like it described in code. I press btn at first frame. At 2nd - swf loads, it shows and then it reach end it stops and go to 3rd frame. At 3rd frame i see some drawings and i still see loaded swf. But it still stoped at his last frame. No loops for my. So it is something in you logo file, i think, which intefere with your code. – Aspiro Dec 03 '13 at 21:22
  • My .swf files all contain nothing in the main timeline but one frame and a movie clip container where the actual animation is stored (at the time I thought I could import the movieclip object into the main .fla project). I managed to make it work by exporting the .swf with the animation in the main timeline and not inside a movieclip. However, my problem now is that everything is off-center and moving it would mean moving every single tween operation. Thanks a lot for the help and patience. I just have to figure out how to move this now without another headache. – NinjaBaseballBatMan Dec 03 '13 at 21:40
  • Now i see where your problem is. `stop();` method stop only current timeline there you use it. So if inside you logo swf you have another MovieClip with animation inside, you should stop this MovieClip. Place `stop();` at the end frame inside your MovieClip (there your animation is). Or you could do it from you main file using right reference to animation you wanna stop. Is should looks like `intro_mc.instanceNameOfAnimationMC.stop();` inside your `if(){}` block. – Aspiro Dec 03 '13 at 21:52
  • Yes! Thank you! I finally did it! Actually, the best way to do things now is converting every movieclip animation I have inside the .swf's movieclip and the movieclip itself, to graphics, then export and load the file again. Now the code works as intended because everything is set to "graphic" instead of "movieclip". It plays the file and proceeds to the nextframe. Thanks for your patience. I can sleep well tonight :) – NinjaBaseballBatMan Dec 03 '13 at 22:16
  • Hmm. It looks like I made a mistake. Even changing the movieclips to graphics they still didn't work. It turns out that it makes no differece if they're movieclips or graphics. I managed to fix this by having enough frames on the main timeline of the .swf file to match the number of frames in its movieclip (that contains the animation). Then, on the main .fla code, I have inside the "If(){}" "unloadMovie(intro_mc); nextFrame(); delete onEnterFrame;" Crazy! – NinjaBaseballBatMan Dec 04 '13 at 01:33
  • Its really not very convenient way to solve the problem. Graphics not accessible by code at all. All you should do is learn how use right references to objects in different timelines. Both down and up. `_root`, `this`, `_parent` and `trace() - are your best friends. – Aspiro Dec 04 '13 at 01:50