1 Reply Latest reply on Jul 30, 2009 5:58 AM by robdillon

    Flash IDE, duplicated objects share instances?


      I'm sorry if there is already information about this, but I litterally didn't know what to search for.


      I'm using CS3+AS3 and I have a Flash project with a menu, the items in the menu can expand to reveal more items and this is currently done by having each state of the menu in a separate frame, and then doing "gotoAndStop" in this movieclip when buttons are pressed. Perhaps not the best solution, but works very well for this purpose, but as you can imagine, this means that the "same buttons" in "different frames" will do the same thing.


      All frames were constructed by duplicating the first frame, then moving the buttons around and adding more buttons where needed. So now I set instance names to the buttons in frame #1 and added event-listeners. But when I tested the project, the buttons that had event-listeners in frame #1 also had them in all the other frames. Now this could be an awesome feature, but right now it's more of a huge mystery to me.


      The buttons that had instance names in frame #1, does not have instance names in frame #2, but yet they share the same instance. I searched all over the IDE but I could not find any functionality to actually determine what instances are linked, how to link instances or unlink instances. But I do know that two objects share instances when you duplicate them.


      So my question is, is there no functionality in the Flash IDE to actually make more efficient use of this?

      Do they simply share instances whenever you duplicate and there is no way of "seeing or knowing" this in the Flash IDE?



        • 1. Re: Flash IDE, duplicated objects share instances?
          robdillon Most Valuable Participant

          You can use the Movie Explorer window to find objects by their instance name, but this will not show you if any given object's instance name changes across the timeline.


          If you name an instance at its first keyframe, it will keep that name until it is changed in a later keyframe.

          If an object has more than one keyframe, and you name the object in any given keyframe, the name will hold only until the next keyframe. Earlier instances in keyframes will also not be named.

          If you duplicate a named object on the stage, the duplicate will inherit the instance name.


          The best practice is to immediately name your object instances as you place them on the stage. The name will then persist as you add keyframes. Duplicating an object on the stage will duplicate every property of that object including its instance name. Dragging in a new instance of a Library object will give you a fresh, unnamed, object on the stage. If you duplicate an object on the stage, rename it immediately. If you place a new instance on the stage, name it immediately.

          1 person found this helpful