9 Replies Latest reply on Apr 7, 2013 8:57 AM by Ned Murphy

    Playing a Movie Clip within a Movie Clip on load

    sushi6

      Hi,

       

      I'm trying to play a Movie Clip animation that is within a Movie Clip after a button has been pressed in a different Movie Clip.

       

      The issue is that all Movie Clip animations are playing as soon as the SWF is loaded.

       

      I have a separate Main.as file that contains all of the coding except for the animation stops:

       

      package

      {

                import flash.display.MovieClip;

                import flash.events.MouseEvent;

       

                public class Main extends MovieClip

                {

       

                var title1:Title1;

                var scene1:Scene1;

                var scene2:Scene2;

                var scene3:Scene3;

                var scene4:Scene4;

                var scene5:Scene5;

                var scene6:Scene6;

                var scene7:Scene7;

                var scene8:Scene8;

                var scene9:Scene9;

                var scene10:Scene10;

       

                public function Main()

                {

                          title1 = new Title1();

                          scene1 = new Scene1();

                          scene2 = new Scene2();

                          scene3 = new Scene3();

                          scene4 = new Scene4();

                          scene5 = new Scene5();

                          scene6 = new Scene6();

                          scene7 = new Scene7();

                          scene8 = new Scene8();

                          scene9 = new Scene9();

                          scene10 = new Scene10();

                          addChild(title1);

       

                          title1.buttonStart.addEventListener(MouseEvent.CLICK,onButtonStartClick);

                          scene1.buttonWalkOutside.addEventListener(MouseEvent.CLICK,onButtonWalkOutsideC lick);

                }

                //title

                function onButtonStartClick(event:MouseEvent):void

                {

                          addChild(scene1);

                          removeChild(title1);

                          Scene1(parent).gotoAndPlay("frame1")

                }

                //scene1

                function onButtonWalkOutsideClick(event:MouseEvent):void

                {

                          addChild(scene2);

                          removeChild(scene1);

                }

                }

      }

       

       

      So right now, I'm getting this error:

       

      TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Stage@46534041 to Scene1.

                at Main/onButtonStartClick()

       

      Any help is greatly appreciated... I've been grinding at this all night.