0
我有我想要顯示/隱藏取決於狀態的應用程序是的Flex viewstack孩子includeIn工作搞笑
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:eworx="com.eworx.*"
xmlns:view="com.eworx.view.*"
xmlns:components="com.eworx.view.components.*"
skinClass="com.eworx.view.skins.MainAppSkin"
xmlns:layouts="com.eworx.view.layouts.*"
currentState="login"
initialize="init(event)"
creationComplete="complete(event)"
width="100%"
height="100%">
<fx:Style source="assets/css/screen.css" />
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.core.FlexGlobals;
import mx.events.FlexEvent;
import nl.demonsters.debugger.MonsterDebugger;
private var debugger:MonsterDebugger;
[Bindable]
public var apiUrl:String;
[Bindable]
public var customerType:String;
protected function init(event:FlexEvent):void
{
debugger = new MonsterDebugger(this);
}
protected function complete(event:FlexEvent):void
{
var activated:Boolean = FlexGlobals.topLevelApplication.parameters.activated;
var passwordReset:Boolean = FlexGlobals.topLevelApplication.parameters.passwordReset;
var message:String = FlexGlobals.topLevelApplication.parameters.message;
apiUrl = FlexGlobals.topLevelApplication.parameters.apiUrl;
if(activated)
{
Alert.show(message,"Notice");
}
if(passwordReset)
{
Alert.show(message,"Notice");
}
systemManager.addEventListener(MouseEvent.MOUSE_WHEEL,onMouseWheel,true);
}
private function onMouseWheel(e:MouseEvent):void
{
e.delta *= 5;
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<eworx:Seven7Context contextView="{this}" />
<s:Fade id="fadeIn" alphaFrom="0" alphaTo="1" duration="300" />
<s:Fade id="fadeOut" alphaFrom="1" alphaTo="0" duration="300" />
<s:Rotate3D id="r3d" angleYFrom="0" angleYTo="360" duration="300" />
</fx:Declarations>
<s:states>
<s:State name="login" />
<s:State name="wholesale" />
<s:State name="retail" />
</s:states>
<view:LoginForm id="loginForm" includeIn="login" horizontalCenter="0" verticalCenter="0" />
<s:Group excludeFrom="login" width="960" horizontalCenter="0">
<s:BitmapImage width="100%" height="42" x="13" y="80" source="@Embed('assets/garnish/bar.png')" />
<mx:Image source="assets/garnish/logo.png" top="23" />
<s:HGroup verticalAlign="middle" x="198" y="47">
<s:TabBar skinClass="MainMenuTabBarSkin" dataProvider="{vs}" buttonMode="true"/>
<mx:LinkButton id="logout" label="Logout" click="{currentState='login'}" />
</s:HGroup>
<s:HGroup top="0" right="0" gap="1" verticalAlign="top">
<components:OfferList />
<components:MarginBuildersTrack />
<components:CartTrack top="0" />
</s:HGroup>
<mx:ViewStack
id="vs"
top="120"
horizontalCenter="0"
width="960"
height="100%"
resizeToContent="true" >
<view:HomePage showEffect="{fadeIn}" hideEffect="{fadeOut}" label="Home" />
<view:ShowroomPage showEffect="{fadeIn}" hideEffect="{fadeOut}" label="Showroom" />
<view:CataloguePage showEffect="{fadeIn}" hideEffect="{fadeOut}" label="Catalogue" />
<!--<view:IncentivesPage showEffect="{fadeIn}" hideEffect="{fadeOut}" label="Incentives" />-->
<view:RetailCustomerProfilePage includeIn="retail" showEffect="{fadeIn}" hideEffect="{fadeOut}" label="My Profile" />
<view:WholesaleCustomerProfilePage includeIn="wholesale" showEffect="{fadeIn}" hideEffect="{fadeOut}" label="My Profile" />
<view:ClientsPage excludeFrom="retail,login" showEffect="{fadeIn}" hideEffect="{fadeOut}" label="My Clients" />
<view:CartPage showEffect="{fadeIn}" hideEffect="{fadeOut}" label="My Cart" />
<view:OrdersPage showEffect="{fadeIn}" hideEffect="{fadeOut}" label="My Orders" />
</mx:ViewStack>
</s:Group>
</s:Application>
,你可以看到我inlude零售客戶視圖在零售狀態兒童一個viewstack以及批發狀態下的批發客戶觀點。問題是,當我運行我的應用程序時,它們不會出現在兩種狀態中。
任何想法?
我的應用程序有一個默認狀態「登錄」,它有一個登錄表單視圖。當用戶登錄時,我檢查他是否是零售客戶或批發客戶,並相應地更改當前狀態。所以我想對每種類型的用戶有不同的看法。我使用viewstack作爲導航的應用程序視圖和tabbar。爲什麼這是一個奇怪的方法。順便改變creationPolicy到所有的工作,但我有最初的開銷。 – chchrist 2010-09-17 11:57:43
我從來沒有見過任何人使用ViewStack作爲TabBar的dataProvider。我從來沒有見過任何人爲ViewStack的孩子使用「includeIn」。這是我說這是奇怪的原因。大多數人認爲我已經使用了州或ViewStacks;但你在混合這兩個。這就是爲什麼我說這很奇怪。由於它的工作方式與您的預期相同,因此在將creationPolicy設置爲all時,我只會將您指向我關於ViewStack綁定的原始理論,而TabBar不會更改。 – JeffryHouser 2010-09-17 13:13:54
在「登錄」狀態下,零售或批發不存在包含使用情況的提單。當您更改狀態時,TabBar的dataProvider不會更新更新,因爲ViewStack不是可綁定的。我敢打賭,如果你在ActionScript中創建ViewStack並使其成爲可綁定的,它就可以工作。這將是一件乏味的事,雖然B/C,那麼你將不得不在AS3中創建所有ViewStack的子項目。 – JeffryHouser 2010-09-17 13:15:06