A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: TypeError: Error #1034 while adding a child to screen

  1. #1
    Member
    Join Date
    Nov 2007
    Location
    Los Angeles, CA
    Posts
    32

    TypeError: Error #1034 while adding a child to screen

    I am attempting to add a child to the stage with the following code:
    Actionscript Code:
    //Buttons: Adds movie clip to stage.
    readtomeShortA1.addEventListener(MouseEvent.CLICK, playShortAReadMe1);

    function playShortAReadMe1(e:TimerEvent):void{
        var playShortA1:ShortAReadMe1 = new ShortAReadMe1
        addChild(playShortA1);
        playShortA1.x = 307;
        playShortA1.y = 603;

    }


    When I test the movie the following message appears, "TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::MouseEvent@212a161 to flash.events.TimerEvent," when I click the button ("readtomeShortA1"). Note the instance I am referring to is a button. When the swf is created there are compile errors that appear. The "TypeError....." only happens when I click on the button ("readtomeShortA1").

    FYI, there is other code on the page which is below the code in question:

    Actionscript Code:
    //Button Code
    backTo.addEventListener(MouseEvent.CLICK, backToShortA);
    function backToShortA(event:MouseEvent):void
    {
        gotoAndPlay(1);
        SoundMixer.stopAll();
    }

    ForwardTo2.addEventListener(MouseEvent.CLICK, toPage2);
    function toPage2(event:MouseEvent):void
    {
        gotoAndPlay("page_2");
        SoundMixer.stopAll();

    }

    What am I doing wrong?

  2. #2
    Member
    Join Date
    Nov 2007
    Location
    Los Angeles, CA
    Posts
    32
    Here is another piece of information:

    "ShortAReadMe1" is a movieclip (class) that has sound on the timeline.

  3. #3
    Senior Member
    Join Date
    Jun 2008
    Posts
    549
    change this

    function playShortAReadMe1(e:TimerEvent):void{

    to

    function playShortAReadMe1(e:MouseEvent):void{

  4. #4
    Member
    Join Date
    Nov 2007
    Location
    Los Angeles, CA
    Posts
    32
    Thanks. Simple error due to long hours.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center