5 Replies Latest reply on Sep 21, 2012 9:14 AM by sinious

    Having two of the same class in the library


      I have a GUI that I'm working on with textInput fields.


      I would like to have several different TextInput forms, each with a different graphical style. For example, one with a green background and one with a red.


      At the moment I have, in my library, a single TextInput form. I can use this multiple times on my form. However, I am just creating instances of this class and any graphical changes made to one of them affects all of them.


      I have tried clicking on the TextInput class and selecting 'duplicate'. However, when adding an instance of the duplicate class to the stage, it causes excessive flickering when the output .swf is run.


      I know this is probably trivial, but I'm new to Flash.


      Thanks for reading

        • 1. Re: Having two of the same class in the library
          sinious Ninja

          Flickering is typically due to a MovieClip without a stop() on a frame when there's more than one frame. When you duplicate the clip did you keep the same base class? For example you might have had the item as a TextField or TLFTextField but when you duplicated it you accidently set it as a MovieClip and added an accidental blank frame. Then it would play the MovieClip and every time the playhead moved to the blank frame it would appear like the TextField is blinking.


          To explain the library, the behavior you see is completely normal. To be efficient the library contains objects and you're allowed to re-use them over and over. When you drag out your TextField from the library, that is what we call an "instance". The behavior you saw was designed work exactly as it did. When you double-click on any one of the "instances" you dragged out of the library you are directly editing the library item itself, not what you clicked on. Therefore all other "instances" you dragged out will receive the updates you made to that library item.


          To get around this you must make a separate library item for each style you want. Duplicating the clip you have and customizing that is the easiest. The same will happen with your newly duplicated library item though. If you drag out multiple "instances" of that and change any one of them, any other instances of that same library object will be updated as well.


          If you understand that much let me know and I'll explain how you can cut down on some of the unnecessary duplicated parts by nesting clips inside each other which is how skins works.

          • 2. Re: Having two of the same class in the library
            Wozza12 Newcomer

            Ah, I think you are correct In that I was not specifying a base class when duplicating my TextInput. In fact, I can only specify a base class if I click on 'export for actionscript'? so I was just getting the default I suppose.


            I actually tried calling stop() on the duplicate that was flickering. This did stop the flickering, so I guess it was doing exactly what you said!


            I am not sure what to put in the 'Class:' and 'Base Class' fields for the duplicate though. For the original TextInput class, the base class field is empty, and the class field is 'fl.controls.TextInput'


            EDIT - I've changed the original TextInput to have base class: 'fl.controls.TextInput' & class: 'TextInput'. I then tried giving the duplicate the same base class and a different class name. It works in the sense that they are both functioning TextInput fields. However, drawing a line on one of them also affects the other

            • 3. Re: Having two of the same class in the library
              sinious Ninja

              Ahhh, you're using a component. Components have skins and you've probably noticed when you added the TextInput to your library a bunch of folders/movieclips came with it. That is the skin for the component. If you want to create more skins, here's a decent starting point to understand the concepts:



              • 4. Re: Having two of the same class in the library
                Wozza12 Newcomer

                Ah great. Thank you for all the help!

                • 5. Re: Having two of the same class in the library
                  sinious Ninja

                  You're welcome and good luck!