How to inherit the properties of the base class?

Hi all

I have a doubt. Can someone remove this doubt?

Steps to follow:

(1) I created a movieClip & named MyComp

(2) I export this movieclip in actionscript. The class name for this movieclip is MyComp.

(3) then dynamically I created 5 instance of this class and added to the stage.

(4) now I need to change the width of MyComp. He should think about a previous 5 instance too.

I tried like,

I created MyComp.as file in the same place. I tried to inherited DisplayObject properties Width.

Example:

At the time of creation, I have a movieclip in my library that contains a rectangle shape... IM adding 5 This movieclip instance in the stadium.

After that, I get in a movieclip and im increasing the width of this movieclip by increasing the width of the shape. He'll get reflected in all cases...

I need this thing in actionscript... is it possible?

Thank you...

You can't do what you're trying to make the way in which you are trying to do.

I've included a code here (pure AS3 without chronology or library) that you may be able to adapt to your needs

Basically, I created a static property (_rectWidth which controls the width of the rectangles) on the MovieClip class that contains the rectangle and a render() function that redraws the rectangle to the right width. Note You must call render() after setting a new width to see the rectangle drawn to the new width.

Then in the main class, I create 5 rectangles to the posts and random colors.

The main class also listens to the "arrow up" and "arrow down" to change the size of the rectangle. Note: I change the size of the rectangle and then worked for all classes of hand children (all of which are the RectMC) and call render();

package
{
          import flash.display.Sprite;
          import flash.events.Event;
          import flash.events.KeyboardEvent;

          public class Main extends Sprite
          {

                    public function Main():void
                    {
                              if (stage) init();
                              else addEventListener(Event.ADDED_TO_STAGE, init);
                    }

                    private function init(e:Event = null):void
                    {
                              removeEventListener(Event.ADDED_TO_STAGE, init);
                              // entry point

                              for (var i:int = 0; i < 5; i++)
                              {
                                        var col:uint = Math.floor(Math.random() * 0xffffff);
                                        var rectX:int = Math.floor(Math.random() * stage.stageWidth);
                                        var rectY:int = Math.floor(Math.random() * stage.stageHeight);
                                        var rectMC:RectMC = new RectMC(col);
                                        rectMC.x = rectX;
                                        rectMC.y = rectY;
                                        addChild(rectMC);
                              }

                              stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
                    }

                    private function onKeyDown(e:KeyboardEvent):void
                    {
                              switch (e.keyCode)
                              {
                                        case 38:
                                                  RectMC.rectWidth += 20;
                                                  break;

                                        case 40:
                                                  RectMC.rectWidth -= 20;
                                                  break;
                              }

                              for (var i:int = 0; i < numChildren; i++)
                              {
                                        var rectMC:RectMC = getChildAt(i) as RectMC;
                                        rectMC.render();
                              }
                    }

          }

}
package
{
          import flash.display.MovieClip;
          import flash.events.Event;

          /**
           * ...
           * @author steven O'Boyle
           */
          public class RectMC extends MovieClip
          {
                    protected static var _rectWidth:int = 100;
                    protected static var _rectHeight:int = 50;

                    protected var _rectColour:uint;

                    public function RectMC(col:uint)
                    {
                              _rectColour = col;
                              render();
                    }

                    public function render():void
                    {
                              graphics.clear();

                              graphics.beginFill(_rectColour);
                              graphics.drawRect(0, 0, _rectWidth, _rectHeight);
                              graphics.endFill();
                    }

                    public static function set rectWidth(value:int):void
                    {
                              _rectWidth = value;
                    }

                    public static function get rectWidth():int
                    {
                              return _rectWidth;
                    }
          }

}

Tags: Adobe Animate

