Highlighted

TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::MovieClip@64e6ca1 to fla

Explorer ,
Aug 15, 2011

Copy link to clipboard

Copied

Hi all,

I'm getting this error pop-out window when I pressed on a button. The button listener contains the following code:

btn_start.addEventListener(MouseEvent.CLICK, gotoStart);

function gotoStart(e:MouseEvent):void{

     btn_start.removeEventListener(MouseEvent.CLICK, gotoStart);

     gotoAndStop("START");

}

TypeError: Error #1034: Type Coercion fai led: cannot convert flash.display::MovieClip@64e6ca1 to flash.display.SimpleButton

at flash.display::MovieClip/gotoAndStop()

at attendanceCheck/gotoStart()[attendanceCheck::frame2:31]

After searching for the cause for a while, I can't find what is wrong with it...

Help me please...

Thanks,

Zainuu

As I said, there is nothing wrong with that code.  So since the error is indicating you are trying to treat a MovieClip as if it is a SimpleButton, somewhere in your design you have done something to attempt to coerce that MovieClip into being a Button (or possibly vice versa if it is actually a Button).  Check the properties panel and elsewhere to see if you have selected something that would be trying to make that button a different type of object than what it is.

Try creating a new movieclip and assign it that name (removing it from the other) and see if you still get the error.  If that works, then I recommend just creating a new movieclip and replacing it for the current one that is giving you the problem.

Topics

ActionScript

Views

33.0K

Likes

Translate

Translate

Report

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

TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::MovieClip@64e6ca1 to fla

Explorer ,
Aug 15, 2011

Copy link to clipboard

Copied

Hi all,

I'm getting this error pop-out window when I pressed on a button. The button listener contains the following code:

btn_start.addEventListener(MouseEvent.CLICK, gotoStart);

function gotoStart(e:MouseEvent):void{

     btn_start.removeEventListener(MouseEvent.CLICK, gotoStart);

     gotoAndStop("START");

}

TypeError: Error #1034: Type Coercion fai led: cannot convert flash.display::MovieClip@64e6ca1 to flash.display.SimpleButton

at flash.display::MovieClip/gotoAndStop()

at attendanceCheck/gotoStart()[attendanceCheck::frame2:31]

After searching for the cause for a while, I can't find what is wrong with it...

Help me please...

Thanks,

Zainuu

As I said, there is nothing wrong with that code.  So since the error is indicating you are trying to treat a MovieClip as if it is a SimpleButton, somewhere in your design you have done something to attempt to coerce that MovieClip into being a Button (or possibly vice versa if it is actually a Button).  Check the properties panel and elsewhere to see if you have selected something that would be trying to make that button a different type of object than what it is.

Try creating a new movieclip and assign it that name (removing it from the other) and see if you still get the error.  If that works, then I recommend just creating a new movieclip and replacing it for the current one that is giving you the problem.

Topics

ActionScript

Views

33.0K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
LEGEND ,
Aug 15, 2011

Copy link to clipboard

Copied

There is nothing wrong with that code, so if there is a problem with it, it might be due to something else in the file.  Since you show the error message in two pieces it gives the impression you are not showing the entire error message, as though you left out a middle section.  If so, the start of the missing section is where you are likely to find the true error indication.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Explorer ,
Aug 15, 2011

Copy link to clipboard

Copied

Hi Ned Murphy,

That is the entire error msg. Sorry for the wrong impression... I have other buttons going to other frames which does not gives me any errors. But for the button that brings me to frame "START", it gives me that error.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
LEGEND ,
Aug 15, 2011

Copy link to clipboard

Copied

As I said, there is nothing wrong with that code.  So since the error is indicating you are trying to treat a MovieClip as if it is a SimpleButton, somewhere in your design you have done something to attempt to coerce that MovieClip into being a Button (or possibly vice versa if it is actually a Button).  Check the properties panel and elsewhere to see if you have selected something that would be trying to make that button a different type of object than what it is.

Try creating a new movieclip and assign it that name (removing it from the other) and see if you still get the error.  If that works, then I recommend just creating a new movieclip and replacing it for the current one that is giving you the problem.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Explorer ,
Nov 29, 2012

Copy link to clipboard

Copied

Thnaks for this, Ned. i was getting the same # 1034 error, which was happening inconsistently, i.e. sometimes yes, sometimes no error. i realized i was using an instance name of play_btn when in fact, that was for a MovieClip and not a simple button. So i fixed the code and instance name to reflect the MovieClip. I think the issue's been fixed.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
LEGEND ,
Nov 29, 2012

