Archive for December 14th, 2005

Flex 1.5 Create/Destory component with same filename but different directory

Three files in this example, CreateDestroyIssue.mxml, test/MainPage.mxml, and test1/MainPage.mxml. The issue is that test/MainPage.mxml is a VBox and test1/MainPage.mxml is a Panel. When test1/MainPage.mxml is created some of the styles are not correct, for example the round edges of the panel header. This only happens on files with the same name, even though they are in different directories.

Example code:

CreateDestroyIssue.mxml

XML:
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" xmlns="*"
  3.     width="100%" height="100%" initialize="createUI( 'pageVBox' )">
  4.    
  5.     <mx:Script>
  6.         <![CDATA[
  7.             import mx.core.UIObject;
  8.             public var pageItem : Object;
  9.            
  10.             function createUI( pageUI:String ):Void {
  11.                 if( pageUI == "pageVBox" )
  12.                     pageItem = vsPageHolder.createChild( test.MainPage, undefined );           
  13.                 if( pageUI == "pagePanel" )
  14.                     pageItem = vsPageHolder.createChild( test1.MainPage, undefined );         
  15.             }
  16.  
  17.             public function destroyUI():Void {
  18.                 vsPageHolder.destroyChild( UIObject( pageItem ) );
  19.             }         
  20.         ]]>
  21.     </mx:Script>
  22.     <mx:HBox width="100%" textAlign="center" backgroundColor="#DDDDDD">
  23.         <mx:Text text="Select a Combo Box item: " width="200" textAlign="right"/>
  24.         <mx:ComboBox id="cmbPages" change="destroyUI();createUI( cmbPages.selectedItem.data );">
  25.             <mx:dataProvider>
  26.                 <mx:Array>
  27.                     <mx:Object data="pageVBox" label="Page with VBox"/>
  28.                     <mx:Object data="pagePanel" label="Page with Panel"/>
  29.                 </mx:Array>
  30.             </mx:dataProvider>
  31.         </mx:ComboBox>
  32.     </mx:HBox>
  33.     <mx:ViewStack id="vsPageHolder" width="100%" height="100%">
  34.     </mx:ViewStack>
  35. </mx:Application>

test/MainPage.mxml

XML:
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:VBox xmlns:mx="http://www.macromedia.com/2003/mxml"
  3.     width="100%" height="200"
  4.     backgroundColor="0x99BB66">
  5.     <mx:Text text="VBox Page, Hello World!"/>
  6. </mx:VBox>

test1/MainPage.mxml

XML:
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Panel xmlns:mx="http://www.macromedia.com/2003/mxml"
  3.     width="50%" height="300"
  4.     backgroundColor="0x6699BB">
  5.     <mx:Text text="Panel Page, Hello World!"/>
  6. </mx:Panel>

Fix 2006.01.18:
When the file names are the same Flex has this problem. If the file names are different it works. It has something to do with Flex using filenames as an internal identifier during the compiling process/runtime process.

Add comment December 14th, 2005



Disclaimer: I work as a Flash/Flex Developer for Adobe Systems Incorporated. The opinions expressed here represent my own and not those of my employer.

My Amazon.com Wish List

Calendar

December 2005
S M T W T F S
« Aug   Feb »
 123
45678910
11121314151617
18192021222324
25262728293031

Posts by Month

Posts by Category


Flex.org - The Directory for Flex