Similar Questions

  • How to replace the base class events

    I faced a problam event. That I called a class AA scene. Class AA is extends from class BB. Class BB extends the CC class. CC class extends MovieClip.  In the CC class, I gave CLICK event tracing ("it's class CC '). I am also given to AA class CLICK event ("it's class AA"). When I click on the AA in the updated Panel "it's class CC", "this is class AA") I want to stop class mouseEvents CC.

    Default event bubble... Looks like you want to watch the stopImmediatePropagation event class method.

  • Substitution of the class, how to create the child class and then the base class

    I started to write a program for a DMM smart, that the problem is all versions of DMM greet the change company communication.

    My idea is to write a child class for each version, DMM and each Subvi child will replace the Subvi base class.

    My problem is, I first want to create a child class and after I see everything is working, start creating the base class. in this way, I'll see if think the right way.

    My question is

    How can I create a child class and then create the base class and configure the Subvi class of the child to be the substitution of the base class?

    I tried searching in the property of the class, but I don't see anything.

    Thank you

    This can be done and I did on occasion.

    You create the base class with the methods of dynamic distribution, you need (Connector components must be identical to those of the class of the child).

    Set then the legacy of the class inherits this base class.  If your method is defined as a dynamic distribution method in the parent, you will probably now have some errors (unless your method of child was already DD, in which case you might be OK already).

    To change the inheritance of a class, right-click on the properties of the class in your project, and then select Properties.  According to me, the tree of estate is at the lower end of the property.  Click on the 'legacy of change' (or something similar) to choose the class from which you now want to inherit.

  • import a class: how many ways are there? CFC, import, extend the base class

    How many ways is there to import a class and am I confused

    1 screen/public class extends MovieClip

    This inherits all the properties and methods of the MovieClip class so WHY again do we use: import flash.display.MovieClip;

    Import something else or just made the job twice

    2 import flash.display.MovieClip - so no need to extend (repeat me once again - see 1)

    3 CFCS: connect to a CFC

    4. stir in a SWF with a meta tag

    5. in the properties panel menu - add a class as a base class

    OMG - a bit confusing

    You can only "extend" another class if the compiler knows where he is.

    The import statement is only by the compiler to find the class on your hard drive.

    It is not "import" of the entire class in the sense that you import a BMP in Photoshop.

  • How Illustrator choose the base color when creating a new group of colors?

    I'm just curious on all selection and the creation of the Group color process.

    base_color.png

    On the above document, I have 5 rectangles of the same size, filled with 5 different colours. If I type Cmd + A to select all, then go into the swatches Panel and click on "New color group", I got the color group marked as G1 in the image above.

    If I want the colors appear in the same order (G2 in the picture), making the left most red color as the base color, I must first create an empty group, and then add each sequence color myself.

    So I wonder how Illustrator decides what color take it as the base color?

    I think that it is the angle of the color first, and then S B or vice versa.

    Stacking order is not serious.

    But why is this important to know?

  • How to get the Base name of the executable process

    Hi all
    I have a problem for the creation of SQL AnyWhere Plugin (Database Plugin). In this regard, ServerDetector class long pids [] = getPids ("State.Name.eq =?"). Instead of question mark that I place. And how to get the name of this executable process.

    Thanks and greetings
    Florent K Reddy

    Take a look at the doc following if you have not already:

    http://support.Hyperic.com/Confluence/display/Sigar/PTQL

    State.Name is the name of the base of the executable of the process, such as "dbsrv9.

    On 16 May 2007, at 23:24, fredo Reddy wrote:

    Hi all
    I have a problem for the creation of SQL AnyWhere Plugin (Database Plugin). In this regard, ServerDetector class long pids [] = getPids ("State.Name.eq =?"). Instead of question mark that I place. And how to get the name of this executable process.

    Thank you & best regards
    Florent K Reddy

  • update so on different WiFi router and now my Airport base station has a yellow light flashing - how to reset the base station

    Light Flsahing Amber on my Airport base station

    A persistent, flashing amber light indicates that one of the conditions is possible more may require your attention:

    • The base station has not yet been configured, because it's new or reset switch has been set.
    • You have chosen a security configuration that is not recommended.
    • Among several other conditions, such as a disconnected Ethernet cable or invalid IP address has been detected.

    (Ref: AirPort base stations: status of base station on airport (LED))

    To find out why your base station status led is orange flashing:

    • Open AirPort Utility
    • Click on the AirPort base station
    • Look for the Status parameter in the small window that appears
    • Click on the little orange dot here and another window will open to explain what might be the 'question '.
  • How to add the base permission to business?

    Hello

    I'm getting authorization of business failure.

    How to pass the credentials to the Business Service?


    Thank you

    When you create a business service, on the transportation Configuration page, select HTTP. When you are prompted, select required basic authentication.

    Create a service account to provide the username and password that requires the service of business.
    You can add a user name and password directly to the service account, or configure the service account to pass the credentials that she has received the request of his client, or you can map a client username of a user Oracle Service Bus. If you have configured the proxy service so that Oracle Service Bus does not authenticate clients, create a service account that requires credentials.

    Create a proxy service or to change an existing proxy service so that it specifies the service account.

    Please see the article "49.2.2 outbound HTTP security of configuration: main steps ' to.

    http://download.Oracle.com/docs/CD/E17904_01/doc.1111/e15866/transport_level.htm#i1079076

    Kind regards.
    Anuj

  • How to fix the filter class corrupted

    CD/dvd drive does not run set and discovered that the class filter drivers are damaged or missing how can I solve this

    Hello JanettLewis,

    I suggest that you try to manually remove the filters on the computer.

    If this does not resolve the problem, you can try to do these steps manually.

    a. click on start this image and then click on all programs.

    b. click Accessories and then click Run.

    c. type regedit, and then click OK, if you are prompted for an administrator password or a confirmation, type the password or click on allow.

    In the navigation pane, find and then click the following registry subkey:

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\ {4D36E965-E325-11CE-BFC1-08002BE10318}

    d. in the right pane, click UpperFilters.

    Note: You may also see an UpperFilters.bak registry entry. You don't have to delete this entry. Click UpperFilters. If you do not see the UpperFilters registry entry, you may still have to delete the LowerFilters registry entry. To do this, go to step f.

    d. in the Edit menu, click on delete.

    e. When you are prompted to confirm the deletion, click Yes.

    f. in the right pane, click LowerFilters.

    Note: If you do not see the LowerFilters registry entry, unfortunately this content cannot help you further. Go to the section "Next steps" to learn how you can find more solutions or more help on the Microsoft Web site.

    g. in the Edit menu, click on delete.

    h. When you are prompted to confirm the deletion, click Yes.

    i. exit the registry editor.

    j. restart the computer.

    Important: This section, method, or task contains steps that tell you how to modify the registry. However, serious problems can occur if you modify the registry incorrectly. Therefore, make sure that you proceed with caution. For added protection, back up the registry before you edit it. Then you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click on the number below to view the article in the Microsoft Knowledge Base: 322756 (http://support.microsoft.com/kb/322756/) how to back up and restore the registry in Windows.

    Thank you
    Irfan H, Engineer Support Microsoft Answers.

  • The extension of class + access to the children of the base class

    Hello.

    I am trying to create a kind of panels of information and tool for a project, similar to those on the Adobe Suite products. They will have a tab that you can double-click to open or close and title of the Panel will be on this tab.

    So I created a video called main and in it, I placed a textfield called txtTitle and a rectangular MovieClip called mTab. I duplicated the main twice on the stage, called PanelA and PanelB and add individual, but kept the txtTitle and mTab.  I edited the linking options of PanelA and PanelB to link to specific custom classes.

    First, I created a base for the main class.

    package com.panels {}

    import flash.display.MovieClip;

    import flash.events.MouseEvent;

    Import fl.text.TLFTextField;

    //

    SerializableAttribute public class MyPanel extends MovieClip {}

    //

    public void MyPanel (): void {}

    txtTitle.mouseEnabled = false;

    mTab.doubleClickEnabled = true;

    mTab.addEventListener (MouseEvent.DOUBLE_CLICK, clickedPanel);

    }

    }

    }

    And then the classes of Group A and B, which extend from the main.

    package com.panels {}

    import com.panels.MyPanel;

    //

    SerializableAttribute public class PanelA {MyPanel extends

    //

    public void PanelA (): void {}

    }

    }

    }

    When I test the movie, I get an error stating that 'Access of undefined property txtTitle' (and even to mTab). If I have just a PanelA link to the main class it all work - I got it to open, close, dragged with the mouse... I can access mTab, txtTitle and something else is already on the scene. But if I extend the class, I can't. Anyone know why this happens and how best to make it work? Thank you.

    use:

    SerializableAttribute public class MyPanel extends MovieClip {} Dynamics

    //

    public void MyPanel (): void {}

    this.txtTitle.mouseEnabled = false;

    this. mTab.doubleClickEnabled = true;

    ce. mTab.addEventListener (MouseEvent.DOUBLE_CLICK, clickedPanel);

    }

    }

    }

  • How to customize the PortalApplicationBundle.class inside the Library portal framwork webcenter

    Hello

    I am developing a multilingual portal using application portal webcenter framework and I use Oracle Jdeveloper 11.1.9 as my IDE, I managed to create the Multilingual Portal, including the Persian language Persian language works very well for the site, but in the administration of the portal page it works for Oracle supported languages , I tried to create a new PortalApplicationBundle.class (such as PortalApplicationBundle_fa) located in the library of Portal-> oracle.webcenter.portalwebapp.view.resource Webcenter Framework but Oracle built in libraries are read only so my question is how I translate the administration page of the Persian-language portal?

    Hello.

    First to comment on this portal framework are developments discouraged as it's going to be supported in the future version 12 c.

    If you step to change your approach to go with the portal site generator.

    Oracle Portal framework approach Note: https://docs.oracle.com/middleware/11119/wcp/plan/pywcp_tasks.htm#PYWCP167

    As to your question.

    Create your own PortalApplicationBundle_fa class implemented by using the same name of packaging as the other PortalApplicationBundle inside your Portal Application. It will deploy your class in the classpath and the Bundle resource class loader is smart enogh to load your translations.

    If the load does not, there is much more stuff to achieve this forzing classes PortalApplicationBundle your portal instead of the Shared-lib application first loads.

    First test of my comment and let me know.

    It will be useful.
    Kind regards.

  • How to get the controller class of the a fxml file open in a tab?

    Hello.
    First of all, sorry for my bad inglish, that is not my language.

    Introduction:
    I work in the skeleton of an enterprisse application in javafx. Generally (in the past), I used swing with InternalFrames MDI form. Search in the web site on how can he do this, I found that the concept of the MDI form is obsolete, is recommended to use a tabpanel structure. I started to develop the application with this concept, but I have a question.

    Scenario:
    I have a main window with:
    -Menu: To access the different options
    -Toolbar: To run the day-to-day operations (open, save, edit, delete and print)
    -TabPanel: To display the dashboard and fxml files opened from the menu.
    -Status bar: To display information.

    [http://www.blueboxmicrosystems.com/fxml.png |] See the image]

    The problem:
    I don't know how to access the methods of the controller of the fxml file on the active tab.

    Note: I have an interface with operations (open, save, edit, delete and print) and the tools of the interface controllers.

    The question:
    How can I me the controller class of the file fxml in the active tab in order to call methods?

    Kind regards

    Published by: user10311523 on 31-mar-2013 20:36

    Published by: m_ilio on 01-Apr-2013 05:40

    Instead of

     Parent root =  FXMLLoader.load(getClass().getResource(fxmlFile));
    

    do

    FXMLLoader loader = new FXMLLoader(getClass().getResource(fxmlFile));
    Parent root = (Parent) loader.load();
    MyControllerType controller = loader.getController();
    // now you'll need to keep track of the controller somewhere, maybe a Map
    

    where of course you replace MyControllerType with classname of your controller.

  • How to reuse the java class in several applications

    Hi friendz,.
    Please help me...
    I use JDEV 11.1.2.2.0 version.

    My problem is that I want to reuse the same java class in many applications.
    How can I do that...
    I hope your help...
    -Rude-

    Compile the Java class.
    Package Java class in a POT as suggested in the other post.
    Include the JAR in the classpath.
    Import the class in the other class of the application.

  • definition of the base class _ not found

    Hello!

    While exploring Flex 3 (really good btw) and build my first app, I tried the following:

    SerializableAttribute public class X extends EventDispatcher {}

    It gives me a compilation error #1017: the definition of the EventDispatcher base class was not found.

    To compile I am just use a file .bat, such as those used in the samples. Everything compiles normally without extending an existing class (in this case flash.events.EventDispatcher).
    Try to change the compiler options with
    -library-path += c:\flex\framework\libs
    has resulted in the same error here (and I guess that's already a default setting).

    Any help would be greatly appreciated!

    Fre

    It worked :-). Thank you very much, Deepa!

    So, apparently, you can make import declarations in the declaration of class (or anywhere in the code), but always before you use the imported class. I got confused, as in java, all import instructions are in the same place and import flash.net worked under my class declaration.

  • How to access the inner class fields in refleciton?

    I have:
    class Outer {
        class Inner {
            int field;
        }
        Inner inner;
    }
    I use reflection to get the Outer.field field and recognize that it is a reference to the inner class. What should I do to get the inner.field (or something that looks remotely like this at Inner.field)?

    We would like to

    Well, precedent is too messy for me even follow my example. I've simplified it, and I think I found where my error was. I suspect that you were doing a similar error:

    package scratch;
    
    import java.lang.reflect.Field;
    
    public class Scratch {
    
      public static void main(String[] args) throws Exception {
        new Scratch().go();
      }
    
      void go() {
        Outer1 o1;
    
        Field[] fields = Outer1.class.getDeclaredFields ();
    
        for (Field field : fields) {
    
          final String fn = field.getName ();
          final Class ft = field.getType ();
          final Class fc = field.getClass ();
          final Class fdc = field.getDeclaringClass ();
    
          System.out.println ();
    
          System.out.println ("Outer1 field : " + fn);
    
          System.out.println ();
    
          System.out.println ("field's class (field.getType()) : " + ft.getName());
          System.out.println ("field.getType().isMemberClass() (" + ft.getName() +" isMemberClass()) : " + ft.isMemberClass ());
          System.out.println ("field.getType(). getDeclaringClass() (" + ft.getName() + "'s declaring class) : " + fdc);
    
          System.out.println ();
    
          System.out.println ("field.getClass()) : " + fc.getName());
          System.out.println ("field.getClass().isMemberClass() (" + fc.getName() +" isMemberClass()) : " + fc.isMemberClass ());
          System.out.println ("field.getClass().getDeclaringClass() (" + fc.getName() + "'s declaring class) : " + fc.getDeclaringClass ());
    
          System.out.println ();
    
          System.out.println ("Note the difference between Field.getClass() (" + field.getClass () + ") and Field.getType() (" + field.getType() + ")");
    
          System.out.println ();
        }
      }
    }
    
    class Outer1 {
      class Inner1 {
      }
    
      Inner1 i1;
    }
    
    Outer1 field : i1
    
    field's class (field.getType()) : scratch.Outer1$Inner1
    field.getType().isMemberClass() (scratch.Outer1$Inner1 isMemberClass()) : true
    field.getType(). getDeclaringClass() (scratch.Outer1$Inner1's declaring class) : class scratch.Outer1
    
    field.getClass()) : java.lang.reflect.Field
    field.getClass().isMemberClass() (java.lang.reflect.Field isMemberClass()) : false
    field.getClass().getDeclaringClass() (java.lang.reflect.Field's declaring class) : null
    
    Note the difference between Field.getClass() (class java.lang.reflect.Field) and Field.getType() (class scratch.Outer1$Inner1)
    

    field.getClass () does NOT get the class of the field. It get the class of the field object that points to the field reference variable, which is always java.lang.reflect.Field. To get the class of the field, use field.getType ().

    Do you see the difference?

    Edited by: jverd February 5, 2011 17:18

Maybe you are looking for