I have created my own CanvasStack (to replace the viewstack) because
viewstacks and models do not mix.

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas 
xmlns:mx="http://www.adobe.com/2006/mxml";
creationComplete="initApp()" height="100%"
horizontalScrollPolicy="off" verticalScrollPolicy="off"
>
        
<mx:Metadata>
[Event(name="changeSelectedIndex",type="flash.events.Event")]
</mx:Metadata>
        
<mx:Script>
<![CDATA[
import com.gladhandle.AppGlobals;
import com.gladhandle.handles.greeting_card.gcassets.Editor;
        
[Bindable]
private var _selectedIndex:int;
public var dataProvider:Array;
private function initApp():void {
_selectedIndex = 0;
addChild( dataProvider[_selectedIndex] );
}
                        
public function set selectedIndex( selectedIndex:int ):void {
if( selectedIndex < 0 || selectedIndex > dataProvider.length ) {
throw new Error( "selectedIndex out of range" );
return;
}
_selectedIndex = selectedIndex;
dispatchEvent( new Event( "changeSelectedIndex", false ) );
this.removeAllChildren();
this.addChild( dataProvider[_selectedIndex] );
}
                        
[Bindable]
public function get selectedIndex():int {
return _selectedIndex;
}
                        
]]>
</mx:Script>
</mx:Canvas>

---------------------------------------

This dataprovider is populated with custom components as well.

When I change the selected index, it removes all the children (but
they still exist in the dataprovider, so 'session' data should be
saved), but when I navigate back to an index I have already visited,
everything is still there, EXCEPT for the format of the text, it for
some reason, is reset back to the original text, even though I have
setTextFormat() and set the defaultTextFormat on the TextField.

Any ideas?


Reply via email to