1 Reply Latest reply on Aug 19, 2011 12:13 PM by noSleepDemon

    Extending a component that uses mx:script


      I have a Flex project whose main mxml file includes an mx:script block, which points to an external file. Although a good deal of the functionality of the application is abstracted into classes, a fair bit of the implementation such as UI element animation / interaction is inside the file pointed to by mx:script.


      I now have to make an extension to the application, but don't want to copy-paste the script file. However as it is not a class, I can't just extend it, and I can't include it into another file and override its methods either. I could wrap the whole thing inside a class, but then I'll be forced to refer to stage components using this["componentName"] instead of just this.componentName, I also don't get code completion using this, and there are hundreds of places in the file I'd need to correct.


      Has anyone run into the issue of trying to extend an mxml component like this? If so, how did you do it?

        • 1. Re: Extending a component that uses mx:script
          noSleepDemon Level 1

          Ok so I read up on MXML documentation, and how that translates to a compiled .swf file, and found that functions and variables declared in the mx:script block are added to the application's class upon compile. With this, I reasoned that if I declared my old application as a custom class, and then inherited from that class with the new application, the new app would inherit everything from the old one... Didn't work. However, if instead of declaring a custom class for the old application, I instead declare a custom class for my new app that extends the old apps application NAME, stuff compiles. I'm getting some null pointer errors though, so not sure if something went tits up somewhere, will investigate.