5 Replies Latest reply on Dec 22, 2015 2:43 PM by kglad

    how can you return a object reference to _level0.<instanceName>


      I am writing action script for a piece of software that was developed to play AS2 files.  The problem is I would really like to not have to learn AS2, since AS3 seems like such a better option.  The movie itself will run but there are combo boxes and text boxes on the 'player' itself that allow you to input values to the variables in action script.  The 'binding' as far as I can tell relies on mx.core.UIObject which is not in AS3.


      Other things I have noticed, the player is looking for a reference to an object of type mx.core.UIObject that when you 'trace' the object the output panel says "_level0.<whateverNameOfTheInstanceAtLevel0>"  Knowing about as much as I know with AS2, the level0 or _root object should be a MovieClip?  Then how would I 'cast' a movie clip to a mx.core.UIObject... or any other ideas???

        • 1. Re: how can you return a object reference to _level0.<instanceName>
          kglad Adobe Community Professional & MVP

          _level0 is the main timeline in the as2 swf (unless the as2 swf is loaded into an as3 swf).


          in any case, are you trying to convert the as2 to as3, or are you loading an as2 swf into an as3 swf or something else?

          • 2. Re: how can you return a object reference to _level0.<instanceName>
            gt5364e Level 1

            Hi kglad!  Really "glad" to see you replied


            I will try to be as specific as possible.  The flash controls that I will develop are going to send commands and read parameters from a piece of embedded software on a PC.  The company that sold us this interface, which is packaged as an .exe, sort of does not 'write' software primarily so their interface uses some old technology, namely AS2 and Windows DDE.  So in order to get the binding to happen correctly I have to create my class with specific set and get methods and extend their class which is an extension of mx.core.UIObject (since it is AS2 code).  I understand enough about AS2 to know the only reason I can't rewrite their class in AS3 is because of the way they are fiddling around with the _root to obtain an object reference to the level0 movieclip at runtime.  The key line in their class is something in their class constructor like this:  (not exact, I don't have it open at the moment, will edit later).


            _root.components = _root.components + getInstanceAtDepth(_root.getDepth());


            So this is creating a parameter called .components in the _root object at runtime that acts as a 'pointer' to the root.  When I put a trace statement "trace(_root.components);" it returns _level0.classname which as you stated is a instance of the class running at the main timeline. I can get the same output putting "trace(this);" in the root timeline it returns _level0.classname


            I think it will work that I can add code to the main timeline but AS3 complains about having 'classes' running in the main timeline.  I can create simple shapes on the stage then export them for actionscript, but even then I think the 'root' here is the stage.


            Anyway it sounds like something that should have a fix, I doubt that I am the first one to have this problem

            • 3. Re: how can you return a object reference to _level0.<instanceName>
              kglad Adobe Community Professional & MVP

              i don't see how you can extend an as2 class with an as3 class.


              and i don't understand how you're doing anything with with an exe, other than execute it.

              1 person found this helpful
              • 4. Re: how can you return a object reference to _level0.<instanceName>
                gt5364e Level 1

                The executable is able to interact with the SWF.  I don't know exactly how either other than they said it uses DDE.


                It sounds like I am stuck writing in AS2.


                I suppose now I have a follow-on question about how to use the Flash Pro components library in an AS2 project.  The last version of this which contained AS2 components was CS4, all subsequent versions the code snippets and components library are AS3 code and can not be used in an AS2 project.  So do I have to go find a copy of CS4 out there somewhere or is it possible to download the AS2 components?


                I know this is a separate question and may have to become a separate thread.  Thanks.

                • 5. Re: how can you return a object reference to _level0.<instanceName>
                  kglad Adobe Community Professional & MVP

                  you can use flash pro cs6 (which is included in cc subscriptions that include flash pro).


                  Download and install Adobe Creative Cloud apps

                  1 person found this helpful