zoukankan      html  css  js  c++  java
  • FLEX中ViewStack刷新解决方案

    在ViewStack的生命周期中仅只会加载一次view,对于某些业务来说这样的加载方式不大合适,有没有一种办法在每次切换NavigatorContent的时候都重新加载view呢?

    办法是有的,直接上代码

        <mx:ViewStack id="viewStack1" bottom="0" right="0" top="0" left="0" change="viewStack1_changeHandler(event)">
    <s:NavigatorContent width="100%" height="100%" label="列表" icon="@Embed(source='http://www.cnblogs.com/http://www.cnblogs.com/__assets/icon/main/36/list.png')">
    <view:CommodityListView id="listView" width="100%" height="100%"
    showAddView
    ="listView_showAddViewHandler(event)"
    showModifyView
    ="listView_showModifyViewHandler(event)"
    showPreviewView
    ="listView_showPreviewViewHandler(event)"/>
    </s:NavigatorContent>
    <s:NavigatorContent width="100%" height="100%" label="修改" icon="@Embed(source='http://www.cnblogs.com/http://www.cnblogs.com/__assets/icon/main/36/modify.png')">
    <view:CommodityModifyView id="modifyView" width="100%" height="100%" commodityVO="{this.vo}" returnToListView="addView_returnToListViewHandler(event)" modifyOK="modifyView_modifyOKHandler(event)"/>
    </s:NavigatorContent>
    <s:NavigatorContent id="AddContent" width="100%" height="100%" label="新增" icon="@Embed(source='http://www.cnblogs.com/http://www.cnblogs.com/__assets/icon/main/36/add.png')">
    <view:CommodityAddView id="addView" width="100%" height="100%" returnToListView="addView_returnToListViewHandler(event)" addOK="addView_addOKHandler(event)"/>
    </s:NavigatorContent>
    </mx:ViewStack>

    我想刷新新增view 给NavigatorContent指定一个ID:AddContent

    创建ViewStack的change事件(当所选的子容器更改时分派此方法)

    代码

                protected function viewStack1_changeHandler(event:IndexChangedEvent):void
    {
    // TODO Auto-generated method stub
    var nav:NavigatorContent = event.relatedObject as NavigatorContent;
    if(nav.id == "AddContent")
    {
    addView = new CommodityAddView();

    nav.addElement(addView);
    }
    else
    {
    AddContent.removeElement(addView);
    nav= null;
    }
    }



     

  • 相关阅读:
    217MySQL读写分离mysqlproxy
    shell脚本自动化安装LAMP
    Mybatis的如何根据下划线_,百分号%模糊查询escape的作用
    springboot下MVC的MessageConverters和静态资源位置的配置
    全局性事务控制如何在springboot中配置
    最详细的@Transactional讲解
    常用网址
    truncate、drop、delete区别
    CommandLineRunner、ApplicationRunner 接口
    交叉编译,为什么需要交叉编译
  • 原文地址:https://www.cnblogs.com/ahjesus/p/2277440.html
Copyright © 2011-2022 走看看