Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

load mc via loadMovie and play only once!

Posted on 2008-06-23
11
Medium Priority
?
1,693 Views
Last Modified: 2013-11-11
Hello,

I think this should be easy, but I must be missing something.  I have a two frame movie.  First frame is stop().  Second frame has a mc on it.  I export this to a swf.

I load the swf in my movie.  I would like it to play once and then I would like to take it off the stage.  But, it keeps looping and looping.  What to do?

Code below.

Many thanks in advance!
_root.createEmptyMovieClip("myIntroAnim",_root.getNextHighestDepth());
		for (i=0; i<=1; i++){
		_root.myIntroAnim.loadMovie(path+"Section1IntroAnim.swf");
		setProperty("myIntro",_x,80);
		setProperty("myIntro",_y,60);
		}
        _root.myIntroAnim.gotoAndPlay(2);
		_root.myIntroAnim.removeMovieClip();
		trace("I am in intro");

Open in new window

0
Comment
Question by:1Cougar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 3
11 Comments
 
LVL 8

Expert Comment

by:Dreammonkey
ID: 21847280
change the 7th line to goToAndStop like i code below,
or just put a stop(); in the actions layer ...
 
_root.createEmptyMovieClip("myIntroAnim",_root.getNextHighestDepth());
		for (i=0; i<=1; i++){
		_root.myIntroAnim.loadMovie(path+"Section1IntroAnim.swf");
		setProperty("myIntro",_x,80);
		setProperty("myIntro",_y,60);
		}
        _root.myIntroAnim.gotoAndStop(2);
		_root.myIntroAnim.removeMovieClip();
		trace("I am in intro"); 

Open in new window

0
 
LVL 8

Expert Comment

by:Dreammonkey
ID: 21847319
sorry, this one is better, I guess...
_root.createEmptyMovieClip("myIntroAnim",_root.getNextHighestDepth());
		for (i=0; i<=1; i++){
		_root.myIntroAnim.loadMovie(path+"Section1IntroAnim.swf");
		setProperty("myIntro",_x,80);
		setProperty("myIntro",_y,60);
		}
        _root.gotoAndStop(2);
		_root.myIntroAnim.gotoAndPlay(2);
		_root.myIntroAnim.removeMovieClip();
		trace("I am in intro");
 

Open in new window

0
 

Author Comment

by:1Cougar
ID: 21847449
Hi,

I have a 1 frame movie run in actionscript, so I don't want to have the root go to frame 2.  The external movie plays fine until I load it in the main movie.  Frame 1 has the mc on it with the action and Frame 2 has a stop().  Movie plays 1 time and then stops.  But, when I load it in main movie, it loops over and over and it seems like I can't control the movie.  Maybe there are too many nested movie clips?  This is how it is:

Main movie-->mc myIntroAnim --> loads Section1IntroAnim.swf -- has 2 frames, frame 1 with mc and frame 2 with stop.

Thanks again,
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.

 
LVL 8

Expert Comment

by:Dreammonkey
ID: 21847523
Ok, how about this one?
_root.createEmptyMovieClip("myIntroAnim",_root.getNextHighestDepth());
		for (i=0; i<=1; i++){
		_root.myIntroAnim.loadMovie(path+"Section1IntroAnim.swf");
		setProperty("myIntro",_x,80);
		setProperty("myIntro",_y,60);
		}
        
		_root.myIntroAnim.gotoAndPlay(2);
		_root.myIntroAnim.removeMovieClip();
		trace("I am in intro");
		stop();

Open in new window

0
 
LVL 18

Expert Comment

by:Antonio Estrada
ID: 21847987
Why are you using removeMovieClip? removeMovieClip(); is the counter method for attachMovie();, not loadMovie(); ...You should use unloadMovie instead.

unloadMovie(_root.myIntroAnim);

Another thing, if the loaded MovieClip has 2 frames and you're telling him to gotoAndPlay(2) it could be the cause for the looping, why don't you use gotoAndStop(2)

-V
0
 

Author Comment

by:1Cougar
ID: 21848900
Hi there and thanks for your comments.  I will change the remove Movie Clip statement.  I have gotten the movie to stop looping by putting another stop() in the nested mc (swf).

Now I have another issue.  The main movie doesn't wait for the swf to finish playing before moving ahead....what can I do to stop the main movie to wait until the loaded swf has finished?

Thanks a lot for any ideas!

Cheers!
0
 
LVL 18

Expert Comment

by:Antonio Estrada
ID: 21848985
Well since you're loading and unloading pretty much at the same time you can't see anything. A way make sure the entire loaded swf is played is the following:

<code>

Or something along these lines, would be better to see your *.fla to see it working/failing.

Good luck.

-V
_root.createEmptyMovieClip("myIntroAnim",_root.getNextHighestDepth());
                for (i=0; i<=1; i++){
                _root.myIntroAnim.loadMovie(path+"Section1IntroAnim.swf");
                setProperty("myIntro",_x,80);
                setProperty("myIntro",_y,60);
                }
        
                _root.myIntroAnim.gotoAndPlay(2);
                _root.myIntroAnim.onEnterFrame = function() {
                    _root.stop();
                    if(this._currentframe == this._totalframes) {
                        _root.play();
                        unloadMovie(this);
                    }
                }
                trace("I am in intro");
                stop();

Open in new window

0
 

Author Comment

by:1Cougar
ID: 21849705
Hi,

Your suggestion has improved performance in that it is stopping, but it does not move forward.  In fact, I put a "trace" statement inside of the function myIntroAnim.onEnterFrame and it never executes....why would it never go into the function?

Any ideas?


0
 
LVL 18

Expert Comment

by:Antonio Estrada
ID: 21850317
Interesting.

Looks like something's wrong with the loadMovie method, I'll create a test *.fla for you to use. Do you have Flash 8 or CS3?

-V
0
 
LVL 18

Accepted Solution

by:
Antonio Estrada earned 2000 total points
ID: 21850527
Ok, I assume it's Flash 8.

Check it out and let me know if you have any questions.

http://evilrealm.polygonized.com/IntroLoader.zip

It has two files, loader.fla and childMovie.fla. The "childMovie" is the one containing the Intro animation.

-V
0
 

Author Comment

by:1Cougar
ID: 21854170
Hi and thanks!  Your code is perfect and that is now working....but, still more issues.  Will post another question.

Cheers!
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question