Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Controlling a movie within a movie.

Community Expert ,
May 07, 2011 May 07, 2011

Here's my problem. I have a movie on a stage (MyMovie) that I can control with start and stop buttons. Let's call it MyMovie. Inside that movie there are 4 layers. Layer one has movie1 which contains a movie created with a movie clip symbol that has been tweened over 60 frames. Layer 2 has a movie clip which has the movement generated by action script using a simple aray. That movie has start and stop buttons controlling the action script movie. Layer 3 has a movie clip (movie3) that is generated using the built feature copy motion as actionscript 3.

I know it's kind of confusing so here's a screenshot of the MyMovie timeline:

MyMovie.png

Here is the Scene timeline:

Scene.png

The problem I'm running into seems like it should have a simple solution. The first line in the Actionscript for Scene 1 is stop(). I expect MyMovie not to play. The blue outline around the yellow circle is actually a blue circle below the yellow circle. It is the only component of MyMovie that derives it's animation from a tween. It is also the only part of the animation that is stopped. The yellow circle, motion by a tweening a simple array will play with the stop and go buttons and the orange circle animates all the time. Pressing the big go button causes the blue circle to animate, pressing the stop button causes the blue circle to stop, but all the other animations inside MyMovie keep running. I have no control over the embedded movies.

Does anyone have an idea for a solution? I seems to me that it should be easy to start and stop all elements embedded inside MyMovie by simply stopping MyMovie. There's obviously something that I'm missing here.

If anyone has the time to help I'd appreciate it. Here's the project file. I thought it would be easier than posting all of the actionscript.

TOPICS
ActionScript
716
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 07, 2011 May 07, 2011

A stop(); command is a timeline command, nothing more, it stops progression of the timeline.  If your animations don't animate along the timeline, then a stop command won't have any effect on them.  Stopping those that use actionscript to animate will require actionscript to stop them.

If you used the approach I offered in your other posting to animate one of them, then the pauseButton's event hamdler function code should take care of stopping it.

As for the one generated using the copy motion feature, if I knew how that AnimatorFactory class worked I might be able to help, but not knowing is why you ended up with what I provided yesterday.  I still work with CS3, and that class isn't in that version, so it must be part of a one of the newer releases.  But if you have any spirit for adventure, if you look up that class in the help documents you might be able to find out what methods it is supported by that you might be able to put to use... it may be as simple as using object.stop() / object.play(), where object is whatever the AnimatorFactory object is.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 07, 2011 May 07, 2011

I think you've hit the core problem. Animation as actionscript doesn't respond to the stop(); command. Neither does the array/tween animation you offered up as help yesterday. I can stop the animation from within the movie by placing buttons inside the movie, but if the movie, in this case movie3, is inside MyMovie in the main scene I can't make it stop.

I would think that there are those that build things like walk cycles, or timers, that are created with action script. I would also assume that those elements are embedded in movie clips on separate layers inside the scene. I would think that it would be common to put some kind of controller in the Scene on a layer that would control these embedded actionscript movies. At least that is the way I would do it.

Thanks again for your help. You pushed me a long way down the road to understanding how to control an array. Unfortunately I can't seem to get that control to cross the embedded movie barrier.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 07, 2011 May 07, 2011
LATEST

You don't need the button to make the code stop the movieclip, but you need the code to stop the movieclip.  How you implement the code depends on where you have the animation code for your movieclip.

If the code is inside the movieclip, then you could call the inner pause function from outside the movieclip if you give the movieclip an instance name so that you can target it...  Say you gave it an instance name of "arrayAnimatrion"... then in the timeline where the stop() is you could tell that movieclip to stop using...

stop();    // this stops your timeline animation

arrayAnimation.pauseClick(); // this stops the array version

The only stipulation there is that you need to alter the pauseClick function slightly to allow it to be called without an argument being passed to it.  While that function call just shown doesn't pass any argument, the button clicking sends the event as an argument.  So adding the "=null" to the argument in the funcion definition allows it to work either way.

function pauseClick(evt:MouseEvent=null):void {
    MyMovie.removeEventListener(Event.ENTER_FRAME, tweenMC);
}

And if you didn't plan to have any buttons controling it, then you don't need to specify the argument at all...

function pauseClick():void {  // I'd rename it since "Click" isn't applicable, but wouldn't matter

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines