Flex XML Elements and Code

In a Flex application, you can declare elements, such as HTTPService elements, both in XML and in code.

I.e: ...

or in code: var hs: HTTPService = ...

My question is when should I prefer the alternative? What are the benefits of having stuff in XML or plain old vars in code?

+1


source to share


2 answers


MXML is great for doing declarative layouts, much easier to follow than doing everything programmatically in ActionScript. If you are using something like ServiceLocator to define HTTPService, RemoteObject, etc. In your application, then declaring them through MXML is also quick and easy. Basically, if you want to quickly and easily add anything to a displayList object, MXML is a great way to go.



+1


source


The elements are more succinct and more compact than AS3 code, of course it ends up being the same thing. You can, for example, declare HTTPService in "one line" mxml and set several of your properties. In your script, you will need to do this in many lines of initialization code. If you have a lot of globals, this can become unmanageable.



0


source







All Articles