3 Replies Latest reply on Jul 18, 2008 4:09 PM by enzoZero

    Manipulating a movieClip instance from a class file

      I have as2 code in a class file that is imported into a fla file. I've been trying to manipulate the movieClip instance that I have on the Stage via just the Class file.


      I have a MovieClip on stage with an instance name of box_mc. I want this movie clip to turn invisble when I click the mouse button on top of it. The key is that I want all mouse press functions to only reside in the Class file and not the fla.

      The issue I am having is that when I test the movie in Flash and click on the movieClip nothing happens but the test trace() command is run.

      Any help would be most appreciated!

        • 1. Manipulating a movieClip instance from a class file
          dsdsdsdsd Level 1
          this.box.onPress = function()
          //this.box._visible = false;
          this._visible = false;

          // within the onPress handler, 'this' IS the box

          • 2. Re: Manipulating a movieClip instance from a class file
            enzoZero Level 1
            Aha! That did the trick. I have one other question if you don't mind. It seems that I am unable to embed functions in the onPress event handler function. I get an error about unknown variable when I try. Is there another way to do what I'm trying to that would allow me to click a movieClip on the stage and from that click call another function embedded within the same press function?

            I'm in the midst of converting a ton of as3 code down to as2 where I just used addEventListeners to manipulate all the movieClips on the stage. As2 has another method called addListener but it doesn't seem to function like its as3 counter part. Below I have a code snipet from as3 that I would like to achieve in as2.

            Again, any help on this matter would be most appreciated!

            Oh, thanks for you post dsdsdsdsd!!!
            • 3. Re: Manipulating a movieClip instance from a class file
              enzoZero Level 1
              Well looks like I solved my own question. For those that were wondering it looks like using 'onPress' eventHandlers inside a function places the 'onPress' event out of scope of the class to the point where you're unable to access properties and/or methods.

              I rewrote my little test code with this in mind and utilized the Delegate class in what can deem as a sort of as3 addEventListener for as2. I have listed the code below: