jump to navigation

Howto: Organise custom components in Flex? August 9, 2007

Posted by Mayank in flex.
trackback

Most of the material on custom components in flex talks about their creation and their use within flex applications. As the number of components begin to grow one begins to feel the need for organising them in subfolders.

To use a custom component in a Flex application we usually add an attribute to the mx:Application tag:

<mx:Application
xmlns:local="*"
...
>

and then use the components as

<local:myComponent/>

I recently solved the mystery behind this attribute :). If you would like to organise the components into subfolders, then create a folder as desired and while setting the namespace attribute in the mx:Application tag set it like this:


<mx:Application
xmlns:myComponents1="subfolder1.*"
...
>

To access the components you would use

<myComponents1:yourComponents/>

You can create additional folders and include their namespaces too :).

<mx:Application
xmlns:myComponents2="subfolder2.*"
...
>

To take this a step further, you could nest your folders to mimick the way your organise your java packages:

Create sub1, and then sub2 under sub1

To use components under sub1 you could place a namespace declaration like:


<mx:Application
xmlns:s1="sub1.*"
...
>

and then to include sub2 components you would declare another namespace:


<mx:Application
xmlns:s2="sub1.sub2.*"
...
>

Hope that helps you in organising your custom flex components.

Happy Flex-ing! 🙂

Advertisements

Comments»

1. chowdary - May 28, 2009

i want adding custom components to action script.

suppose i created custom component name like modify.mxml.

I want add this component in action script.

Plz help me this. its very urgent.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: