6 Replies Latest reply on Apr 18, 2007 2:14 PM by Neeeol

    Accessing library code in ActionScript

    Neeeol

      I am totally confused. I am modifying code written by someone else and need access to a class that is never created directly. What the author did was write a class and assign it to a library object using the Linkage Properties|AS 2.0 class. He creates a form using as the contentpath the library clip name (see attached code.)

      When the window is created, the frmPublishVideoStream object creates an instance of the class I need access to, "PublishVideoStreamForm". But I can't get to it in my code. It's not maintained anywhere, in fact, it is not referenced anywhere. The class has to be a property of the movie clip to which it's attached. But how do I get to it?

      If I can't access this class I'm going to have to go through a painful, and ugly process of closing all my open windows and reopening them. That will make for a very bad user experience.

      Can someone tell me how I access this? I know I can use getProperty to get the other properties such as allowMaximize. I tried getting the property "PublishVideoStreamForm", just in case the class goes in as a property under it's own name, but that didn't work. I get a compiler error, "Property name expected in GetProperty."

      Anyway, can this be accessed?
        • 1. Re: Accessing library code in ActionScript
          MotionMaker Level 1
          The class is in an AS file probably named GWWindowXP.
          Open the properties for GWWindowXP in the library and select the Advanced button and look at AS 2.0 class for the location of the code for this item.
          • 2. Re: Accessing library code in ActionScript
            Neeeol Level 1
            I'm sorry, I guess I didn't make myself clear. I know where the physical code is. What I'm trying to do is access it at runtime, I need to execute functions in that code directly, but I don't have a reference to it.

            The Library element is named "frmPublishVideoStream". It's "link to 2.0 class" property is "PublishVideoStreamForm.AS". I need to execute code in PublishVideoStreamForm.AS but cannot because I have no reference to that object at runtime. The question is, how do I get a reference to that object?
            • 3. Re: Accessing library code in ActionScript
              MotionMaker Level 1
              You use the import statement and add the line you find in the Advanced properties tag under AS 2.0.
              Then you use the instance name in the attachMovie to reference the exposed methods and properties in the class.
              As a guess at the details:
              • 4. Re: Accessing library code in ActionScript
                Neeeol Level 1
                Cool! I'll chew on this for a while and see if I can make it work.

                Thanks!
                • 5. Re: Accessing library code in ActionScript
                  Neeeol Level 1
                  I'm reading up on Import, but I think I've got a basic problem. I did this:

                  import PublishVideoStreamForm;

                  without any qualifiers, because in my arrangement, the PublishVideoStreamForm.as file is in the same directory as my ESMS.fla file (ESMS being my app name.)

                  In my code, I set my instance name to a specific value (this is going to be a problem, because we create unique instance names for each instance of the form we load. We can have as many as 12 up at a time.)

                  Neither of the calls to Howdy(); results in the alert "Howdy sailor!". I'm obviously missing something still.
                  • 6. Accessing library code in ActionScript
                    Neeeol Level 1
                    PROBLEM SOLVED!!!!!!

                    I did it in a unique way, though. Since I couldn't get what was suggested here to work, I created an array of objects in my main session class. In the constructor for my inaccessible class, I have it add a reference to itself. I can then walk through the list of windows and have access to the individual instances anytime I want.

                    It's a round about way, but whatever works!

                    Thanks for your help.