1 Reply Latest reply on Jan 23, 2007 3:01 PM by I tried

    Using ActionScript on a Custom Component

    mjpolizz
      I’ve been learning to write my own classes and in turn custom components. I started simple and developed a Preloader Component. The component works great, but I am now trying to access and alter the parameters of my preloader component via ActionScript. In writing this component, I extended MovieClip and not the UIComponent. Can anyone briefly explain as to how I might access my parameters and alter them?

      Any help is appreciated...
        • 1. Re: Using ActionScript on a Custom Component
          I tried Level 1
          First off, because you've inherited from the movieclip class, you'll be able to use any of the movieclip properties or methods, such as:

          mycustomclass._x or mycustomclass._y

          When writing the actionscript class for the movieclip that contains your movieclip, ensure that you import your custom class code and make a reference to it.

          import com.mycustomclass;

          class com.mycontainingclass extends movieclip {

          private var mycustomclassinstance:mycustomclass;

          private function onload(){
          //instantiate your object
          mycustomclassinstance = new mycustomclass();
          //change a parameter
          mycustomclassinstance._x = 12;
          mycustomclassinstance.somevariable = 15;
          }
          }

          Now, in your custom class, you will have built any parameters you want to access and or change, hopefully using getters and setters to preserve encapsulation.

          This is the best primer I can give you in the time I have. If you're not used to object-oriented development, you may want to pick up a book or two on the subject or look at some examples out there on the web. The good thing is that with flash, you really can see that everything is an object and visualize your object-oriented development easier than other languages.

          Good luck
          Robert