Copy link to clipboard

Copied

You're welcome

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
zopy_in LATEST
New Here ,
Sep 17, 2013

Copy link to clipboard

Copied

My Error :-

TypeError: Error #1034: Type Coercion failed: cannot convert the_game@24d270b1 to flash.display.MovieClip.

          at Game::Player/update()

          at the_game_itself/update()

I tried as your suggestions. But unable to slove error.

Here is my

the_game_itself update function :-

public function update(evt:Event)

                    {

                              //******************

                              //Handle User Input

                              //******************

                              if (moveX > 0)

                                        player.moveRight();

                              else if (moveX < 0)

                                        player.moveLeft();

                              else if (moveX == 0)

                                        player.stopMoving();

                              if (jump && !player.isInAir())

                              {

                                        player.jump();

                                        jump = false;

                              }

                              //******************

                              //Handle Game Logic

                              //******************

                              //Update lifts

                              for (var l=lifts.length - 1; l >= 0; l--)

                              {

                                        lifts.update();

                              }

                              //Update Player

                              player.update();

                              //Check for collisions

                              if (player.isInAir() && player.isFalling())

                              {

                                        for (var i=bricks.length - 1; i >= 0; i--)

                                        {

                                                  if (player.hitAreaFloor.hitTestObject(bricks))

                                                  {

                                                            //Player landed on the brick

                                                            player.hitFloor(bricks);

                                                  }

                                        }

                                        for (var j=lifts.length - 1; j >= 0; j--)

                                        {

                                                  if (player.hitAreaFloor.hitTestObject(lifts))

                                                  {

                                                            //Player landed on the lift

                                                            player.hitFloor(lifts);

                                                  }

                                        }

                              }

                              //Check for collisions

                              for (var k=coins.length - 1; k >= 0; k--)

                              {

                                        if (player.hitTestObject(coins))

                                        {

                                                  //Player obtain a coin

                                                  playerScore += C.SCORE_PER_COIN;

                                                  //Remove the coin

                                                  mcGameStage.removeChild(coins);

                                                  coins.splice(k,1);

                                        }

                              }

                              if (player.notInScreen())

                                        gameOver();

                              //******************

                              //Handle Display

                              //******************

                              //Display new Score

                              txtScorePlayer.text = String(playerScore);

                    }

Player update function :-

public function update()

                    {

                              //Move Horizontally

                              if (this.speedX < 0)

                              {

                                        //Check if player should move

                                        if (MovieClip(root).playerShouldMoveLeft())

                                        {

                                                  this.x += this.speedX;

                                        }

                                        else

                                        {

                                                  MovieClip(root).scrollGameObjects(-this.speedX);

                                        }

                              }

                              else if (this.speedX > 0)

                              {

                                        //Check if player should move

                                        if (MovieClip(root).playerShouldMoveRight())

                                        {

                                                  this.x += this.speedX;

                                        }

                                        else

                                        {

                                                  MovieClip(root).scrollGameObjects(-this.speedX);

                                        }

                              }

 

                              //Move Vertically

                              if (this.speedY < C.MAX_SPEED)

                                        this.speedY += C.GRAVITY;

 

                              if (this.inAir)

                                        this.y += this.speedY;

                              else

                              {

                                        //Move the player as its floor moves

                                        if (this.standingOn != null)

                                                  this.y = standingOn.y;

                              }

 

                              if (standingOn != null)

                              {

                                        //Check if player has moved off the floor it stands on

                                        if (!this.hitAreaFloor.hitTestObject(standingOn))

                                        {

                                                  removeFloor();

                                        }

                              }

 

                              //Animate

                              if (this.inAir)

                              {

                                        if (this.currentLabel != C.PLAYER_JUMP)

                                                  this.gotoAndPlay(C.PLAYER_JUMP);

                              }

                              else if (this.speedX > 0)

                              {

                                        if (this.currentLabel != C.PLAYER_RIGHT)

                                                  this.gotoAndPlay(C.PLAYER_RIGHT);

                              }

                              else if (this.speedX < 0)

                              {

                                        if (this.currentLabel != C.PLAYER_LEFT)

                                                  this.gotoAndPlay(C.PLAYER_LEFT);

                              }

                              else

                              {

                                        if (this.currentLabel != C.PLAYER_IDLE)

                                                  this.gotoAndPlay(C.PLAYER_IDLE);

                              }

                    }


Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...