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 version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" xmlns="*"
width="100%" height="100%" initialize="createUI( 'pageVBox' )">
<mx:Script>
<![CDATA[
import mx.core.UIObject;
public var pageItem : Object;
function createUI( pageUI:String ):Void {
if( pageUI == "pageVBox" )
pageItem = vsPageHolder.createChild( test.MainPage, undefined );
if( pageUI == "pagePanel" )
pageItem = vsPageHolder.createChild( test1.MainPage, undefined );
}
public function destroyUI():Void {
vsPageHolder.destroyChild( UIObject( pageItem ) );
}
]]>
</mx:Script>
<mx:HBox width="100%" textAlign="center" backgroundColor="#DDDDDD">
<mx:Text text="Select a Combo Box item: " width="200" textAlign="right"/>
<mx:ComboBox id="cmbPages" change="destroyUI();createUI( cmbPages.selectedItem.data );">
<mx:dataProvider>
<mx:Array>
<mx:Object data="pageVBox" label="Page with VBox"/>
<mx:Object data="pagePanel" label="Page with Panel"/>
</mx:Array>
</mx:dataProvider>
</mx:ComboBox>
</mx:HBox>
<mx:ViewStack id="vsPageHolder" width="100%" height="100%">
</mx:ViewStack>
</mx:Application>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" xmlns="*"
width="100%" height="100%" initialize="createUI( 'pageVBox' )">
<mx:Script>
<![CDATA[
import mx.core.UIObject;
public var pageItem : Object;
function createUI( pageUI:String ):Void {
if( pageUI == "pageVBox" )
pageItem = vsPageHolder.createChild( test.MainPage, undefined );
if( pageUI == "pagePanel" )
pageItem = vsPageHolder.createChild( test1.MainPage, undefined );
}
public function destroyUI():Void {
vsPageHolder.destroyChild( UIObject( pageItem ) );
}
]]>
</mx:Script>
<mx:HBox width="100%" textAlign="center" backgroundColor="#DDDDDD">
<mx:Text text="Select a Combo Box item: " width="200" textAlign="right"/>
<mx:ComboBox id="cmbPages" change="destroyUI();createUI( cmbPages.selectedItem.data );">
<mx:dataProvider>
<mx:Array>
<mx:Object data="pageVBox" label="Page with VBox"/>
<mx:Object data="pagePanel" label="Page with Panel"/>
</mx:Array>
</mx:dataProvider>
</mx:ComboBox>
</mx:HBox>
<mx:ViewStack id="vsPageHolder" width="100%" height="100%">
</mx:ViewStack>
</mx:Application>
test/MainPage.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.macromedia.com/2003/mxml"
width="100%" height="200"
backgroundColor="0x99BB66">
<mx:Text text="VBox Page, Hello World!"/>
</mx:VBox>
<mx:VBox xmlns:mx="http://www.macromedia.com/2003/mxml"
width="100%" height="200"
backgroundColor="0x99BB66">
<mx:Text text="VBox Page, Hello World!"/>
</mx:VBox>
test1/MainPage.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns:mx="http://www.macromedia.com/2003/mxml"
width="50%" height="300"
backgroundColor="0x6699BB">
<mx:Text text="Panel Page, Hello World!"/>
</mx:Panel>
<mx:Panel xmlns:mx="http://www.macromedia.com/2003/mxml"
width="50%" height="300"
backgroundColor="0x6699BB">
<mx:Text text="Panel Page, Hello World!"/>
</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.
Recent Comments