可绑定变量未使用 viewstack / swiz 更新
我正在使用 Swiz 框架,并尝试使用可绑定属性更新我的视图堆栈的 selectedIndex 。它到达我的事件处理程序,该处理程序更新可绑定变量,但主应用程序文件的视图堆栈从未意识到它。可能是什么问题?
thx
-Mike
==================================
主应用程序文件
<mx:Script>
<![CDATA[
import reg.model.ApplicationViewModel;
import beyaz.reg.swiz.SwizBeans;
import org.swizframework.Swiz;
[Autowire(bean="applicationViewModel")]
[Bindable]
public var applicationViewModel:ApplicationViewModel;
private function preInitialize():void {
Swiz.loadBeans( [ SwizBeans ] );
}
]]>
</mx:Script>
<mx:ViewStack id="theViewstack" **selectedIndex=" {applicationViewModel.mainViewIndex}"** width="100%" height="100%">
<prescreen:Prescreen id="prescreenView"/>
<login:Login id="loginView"/>
<profile:Profile id="profileView"/>
</mx:ViewStack>
============ =====================
ApplicationViewModel
包 com.reg.model { 公共类ApplicationViewModel { 公共静态常量 PRESCREEN_VIEW:int = 0; 公共静态常量 LOGIN_VIEW:int = 1; 公共静态常量 PRSNL_INFO_VIEW:int = 2;
[Bindable]
public var message:String = "";
[Bindable]
public var mainViewIndex:int = PRESCREEN_VIEW;
}
}
=============================
控制器
包 com.reg.controller {
import com.reg.model.ApplicationViewModel;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.events.DynamicEvent;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.core.Application;
import org.swizframework.Swiz;
import org.swizframework.controller.AbstractController;
public class PrescreenController// extends AbstractController
{
public static const START_REGISTRATION:String = "startReg";
[Autowire(bean="applicationViewModel")]
[Bindable]
public var applicationViewModel:ApplicationViewModel;
[Mediate(event="startReg")]
public function startReg():void
{
//CODE GETS TO HERE!
applicationViewModel.mainViewIndex = ApplicationViewModel.PRSNL_INFO_VIEW;
}
}
}
I'm using the Swiz framework and I'm trying to update my viewstack's selectedIndex with a bindable property. It gets to my event handler which updates the bindable variable but the Main app file's viewstack never realizes it. What could be the issue?
thx
-Mike
================================
MAIN APP FILE
<mx:Script>
<![CDATA[
import reg.model.ApplicationViewModel;
import beyaz.reg.swiz.SwizBeans;
import org.swizframework.Swiz;
[Autowire(bean="applicationViewModel")]
[Bindable]
public var applicationViewModel:ApplicationViewModel;
private function preInitialize():void {
Swiz.loadBeans( [ SwizBeans ] );
}
]]>
</mx:Script>
<mx:ViewStack id="theViewstack" **selectedIndex=" {applicationViewModel.mainViewIndex}"** width="100%" height="100%">
<prescreen:Prescreen id="prescreenView"/>
<login:Login id="loginView"/>
<profile:Profile id="profileView"/>
</mx:ViewStack>
=================================
ApplicationViewModel
package com.reg.model
{
public class ApplicationViewModel
{
public static const PRESCREEN_VIEW:int = 0;
public static const LOGIN_VIEW:int = 1;
public static const PRSNL_INFO_VIEW:int = 2;
[Bindable]
public var message:String = "";
[Bindable]
public var mainViewIndex:int = PRESCREEN_VIEW;
}
}
===========================
Controller
package com.reg.controller
{
import com.reg.model.ApplicationViewModel;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.events.DynamicEvent;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.core.Application;
import org.swizframework.Swiz;
import org.swizframework.controller.AbstractController;
public class PrescreenController// extends AbstractController
{
public static const START_REGISTRATION:String = "startReg";
[Autowire(bean="applicationViewModel")]
[Bindable]
public var applicationViewModel:ApplicationViewModel;
[Mediate(event="startReg")]
public function startReg():void
{
//CODE GETS TO HERE!
applicationViewModel.mainViewIndex = ApplicationViewModel.PRSNL_INFO_VIEW;
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
上周我就被这个问题困扰了。
将
[Bindable]
标记放在其他标记之前。由于某种原因,Flex 编译器不会折叠适当的PropertyChangeEvent
调度,除非您首先放置[Bindable]
标记。I got bit by this problem just last week.
Put your
[Bindable]
tag before the other tags. For some reason the Flex compiler doesn't fold in the appropriatePropertyChangeEvent
dispatching unless you put the[Bindable]
tag first.