Sunday, March 28, 2010

creation complete

am I right in thining for a view stack, the creation complete will fire every time that view is enabled? or is it just the first time?

creation complete

ok so I've worked out that creation complete will only fire the first time a view in a stack is loaded / viewed.

However whayt I need is this,

I have a viewstack with two views, view 1 and view 2, each time a view is loaded I want to call a function which will in turn populate the view stack, any ideas how I can call this time each time a view is loaded?

Cheers

Tim

creation complete

Hello,

Give this a try. On the Canvas or Panel or whatever it is in your viewstack use the show event to fire the action.

Example:

%26lt;mx:ViewStack id=''vs1''%26gt;

%26lt;mx:Canvas id=''can1'' label=''Customers'' show=''Alert.show('Fires when showed')''/%26gt;

%26lt;/mx:ViewStack%26gt;

Hello

As you require to load data every time when view of viewstack is being changed.

There is two way to do samething.


1. You can use viewstack change event

in this you willl get?oldindex and newindex of viewsatck so as per that you can load or unload the data as per requirement

2. You can use 'show' event of childern inside the viewstack

in this 'show' event is fiered when any child inside view stack is in visible mode, so you can do for that viw also.

With Regards

Virat Patel

Hello

This can be possible is two ways

Like you can use 'change' event of the viewstack or 'show' event of the childs inside viewstack.

Sample Example...

//////////////////////////////////////////////////////////

%26lt;?xml version=''1.0'' encoding=''utf-8''?%26gt;
%26lt;mx:Application xmlns:mx=''http://www.adobe.com/2006/mxml'' layout=''vertical''%26gt;

%26lt;mx:Script%26gt;
%26lt;![CDATA[
import mx.events.IndexChangedEvent;
import mx.events.FlexEvent;

private function onCanShow(event:FlexEvent):void
{
// load new data
// do something
}

private function onChildChange(event:IndexChangedEvent):void
{
// load new data
// do something
}

]]%26gt;
%26lt;/mx:Script%26gt;

%26lt;mx:TabBar dataProvider=''{vs}'' /%26gt;

%26lt;mx:ViewStack id=''vs'' height=''400'' width=''400'' change=''onChildChange(event)''%26gt;
%26lt;mx:Canvas label=''Can1'' height=''100%'' width=''100%''
backgroundColor=''0xCCCCCC'' show=''onCanShow(event)'' /%26gt;
%26lt;mx:Canvas label=''Can2'' height=''100%'' width=''100%''
backgroundColor=''0x00FFCC'' show=''onCanShow(event)'' /%26gt;
%26lt;/mx:ViewStack%26gt;

%26lt;/mx:Application%26gt;

//////////////////////////////////////////////////////////////////////

With Regards

Virat Patel

  • makeup
  • No comments:

    Post a Comment