Attaching asset to a class, and maybe class to an asset? (Flex AS3)

Hey everybody!

I’ve posted this question in other flex and actionscript-centered forums, but got no answers so I thought it couldn’t hurt if I asked it here. The post is long because I’m trying to express the problem with as much detail as possible, so bear with me :slight_smile:

I’m somewhat new to Flex, coming from Flash CS3, so I’m most familiar with the Library paradigm and trying to port that knowledge to Flex. Here’s a specific problem that I’m having…

I know you can attach embedded asset symbols to a full fledged class, similar to defining **Linkage **in Flash CS3. I’ll be using a typical login dialog box to demonstrate this problem. Imagine that the Artist gave me an assets.swf that contained a LoginModule movieclip with a textfield for **username **input, a textfield for **password **input, and a **button **movieclip for clicking. I attach the LoginModule asset like so:

package ui.modules{
    import flash.display.Sprite;

    [Embed(source="/../assets.swf#LoginModule")]
    public class LoginModule extends Sprite{

        public var usernameTxtbox:TextField;
        public var passwordTxtbox:TextField;
        public var loginBtn:MovieClip;

        public function LoginModule(){}
    }
}

Works great like this! However… I would like to have that particular login button behave like yet another class I have written, called CustomButton. All CustomButton is is a MovieClip with 2 frames, stopped at the first frame, but will move to the second upon mouseover:

package ui.controls{
    import flash.display.MovieClip;
    import flash.events.MouseEvent;
    
    public class CustomButton extends MovieClip{
        public function CustomButton(){
            gotoAndStop(1);
            addEventListener(MouseEvent.MOUSE_OVER,onMouseOver);
            addEventListener(MouseEvent.MOUSE_OUT,onMouseOut);
        }
        private function onMouseOver(e:MouseEvent):void{
            gotoAndStop(2);
        }
        private function onMouseOut(e:MouseEvent):void{
            gotoAndStop(1);
        }
    }
}

This is where I’m stumped.

If the Artist gave me the asset.swf with that LoginModule clip with a button already attached, trying to force loginBtn in LoginModule to be a CustomButton using loginBtn:CustomButton would throw an error. In Flash, all I had to do was set the Button’s Base class to ui.controls.CustomButton, but at this time it seems my only option is to ask the Artist not to include the button in the LoginModule, and allow me to include the loginBtn manually as a CustomButton. This would greatly hamper the Artist’s duties, so I’d like to solicit some advice from the gurus out there: How do you handle situations like these?

Thanks for any and all help!
Jay