[Flex/AS3] Code best practice

Hi all,

I have coded AS2 applications with FMX2004 earlier with Zinc and now wanted to try my hand at the shiny new Flex 2.0.1 and AS3 combination.

I am really not very confident in the approach I am using (or have seen others) to interfacing the view (mxml) with the model (AS3). I recently looked at ReviewTube by Joe Berkovitz and kinda confused by his approach.

In short for every component in his view mxml he would have a local <mx:Script> that would point to a singleton service instance that would do the actual work.

<mx:Button label="Register" click="register()"/>
    <mx:Script>
        <![CDATA[
            import com.joeberkovitz.reviewtube.services.Components;

            private function register():void
            {
                Components.instance.controller.register(usernameInput.text, passwordInput.text, emailInput.text,
                                                        descriptionInput.text);
            }

I was more used to having an AS class extend MovieClip or other components and all controller actions happened in that AS which is much cleaner.

Here if the controller changes all mxml files also need to change. Is there any way that an MXML component can be directly linked to AS? More like:

<mx:Button id="linkedBtn" click="com.controller.ClickHandler.linkClicked()"/>

Would the linkClicked need to be a static method? Thats ok but while compiling the com.controller… gives me a compilation error.

Please advice.

Thanks,
Cruiser