2 Replies Latest reply on May 27, 2006 1:25 AM by Newsgroup_User

    Flash class scoping problems

    I tried Level 1
      I am creating a movie clip within an actionscript class in a method I titled init(). I have declared the movieclip at the start of the class with this:

      private var mcEmptyTest :MovieClip;

      My code to create the clip is this:

      createEmptyMovieClip("mcEmptyTest", this.getNextHighestDepth());

      I have also tried this

      mcEmptyTest = createEmptyMovieClip("mcEmptyTest", this.getNextHighestDepth());

      I cannot seem to access the movieclip's properties from any other method within the class. Can someone please let me know how to reference it properly and explain my scoping issues?

      Thanks in advance,
      Robert
        • 1. Flash class scoping problems
          Mad_Rhino
          Hey, do you know if the movieclip is created? as from above you haven't sepecified a target to create the moveiclip in, your code :

          createEmptyMovieClip("mcEmptyTest", this.getNextHighestDepth());

          Therefore flash usually associates the target with "this" i.e. this.createEmptyMovieClip.

          If you want to reference it, try using "this" before the movieClip name e.g. this.myMovieClip....

          Hope this helps
          • 2. Re: Flash class scoping problems
            Level 7
            Hey, do you know if the movieclip is created? as from above you haven't
            sepecified a target to create the moveiclip in, your code :

            <b>createEmptyMovieClip("mcEmptyTest", this.getNextHighestDepth());</b>

            There is no target defined before the "createEmptyMovieClip" part, Although,
            it should still created it in the current class, but thats the only thing i can
            suggest at the moment. Also if you are referencing the created movieclip be
            sure to always put "this." infront of it, eg. this.myEmptyMovieClip .....

            Hope this helps