如何在视图堆栈中设置选定的子项?
在 main.mxml 中:
public function init():void
{
PopUpManager.createPopUp(this,login,true);
}
<mx:ViewStack id="vs" label="content" >
<local:FrontPanel id="Fpanel" />
<local:SlavePanel id="Spanel" />
<local:AdminPanel id="Mpanel" />
</mx:ViewStack>
在 Login.mxml 中:
public function authenticateRH(event:ResultEvent):void
{
var replyMsg:String=event.result as String;
switch(replyMsg)
{
case "Master" :
here i want invoke Mpanel from Main.mxml
break;
case "Slave" :
here i want invoke Spanel from Main.mxml
break;
case "fail" :
Alert.show("Login Incorrect!!");
return;
}
}
如何从 login.mxml 中选择 main.mxml 的 Viewstack 的子项?
in main.mxml :
public function init():void
{
PopUpManager.createPopUp(this,login,true);
}
<mx:ViewStack id="vs" label="content" >
<local:FrontPanel id="Fpanel" />
<local:SlavePanel id="Spanel" />
<local:AdminPanel id="Mpanel" />
</mx:ViewStack>
In Login.mxml :
public function authenticateRH(event:ResultEvent):void
{
var replyMsg:String=event.result as String;
switch(replyMsg)
{
case "Master" :
here i want invoke Mpanel from Main.mxml
break;
case "Slave" :
here i want invoke Spanel from Main.mxml
break;
case "fail" :
Alert.show("Login Incorrect!!");
return;
}
}
How can i selectchild of main.mxml's Viewstack from login.mxml ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我会使用事件(和接口),这样您的表单就不需要了解太多有关其中一个或另一个的信息。它还可以让您更好地控制弹出窗口关闭后发生的情况(恕我直言)。
这是一个小例子(如果我可以正确粘贴代码)。此示例不使用有助于解耦事物的接口。我还使用动态事件来加快原型设计速度,但您需要定义一个正式事件。
模拟您的主要:
模拟您的登录:
I would use events (and interfaces), that way your forms don't need to know as much about one and other. It also gives you more control on what happens after your popup closes (IMHO).
Here is a little example (if I can get the code to paste correctly). This example does not use an interface that would help decouple things. I also use dynamic events that make prototyping faster but you will want to define a formal event.
simulate your main:
simulate your login:
我假设您的问题是在您的authenticateRH 方法中没有对ViewStack 的引用。解决此问题的一种方法是在创建登录弹出窗口后为其提供更多信息:
您必须将 setUsefulInformation() 方法添加到 login.mxml。由您决定要传递哪些信息来解决问题。
I'm assuming your problem is that you don't have a reference to your ViewStack while in your authenticateRH method. One way you can fix this is to give your login popup some more information after you create it:
You'd have to add the setUsefulInformation() method to login.mxml. It's up to you what information you want to pass to solve the problem.
首先,我相信您创建的弹出窗口不正确。您似乎已切换前两个参数。应该是:
PopUpManager.createPopUp(login,this,true);
文档:http://livedocs。 adobe.com/flex/3/langref/mx/managers/PopUpManager.html#addPopUp%28%29
其次,您需要显式为您的 Login 类提供对 Main 类的引用,或者如果您的 Login 类是在与 Main 类相同的显示链上,您可以使用将
Bubbles
设置为true
的自定义事件。first, i believe you're creating your pop-up incorrectly. you seem to have the first two parameters switched. should be:
PopUpManager.createPopUp(login,this,true);
docs: http://livedocs.adobe.com/flex/3/langref/mx/managers/PopUpManager.html#addPopUp%28%29
second, you need to either explicitly give your Login class a reference to your Main class or if your Login class is on the same display chain as your Main class you can use a custom event with
Bubbles
set totrue
.