Skip navigation
sushi6
Currently Being Moderated

Playing a Movie Clip within a Movie Clip on load

Apr 4, 2013 5:51 PM

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,onButt onStartClick);

                    scene1.buttonWalkOutside.addEventListener(MouseEvent.CLICK, onButtonWalkOutsideClick);

          }

          //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.

 
Replies
  • Currently Being Moderated
    Apr 4, 2013 6:48 PM   in reply to sushi6

    What are you attempting to do in the line:

     

           Scene1(parent).gotoAndPlay("frame1")

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 5, 2013 4:37 AM   in reply to sushi6

    You basically just read the code back to me.  I am asking a more pointed question.  What is the movieclip you are trying to animate and why are you casting it as "Scene1()" to try to target it? 

     

    If the object you want to animate happens to be "scene1", then just target scene1.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 5, 2013 5:36 AM   in reply to sushi6

    Then use:    scene1Text1.gotoAndPlay("frame1");

     

    If that is not what you are really trying to do in the coding of it, then explain it in more detail. 

     

    I don't see where a Scene1 object could be the parent of anything relative to the function you were trying to use it in.  What is that parent you are trying to target the parent of?

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 7, 2013 8:56 AM   in reply to sushi6

    I can only guess you were wrong in saying "the movie clip I'm trying to animate is named scene1Text1"

    
     
    |
    Mark as:
  • Currently Being Moderated
    Apr 7, 2013 8:57 AM   in reply to sushi6

    I have to assume there is a solution, but I cannot tell what the problem is due to not knowing what you are really trying to do with what object

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points