Results 1 to 2 of 2

Thread: AS3 gotoAndStop

  1. #1
    Join Date
    Aug 2009
    Thanked 0 Times in 0 Posts

    Default AS3 gotoAndStop

    I am trying to use the following code

    function eventResponse1(evt:MouseEvent):void {
    function eventResponse2(evt:MouseEvent):void {
    function eventResponse3(evt:MouseEvent):void {
    And it works great if the buttons are in the same frame however I need the buttons to be in different frames and that's where it breaks with the error:

    TypeError: Error #1010: A term is undefined and has no properties.

    I can get this to work in AS2 applying the actionscript to the button itself but using AS3 with an external script file or the script on the main timeline I get the error mentioned above.

    Any ideas why this is happening? If more details is needed I can provide it.


  2. #2
    Join Date
    Jan 2008
    Near Chicago
    Thanked 2 Times in 2 Posts

    Default That's my old code your using :) let me help

    I had the exact problem too
    -almost two years ago when I was just learning as3

    You are using frame based animation and adding the code to make it navigate and at different frames your buttons might not always be there.

    The error you are getting is because the code is looking for a button that has been removed, so it's telling you -hey where is it?

    You can work around this by making sure all your buttons are present on all frames and in memory.

    But what if you don't want them there right?

    you can hide them one of two ways -you can move them off the stage by placing them at -500 x or y and then putting them back when you want them -but ALLWAYS keep them somewhere

    later on you will find it easier with code -namely you can create a statement like:
    if (currentFrame==50){mybutton_mc.visible=false};
    currentFrame tests which frame you are in and visible keeps things in memory and in the same place it just takes them out of sight and nullifies their interactivity until you set the visible of that button back to true.

    and do that for each button rather than having to edit your frames.

    later on, instead of having flvs with allot of frames you might want to group buttons and animated part into movieclips with their own timelines. You would then use code to create instances of these groups and remove them from memory rather than having to jump frames so much.

    It's confusing at first because if I remember correctly as 1,2 used to let you assign scripts to buttons and place them (and the code with it) wherever you wanted.

    Let me also recomend a good book. Learning ActionScript 3.0 by Shupe & Rosser it explains everything very well and got me off the ground.
    Last edited by evan; 10-23-2009 at 09:41 PM.


Posting Permissions

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