6/2/2010 11:06:10 PM
Title:
Flex Common telmplate for all Files
Hi all,
I am new to flex and learning the flex4 (flash builder4) .
Can anybody please help me to know about the layouts in Flex.
I am working on a site and it is having menubar at the top , now on
every page (mxml application) I have to copy that menubar and related
Action script.
Is there any way in flex so that I can make a template at once and
resuse for my all pages instaed of copying the code every time?
Is there any layout kind of thing in Flex?
Tyson
Points: 680
Posts:0
6/2/2010 11:43:51 PM
sure, flex support states which can be used to develop websites. You have to place your menubar on the base state and it will appear on all the child States( pages). Check this tutorial
http://askmeflash.com/tutorial/0/how-to-create-website-in-flex-tutorial-my-first-flex-website
6/3/2010 12:00:46 AM
Hey Tyson,
I really appreciate this answer and also thanks for quick resonse.
I have gone through this tutorial and it is really useful for me.
6/3/2010 2:37:57 AM
Hey Tyson,
I have gone through this tutorial but i found one thing difficult about it is maintenance and flexibility.
Suppose In my menu item , I included one more menu at the end of the completion of my site.
then i need to add this manually to all my other states. Is there any way that all code would be automatically change and reflect the base states content.
6/3/2010 3:52:44 AM
you need to select the base state first then change the content. Then the content is added to all the states. this is a common mistake everybody makes.before any modification you should make sure the required state is selected. There is no such problem in maintenance
6/3/2010 4:45:09 AM
boy there is no such problem in using states , you can add content to your base state anytime and it will be updated in all the states. Make sure you are editing the base state only. no need to add common content to all the states . If you have added by mistake then select each state and remove the duplicate content and then add by selecting the base state. Get back to me if you still have problem :)
6/3/2010 4:59:45 AM
Hi All,
Thanks for your response.
What i tried is
1) Created base state
2) created child state ( while creation this i selected option, copy from base state)
Is this correct way to add child state?
3) Edited base state (added new button and action script for this ) but this is not reflected in child state now.
Am i doing somwthing wrong..?
6/3/2010 7:13:49 AM
To add a new state , you need to select the base state in the States Window then right click and select new . select "Based on base state" and enter name. The state created is based on the base state hence its like its child.
To edit the base state , you need to click on base state by clicking its node on the states window now you can add anything in the design view. Do not right click to edit, just select it like this in this image and start the changes on the design view.
http://askmeflash.com/timg/flexweb4.png
6/3/2010 11:32:46 PM
Ok thanks
One more thing i would like to ask.
Is it good way to use states for complex sites as there would be lots of pages (states) in my site and complex logic as well.
6/4/2010 5:47:07 AM
states are actually provided for easy designing and managing of websites in flex. Its certainly good for managing websites that are complex and with many number of pages. You can simply see, manage ,design and edit your website from the states tree menu. So when there are many pages you can easily navigate through tree structure of states. If your site is big and heavy in graphics, you can load the graphics from outside rather than embedding them . for more information on optimizing the swf you can check the following links
http://askmeflash.com/article/14/steps-to-optimise-swf-file-size-reduce-swf-size-how-to
http://askmeflash.com/article/9/optimize-flex-swf-filesize-performance-loading