7 Replies Latest reply on Jun 11, 2007 2:05 AM by smazr123

    Refer to class with string

    smazr123 Level 1
      Is there any way to load something with linkage using a string like in AS 2? for example, say I had a movie called "something1" and "something2" linked from my library. I could use a generated string to load one or the other???
        • 1. Re: Refer to class with string
          kglad Adobe Community Professional & MVP
          you can't load anything from the library. you're creating (or flash is creating for you) a class, a member of which, you can add to your swf by invoking the keyword new and your class name.

          that class name cannot be a composition of two other objects like string, objects or classes. so, no.
          • 2. Re: Refer to class with string
            kglad Adobe Community Professional & MVP
            you could, however,, create a class to which you pass a parameter (like 1 or 2 etc) and that class could instantiate the class you wanted. or you could just use a switch statement in the actions panel to trigger instantiation of the class you wanted.
            • 3. Re: Refer to class with string
              SmileKZS
              Hey kglad you misunderstood him. He meant no class. He meant A LIBRARY SYMBOL WHICH IS CONNECTED WITH A CLASS AND HAS A LINKAGE IDENTIFIER. Luckily the attachMovie() accepts strings only so you can just concat two strings and then pass the result to the attachMovie();
              • 4. Re: Refer to class with string
                kglad Adobe Community Professional & MVP
                i don't think i did misunderstand. this is as3.

                there is no linkage id anymore. you can only instantiate library objects by assigning them a class and then using the "new" constructor.
                • 5. Re: Refer to class with string
                  smazr123 Level 1
                  hmmm... how unfortunate. I always used to load up button pictures by linkaging them with the same name as the button. That way I could have a different picture for a single dynamic button. I guess thats not possible anymore
                  • 6. Re: Refer to class with string
                    SymTsb Level 2
                    yeah i think many people are going to find themselves a bit disoriented by the changes in AS3 but even more so with the fact that attachMovie was removed. Personally, this doesn't affect me but I know plenty who are. There are ways around this that aren't actually too difficult to handle at all.
                    • 7. Re: Refer to class with string
                      smazr123 Level 1
                      For the button problem I found that using named frames works well. I've started using named frames as a replacement for a lot of things. In this case the button has a movie in it that goes to the frame with the designated picture, the frame being based off of the buttons name. I also use named frames to synchronize variose sections or things that can happen on a website, which is based of a label I give to the various buttons when I first load them. Its a good way of dynamically arranging information in what is effectively just an interactive menu system. It makes it easy to change any given piece on the fly, while being able to change the whole template at once as well, if that makes any sence.