<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    【永恒的瞬間】
    ?Give me hapy ?
    找到了一個Flex?RemoteObject結合CFC使用的例子.在這里我來詳細講一下.
    主要三個文件.
    Flex:?main.mxml
    AS:?Test.as
    CFC:?test.cfc


    先教大家配置一下.
    main.mxml放到Flex的根目錄下.
    Test.as放到Flex的根目錄下的cfcRemoting文件內.
    test.cfc放到Coldfusion的根目錄下的cfcRemoting文件內.


    main.mxml文件的內容:
    程序代碼:
    <?xml?version="1.0"?encoding="utf-8"?>
    <mx:Application?xmlns:mx="http://www.macromedia.com/2003/mxml"?>
    ?<mx:Script>
    ?<![CDATA[
    ??var?dependency:cfcRemoting.Test;
    ?]]>
    ?</mx:Script>
    ?<mx:RemoteObject?
    ??endpoint="http://localhost:8300/flashservices/gateway"
    ??source="cfcRemoting.test"
    ??id="ro"
    ?/>
    ?<mx:DateFormatter?formatString="hh:mm:ss"?id="dateFormatter"?/>
    ?<mx:Panel?title="CFC?Remoting"?width="350">
    ??<mx:List?id="objList"?dataProvider="{ro.getObjectArray.result}"?width="100%"?/>
    ??<mx:TextInput?editable="false"?text="{objList.selectedItem}"?width="100%"?/>
    ??<mx:ControlBar>
    ???<mx:Label?text="Number?of?objects:"/>
    ???<mx:NumericStepper?id="amount"?minimum="1"?maximum="500"?value="/5"?/>
    ???<mx:Button?label="invoke"?click="ro.getObjectArray(amount.value)"?/>
    ??</mx:ControlBar>
    ?</mx:Panel>
    </mx:Application>

    1.首先分析看一下他的外觀是如何的.

    外觀用了一個Panel:用于裝下面的組件.一個List:用于存放從CFC傳回來的.一個TextInput:用于顯示List被選的條目.一個:ControlBar:用于裝Label,?NumericStepper,與Button.?NumericStepper用于用戶所需生成的對象數,Button用于調用CFC.
    程序代碼:
    <?xml?version="1.0"?encoding="utf-8"?>
    <mx:Application?xmlns:mx="http://www.macromedia.com/2003/mxml"?>
    ?<mx:Panel?title="CFC?Remoting"?width="350">
    ??<mx:List?id="objList"?width="100%"/>
    ??<mx:TextInput?editable="false"?width="100%"?/>
    ??<mx:ControlBar>
    ???<mx:Label?text="Number?of?objects:"/>
    ???<mx:NumericStepper?id="amount"?minimum="1"?maximum="500"?value="5"?/>
    ???<mx:Button?label="invoke"?/>
    ??</mx:ControlBar>
    ?</mx:Panel>
    </mx:Application>
    ?

    好了,外觀出來了.
    2.再看一下除外觀標簽外的標簽.
    程序代碼:
    <mx:Script>
    ?<![CDATA[
    ??//這里聲明了一個CFC組件的一個對象.
    ??var?dependency:cfcRemoting.Test;
    ?]]>
    ?</mx:Script>
    ?<mx:RemoteObject?
    ??//?endpoint屬性指定網關,這里根大家的配置所填.我這里的是CF7.0的.如果用CFMX的端口改回8500
    ??endpoint=http://localhost:8300/flashservices/gateway
    ??//?source屬性指定CFC的文件
    ??source="cfcRemoting.test"
    ??//id屬性指定實例名,用于在程序中的引用
    ??id="ro"
    ?/>
    ?//formatString屬性指定時間的格式
    ?//id屬性指定實例名,用于在程序中的引用
    ?<mx:DateFormatter?formatString="hh:mm:ss"?id="dateFormatter"?/>
    ?
    3.再看看外觀的代碼:
    程序代碼:
    //標題設為"CFC?Remoting"
    //寬設為:?350
    <mx:Panel?title="CFC?Remoting"?width="350">
    ??//?dataProvider屬性等于ro.?getObjectArray.result得回來的.
    ??<mx:List?id="objList"?dataProvider="{ro.getObjectArray.result}"?width="100%"?/>
    ??//?text屬性是等于"objList"中被選擇的條目
    ??<mx:TextInput?editable="false"?text="{objList.selectedItem}"?width="100%"?/>
    ??<mx:ControlBar>
    ???<mx:Label?text="Number?of?objects:"/>
    ???<mx:NumericStepper?id="amount"?minimum="1"?maximum="500"?value="/5"?/>
    ???//?click事件調用ro.getObjectArray(),將NumericStepper的傳到CFC里
    ???<mx:Button?label="invoke"?click="ro.getObjectArray(amount.value)"?/>
    ??</mx:ControlBar>
    ?</mx:Panel>

    4.test.cfc的內容
    程序代碼:
    <cfcomponent>
    ?<cfset?this.remoteClass="cfcRemoting.Test">
    ?<cffunction?name="getObject"?access="remote"?returntype="struct">
    ??<cfargument?name="num"?type="numeric"?required="yes">
    ??<cfset?var?obj=StructNew()>
    ??<cfset?obj["_remoteClass"]?=?this.remoteClass>
    ??<cfset?obj["date"]?=?now()>??
    ??<cfset?obj["name"]?=?"Object?#num#">??
    ??<cfreturn?obj>
    ?</cffunction>
    ?<cffunction?name="getObjectArray"?access="remote"?returntype="array">
    ??<cfargument?name="amount"?type="numeric"?required="no"?default="1">
    ??<cfset?arr?=?ArrayNew(1)>
    ??<cfloop?from="1"?to=#amount#?index="j">
    ???<cfset?arr[j]=#getObject(j)#>
    ??</cfloop>
    ??<cfreturn?arr>
    ?</cffunction>
    </cfcomponent>

    這個組件有兩個方法.?getObject()getObjectArray().
    這里的getObject()方法是由getObjectArray()方法去調用的.
    getObjectArray()方法是main.mxml中的ro對象所調用的,
    看一下他們做了些什么
    getObjectArray()方法就根據main.mxml中的NumericStepper來動態生成數組個數.
    每個數組都調用getObject()?方法來填充數據為一個結構.
    getObject()?方法就將每個數組都賦上一個結構。
    結構體里有:["_remoteClass"],["date"],["name"]三條。
    5.Test.as的代碼:
    程序代碼:
    class?cfcRemoting.Test?{
    ?//定義一個name
    ?public?var?name:String;
    ?//定義一個時間
    ?public?var?date:Date;
    ?//構造函數
    ?public?function?Test()?{
    ?}
    ?public?function?get?label():String?{
    ??//返回這個到main.mxml的List里
    ??return?name?+?"?(label?test)";
    ?}
    ?
    ?public?function?toString():String?{
    ??//返回這個到main.mxml的TextInput里
    ??return?"Hi,?this?is?"?+?name?+?",?created?"?+?date.getHours()?+?":"?+?date.getMinutes()?+?":"?+?date.getSeconds()?+?":"?+?date.getMilliseconds();
    ?}
    }


    好了.完成了.大家試用一下吧.
    posted on 2007-03-02 14:10 ???MengChuChen 閱讀(847) 評論(0)  編輯  收藏 所屬分類: flex2.0
    主站蜘蛛池模板: 亚洲免费一区二区| 国产91成人精品亚洲精品| 青青青国产手机频在线免费观看| 免费中文字幕不卡视频| 亚洲男同gay片| 日本特黄特黄刺激大片免费| 在线观看亚洲AV日韩AV| 成人性生交大片免费看午夜a| 亚洲五月综合缴情婷婷| 成人免费视频77777| 亚洲熟女乱色一区二区三区| 成人无遮挡裸免费视频在线观看 | 好爽又高潮了毛片免费下载| 亚洲人成电影网站| 久久精品国产亚洲一区二区| 成年女人A毛片免费视频| 亚洲永久无码3D动漫一区| 三年片在线观看免费西瓜视频| 亚洲国产精品VA在线观看麻豆| 暖暖在线视频免费视频| 亚洲伦理一二三四| 国产精品免费_区二区三区观看| 在线播放免费人成视频网站| 国产亚洲3p无码一区二区| 日本一卡精品视频免费| 亚洲成_人网站图片| 亚洲国产一区二区视频网站| 国产精品免费视频观看拍拍 | 日韩在线免费看网站| 男女猛烈无遮掩视频免费软件| 久久影视国产亚洲| 99久久免费看国产精品| 亚洲一线产区二线产区区| 亚洲国产成人久久一区WWW| 丁香花在线视频观看免费| 亚洲第一页在线观看| 亚洲AⅤ视频一区二区三区| 久久精品视频免费播放| 亚洲字幕AV一区二区三区四区| 中文字幕亚洲电影| www.999精品视频观看免费|