4 Replies Latest reply on Apr 27, 2012 12:14 PM by Ned Murphy

    How do you call different layers of a symbol in actionscript?

    DLee2499

      Hello,

      I am new to flash cs5 and am making a flash program to simulate interactions between aircrafts. I have two objects, leftplane and rightplane. Then, I have sub-symbols (don't really know what they are called) that have different tweens. For example, I have my leftplane in the timeline, I double click it to bring up leftplane1 which has a tween, and then I double click it again to bring up leftplane2 which has a different tween. I want to trigger the animations for these tweens by buttons, which I have already inserted. However, I do not know how to call these seperate tweens to trigger them. Currently, I am trying to do:

       

      leftplane.play();

      leftplane1.play();

      leftplane2.play();

       

      I receive error 1061 stating "Call to a possibly undefined method stop through a reference with static type of Class." Any help resolving this would be greatly appreciated. Thanks.

        • 1. Re: How do you call different layers of a symbol in actionscript?
          Ned Murphy Adobe Community Professional & MVP

          It sounds like you have planes as children of planes.  Based on what you explained you would need to target the inner planes via the out planes...

           

          leftplane.play();

          leftplane.leftplane1.play();

          leftplane.leftplane1.leftplane2.play();

           

          It doesn't sound like your error has to do with the code you show.  I seems as though you have a class and you are trying to use a stop(); command for it.  You use a stop for a movieclip symbol/timeline, not a class.

          • 2. Re: How do you call different layers of a symbol in actionscript?
            DLee2499 Level 1

            Ned,

            That seems to be helping. The errors are gone when I use the code that you provided. However, when I put the same code you provided with stop instead of play at the top of my script, it does not stop the planes from tweening before any buttons are pressed. Is leftplane the symbol name or the instance name? That could be my issue.

            • 3. Re: How do you call different layers of a symbol in actionscript?
              DLee2499 Level 1

              Ned,

              Just figured it out. Thank you for your help! I was using symbol names instead of class names in my code.

              • 4. Re: How do you call different layers of a symbol in actionscript?
                Ned Murphy Adobe Community Professional & MVP

                Neither of those two names would be correct. Symbol names are the names you give them in the library.  THose are pretty much meaningless except to give you something to help identofy/arrange them.  Class names are what you mig consider an object's type... what kind of object it is.  You cannot target an object using its class name because most often there would be several such classes around (MoiveClip, Button, TextField, etc... are all class names)

                 

                Instance names are names you assign to an instrance of a class.  I f you drag a copy of your airplane symbol from the library onto the stage, you would assign it an instance name in the properties panel where it says "<Instance Name>".  THat is the name you use to target an object with code.  It is an instance because might have several of them on the stage... you could drag more from the library and name each something else so that you could control each one separately.