Have you tried the ASWing GUI Builder? If you use it, then the examples you provided below are not required at all. The code is generated for you.

Elia

----- Original Message ----- From: "Ian Thomas" <[EMAIL PROTECTED]>
To: "Flash Coders List" <flashcoders@chattyfig.figleaf.com>
Sent: Thursday, November 20, 2008 9:53 AM
Subject: Re: [Flashcoders] Flex vs. Flash


On Thu, Nov 20, 2008 at 8:30 AM, Elia Morling <[EMAIL PROTECTED]> wrote:

The language itself lends itself to spaghetti coding, because MXML can
easily turn into nesting hell. , unless the coders know what they are doing.
The benefits of Flex databinding and UI are bogus, if you are an OOP
programmer reusability exists with any OOP language.

Bogus?

Not at all. The benefits are in speed of development and clarity.

It is perfectly possible to replicate databinding in AS3 (after all,
the underlying implementation _is_ AS3).

But to do so will require considerably more code, and is harder to read.

Similarly for the UI - yes, you can replicate everything in MXML's
layout in AS3, but it also requires more code and is harder to read.

Consider this simple layout example in MXML:

<mx:VBox width="100%" horizontalAlign="center">
  <mx:Label text="Testing"/>
  <mx:Button label="Cancel" click="dispatchEvent(new
UserEvent(UserEvent.CANCEL,true))"/>
</mx:VBox>

And in AS3:

var vbox:VBox=new VBox();
vbox.percentWidth=100;
vbox.setStyle("horizontalAlign","center");

var label:Label=new Label();
label.text="Testing";
vbox.addChild(label);

var button:Button=new Button();
button.label="Cancel";
button.addEventListener(MouseEvent.CLICK,onCancelClicked,false,0,true);
vbox.addChild(button);

addChild(vbox);

private function onCancelClicked(ev:MouseEvent):void
{
 dispatchEvent(new UserEvent(UserEvent.CANCEL,true));
}

In what way is the AS3 clearer? In what way is it easier to maintain?
In what way is it easier to see how the objects are laid out on the
screen just by looking at the code? In what way is it _faster to
develop_?

In what way is the MXML more spaghetti-like?

I agree that - as with any layout language - you can get tangled up by
burying the implementation inside the layout. That's the same sort of
issue that exists in other languages - for example, PHP. But that's
simply about learning how to use it correctly.

I think it's foolish to entirely write off a useful syntax/language
based on examples written by people who don't understand how to use it
properly.

But then, I find MXML a useful tool for layout. It's your loss if you
don't use it.

Ian
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to