A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: as 3.0 error #1034

  1. #1
    Junior Member
    Join Date
    Jul 2008
    Posts
    2

    as 3.0 error #1034

    im getting the following error on the output window, although the .swf file works just fine when tested and published.

    menu
    TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::MovieClip@1e878881 to flash.display.SimpleButton.

    this is the code that is generating the error:

    apps.addEventListener(MouseEvent.CLICK, clickapps);
    function clickapps(event:Event):void{
    trace("apps");
    gotoAndStop("apps");
    }
    entrees.addEventListener(MouseEvent.CLICK, clickentrees);
    function clickentrees(event:Event):void{
    trace("entrees");
    gotoAndStop("entrees");


    any ideas?
    thanks,
    robert
    }

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Are you sure it is that code? There is nothing wrong with the code, which should give such error. You would only get this error if you cast a SimpleButton object to a MovieClip.
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Junior Member
    Join Date
    Jul 2008
    Posts
    2

    Re:

    I am trying to create a sub-menu within the main time line ( a website for a restaurant). under the Scene 1, there is a tab menu with the following code:

    home.addEventListener(MouseEvent.CLICK, clickhome);
    function clickhome(event:Event):void{
    trace("home");
    gotoAndStop("home");
    }
    menu.addEventListener(MouseEvent.CLICK, clickmenu);
    function clickmenu(event:Event):void{
    trace("menu");
    gotoAndStop("menu");
    }
    reviews.addEventListener(MouseEvent.CLICK, clickreviews);
    function clickreviews(event:Event):void{
    trace("reviews");
    gotoAndStop("reviews");
    }
    catering.addEventListener(MouseEvent.CLICK, clickcatering);
    function clickcatering(event:Event):void{
    trace("catering");
    gotoAndStop("catering");
    }
    hosts.addEventListener(MouseEvent.CLICK, clickhosts);
    function clickhosts(event:Event):void{
    trace("hosts");
    gotoAndStop("hosts");
    }
    photos.addEventListener(MouseEvent.CLICK, clickphotos);
    function clickphotos(event:Event):void{
    trace("photos");
    gotoAndStop("photos");
    }
    contact.addEventListener(MouseEvent.CLICK, clickcontact);
    function clickcontact(event:Event):void{
    trace("contact");
    gotoAndStop("contact");
    }

    under the "menu" tab, i pretty much recreated a smaller version of the main tab menu to contain the appetizers, entrees, etc.. the script for that menu is as following:

    apps.addEventListener(MouseEvent.CLICK, clickapps);
    function clickapps(event:Event):void{
    trace("apps");
    gotoAndStop("apps");
    }
    entrees.addEventListener(MouseEvent.CLICK, clickentrees);
    function clickentrees(event:Event):void{
    trace("entrees");
    gotoAndStop("entrees");
    }

    when i run the movie, and click on the "entrees" tab the following error occurs:

    TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::MovieClip@1ce882e1 to flash.display.SimpleButton.

    When i click on the "apps" tab, the following two erros occur:

    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at barcelona_fla::MainTimeline/barcelona_fla::frame10()
    entrees
    TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::MovieClip@1ce882e1 to flash.display.SimpleButton.

    both buttons have the appropriate instance names, and the navigation is correct when tested or exported as .swf, i just can't figure out the errors. any ideas?
    thank again
    robert

  4. #4
    Senior Member
    Join Date
    Jan 2001
    Posts
    567
    Have a look at your timeline and make sure there is only one keyframe... ie your frames look continuous and there's no gaps or key frames breaking up things.

  5. #5
    Junior Member
    Join Date
    Jan 2008
    Posts
    5
    I've just had the same problem myself. A bit of detective work revealed that it has nothing to do with the code, but occurs when:

    • The swf is being run from a remote server.
    • You have a custom class on the stage which has an instance name.
    • The class is NOT declared as "Export in first frame".
    • An instance of the class doesn't appear on the first frame of the movie.


    So the solution, in my case, was just to tick "Export in first frame" in the library symbol linkage options. This made everything work fine, but if anyone knows why this is then I'd be interested to know.

  6. #6
    Junior Member
    Join Date
    Dec 2010
    Posts
    1

    Variable Type

    Just to get past the error you can use the wildcard * when you declare your variable.

    var mc:*

    Probably not best practice but it worked for me.

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