1 Reply Latest reply on Feb 16, 2009 6:14 PM by Newsgroup_User

    Add custom attribute to component in ActionScript

    mavdzee Level 1

      I have a component in ActionScript and want to add a custom attribute for it that I can use when I use the ActionScript component in a MXML file like this:

      <custom:MyComponent myCustomAttribute="value" />

      A simple public setter for MyComponent.myCustomAttribute in the ActionScript class does not work like it does for components written in MXML.

      Thank you,
        • 1. Re: Add custom attribute to component in ActionScript
          Level 7
          It should work just fine. First of all, are you extending UIComponent,
          or some subclass thereof? If not, are you implementing IMXMLObject?

          You should be able to just have a public property:

          class MyComponent extends UIComponent {
          public var myCustomAttribute:SomeClass;

          Or a public setter:

          class MyComponent extends UIComponent {
          private var _myCustomAttribute:SomeClass;
          public function set myCustomAttribute(value:SomeClass):void {
          _myCustomAttribute = value;

          If you're doing these things, then I have no idea. I'd have to see the code.