代码人生的小狗窝

一行行枯燥的代码,却描绘出人生的点点滴滴

您现在的位置是:首页>_Flex

小弟我自己写的一个flex例子

发布时间:2018-05-20浏览(3269)

    我自己写的一个flex例子
    <?xml version="1.0" encoding="utf-8"?>
    <pms:PMSModuleBase xmlns:mx="http://www.adobe.com/2006/mxml"
       xmlns:flexiframe="com.google.code.flexiframe.*"
       xmlns:pms="com.huawei.bi.pms.ui.common.*"
       width="100%" height="100%" title="{effectTitle}"
       paddingLeft="1" paddingRight="1" layout="vertical" creationComplete="init()">
    <mx:Script>
    <![CDATA[
    import com.huawei.bi.pms.ui.utils.PmsConst;
    import mx.controls.Alert;
    import mx.managers.CursorManager;
    import mx.rpc.events.FaultEvent;
    import mx.rpc.events.ResultEvent;
    import mx.core.Application;
    import mx.modules.ModuleLoader;
    import com.huawei.bi.pms.ui.workflownodechooser.util.MyUrlUtil;

    private var urlType:String="";
    [Bindable] private var effectTitle:String = "";
    private var tempPath:String = Application.application.url;
    private var arr:Array= tempPath.split("/");
    [Bindable] private var cognosurl:String="http://"+arr[2];

    private function init():void {
    if(this.parent is ModuleLoader){
    var url:String =(this.parent as ModuleLoader).url;
    var urlUtil:MyUrlUtil = new MyUrlUtil();
    urlType=urlUtil.getValueByKey(url,"type");
    loadReportUrl(urlType);
    }
    }
    private function loadReportUrl(type:String):void{
    switch(type){
    case "01":
    effectTitle="营销活动开展监控";
    ro.getResourceUrl(PmsConst.BICP_EFFECT_REPORT_URL1);
    break;
    case "02":
    effectTitle="营销活动参与监控";
    ro.getResourceUrl(PmsConst.BICP_EFFECT_REPORT_URL2);
    break;
    case "03":
    effectTitle="营销活动成本投入监控";
    ro.getResourceUrl(PmsConst.BICP_EFFECT_REPORT_URL3);
    break;
    case "04":
    effectTitle="营销活动财务收入监控";
    ro.getResourceUrl(PmsConst.BICP_EFFECT_REPORT_URL4);
    break;
    case "05":
    effectTitle="营销活动效果评估监控";
    ro.getResourceUrl(PmsConst.BICP_EFFECT_REPORT_URL5);
    break;
    }
    }
    private function getFaultResult(event:FaultEvent):void{
    CursorManager.removeBusyCursor();
    Alert.show("数据库连接失败!","提示");
    }
    private function getResourceUrlResult(event:ResultEvent):void{
    var res:String = event.result as String;
    if(res!=null&&res!=""&&res.length>0){
    cognosurl=cognosurl+res;
    frm.source=cognosurl;
    }else{
    Alert.show("cognos资源URL获取失败!","提示");
    }
    }
    ]]>
    </mx:Script>
    <mx:RemoteObject id="ro" destination="PMSReportService" showBusyCursor="true">
    <mx:method name="getResourceUrl" result="getResourceUrlResult(event)" fault="getFaultResult(event)"/>
    </mx:RemoteObject>

    <flexiframe:IFrame id="frm"
            label="cognos"
            source=""
            width="100%"
            height="100%"/>
    </pms:PMSModuleBase>