calling different mxml components from main.mxml components

10 views
Skip to first unread message

Raj

unread,
Apr 13, 2010, 6:39:20 AM4/13/10
to Flex India Community
Hi,
I have Main.mxml component and 5 mxml file. I want to access mxml
components features from main.mxml.
plz help me.

Fehmina Kanuga

unread,
Apr 13, 2010, 8:43:32 AM4/13/10
to flex_...@googlegroups.com
Hi u can achieve this using viewstack and tab navigator


 

--
You received this message because you are subscribed to the Google Groups "Flex India Community" group.
To post to this group, send email to flex_...@googlegroups.com.
To unsubscribe from this group, send email to flex_india+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/flex_india?hl=en.


swapna y

unread,
Apr 13, 2010, 10:09:23 AM4/13/10
to flex_...@googlegroups.com
i have same probem...
but if i write this viewstacks in mxml component then how to use these components in main mxml file. do we need to compile before use them??

Utkarsh kaushal

unread,
Apr 13, 2010, 11:12:18 AM4/13/10
to flex_...@googlegroups.com
Step 1: Add name space in mx:Application tag for example
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:mycomponent="com.yourorg.yourdept.applicationname.subfolderifany.components.*"
backgroundColor="#AAAAAA" layout="vertical" top="0" left="0" bottom="0" right="0" paddingTop="0" paddingLeft="0" paddingBottom="0" paddingRight="0" horizontalGap="0" verticalGap="0" initialize="init()" applicationComplete="onApplicationComplete()" >
 
Step:2 Place your components (.mxmls) under path specified for example
com.yourorg.yourdept.applicationname.subfolderifany.components
 
Step 3: use the name space to invoke your components. For example:
mycomponent:Header id="yourId" visible="false" ... and assign the values to attributes/events etc myevent="onClickEventHandler(event)" />
 
Here Header.mxml is defined under folder com.yourorg.yourdept.applicationname.subfolderifany.components and has an event named myevent.
 
Hope this will help.
 
Thanks,
Kaushal.

Kiran Kumar Reddy

unread,
Apr 13, 2010, 11:17:18 AM4/13/10
to flex_...@googlegroups.com
Dear Swapna/Raj,

I have one more solution for you requirement, might not be the best but works for me.
If you are displaying other mxml components in main mxml .... create the other mxml components as MXML Modules.
and on click event callback in your main mxml of some button or link load the MXML module as bellow

var currentModule:IModuleInfo = ModuleManager.getModule("OtherMxml1.swf");
currentModule.addEventListener(ModuleEvent.READY, OtherMxml1EventHandlers); //you can have event listeners for each otherMxml component.

And in OtherMxmlEventHandlers function
============================================
private function OtherMxml1EventHandler (e:ModuleEvent):void {
    var currentScreenForm:Object = currentModule.factory.create() as OtherMxml1;
    mainPanel.removeAllChildren(); // Main Panel is Panel in the Maim mxml file.
    mainPanel.addChild(currentScreenForm as DisplayObject);
}

If you are using Flex Builder then creating mxml modules is very easy and will be loaded only when required. You can also unload the module to free up the memory.The compilation of modules would be taken care by FB and can be optimized to Main MXML.

I am sorry if I am not very clear. I posted some snippet of code from my project. Hope this helps you a bit.

Akshar Kaul

unread,
Apr 13, 2010, 12:19:43 PM4/13/10
to flex_...@googlegroups.com
view stack method is more easy to use... i would recommend you to use view stack....
which ide are you using to code......
flex builder will automatically add the namespace for you.........

Akshar Kaul

Alekhya Krishna

unread,
Apr 20, 2010, 9:49:25 AM4/20/10
to flex_...@googlegroups.com
Hi,
 
View stack is the best.

Reply all
Reply to author
Forward
0 new messages