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

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

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

    隨筆-57  評(píng)論-117  文章-1  trackbacks-0

    在flex組件中嵌入html代碼,可以利用flex iframe。這個(gè)在很多時(shí)候會(huì)用到的,有時(shí)候flex必須得這樣做,如果你不這樣做還真不行……

    flex而且可以和html進(jìn)行JavaScript交互操作,flex調(diào)用到html中的JavaScript方法以及獲取調(diào)用后的返回值。

     

    1、flex iframe下載地址:https://github.com/downloads/flex-users/flex-iframe/flex-iframe-1.5.1.zip

    下載完成后目錄如下

    image 

    asdoc就是文檔doc了

    bin有需要用到的flex庫 swc

    examples就是示例

    sources源代碼

     

    歡迎關(guān)注我的博客:http://hoojo.cnblogs.com

    http://blog.csdn.net/IBM_hoojo

     

    2、將bin目錄中的swc引入到你的flex工程中,并加入代碼片段如下

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                    xmlns:flexiframe="http://code.google.com/p/flex-iframe/"
                    horizontalAlign="center" verticalAlign="middle" xmlns:s="library://ns.adobe.com/flex/spark">
        
        <mx:Script>
            <![CDATA[
                import mx.controls.Alert;
                protected function sayHelloHandler(event:MouseEvent):void {
                    // 調(diào)用當(dāng)前iframe嵌入頁面中的sayHello 的JavaScript方法
                    iFrameBySource.callIFrameFunction("sayHello");
                }
                
                protected function sayHandler(event:MouseEvent):void {
                    // 調(diào)用當(dāng)前iframe嵌入頁面中的say的JavaScript方法,并傳入一個(gè)參數(shù)
                    iFrameBySource.callIFrameFunction("say", ["hello world!"]);
                }
                protected function sayHiHandler(event:MouseEvent):void {
                    // 調(diào)用當(dāng)前iframe嵌入頁面中的sayHi的JavaScript方法,并傳入2個(gè)參數(shù)。sayHi方法會(huì)返回一個(gè)字符串,最后一個(gè)回調(diào)就是輸出值的函數(shù)
                    iFrameBySource.callIFrameFunction("sayHi", ["hello world", "李四"], function (data:*): void {
                        Alert.show(data);
                    });
                }
            ]]>
        </mx:Script>
        
        <!-- HTML content stored in a String -->
        <mx:String id="iFrameHTMLContent">
            <![CDATA[
            <html>
                <head>
                    <title>About</title>
                </head>
                <body>
                    <div>About</div>
                    <p>Simple HTML Test application. This test app loads a page of html locally.</p>
                    <div>Credits</div>
                    <p> </p>
                    <p>IFrame.as is based on the work of</p>
                    <ul>
                    <li><a href="http://coenraets.org/" target="_top">Christophe Coenraets</a></li>
                    <li><a href="http://www.deitte.com/" target="_top">Brian Deitte</a></li>
                    </ul>
                </body>
            </html>
            ]]>
        </mx:String>
        
        <mx:Panel width="80%" height="80%" title="使用source本地遠(yuǎn)程頁面">
            <flexiframe:IFrame id="iFrameBySource" width="100%" height="100%" source="frame.html"/>
            <s:Button label="sayHello" click="sayHelloHandler(event)"/>
            <s:Button label="say-param" click="sayHandler(event)"/>
            <s:Button label="sayHi" click="sayHiHandler(event)"/>
        </mx:Panel>
        
        <mx:Panel width="80%" height="80%" title="使用source加載遠(yuǎn)程頁面">
            <flexiframe:IFrame id="iFrameByRemoteSource" width="100%" height="100%" source="http://www.baidu.com" visible="true"
                               overlayDetection="true" />
        </mx:Panel>
        
        <mx:Panel width="80%" height="80%" title="使用content屬性 加載本地html文本內(nèi)容">
            <flexiframe:IFrame id="iFrameByContent" width="100%" height="100%" content="{iFrameHTMLContent}"/>
        </mx:Panel>
        
    </mx:Application>

     

    frame.html 頁面內(nèi)容

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <title>frame.html</title>
        <meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">
        <script type="text/javascript">
            // 無參數(shù)
            function sayHello() {
                alert("hello......");
            }
        
            // 1個(gè)參數(shù)
            function say(message) {
                alert("your say: " + message);
            }
        
            // 多個(gè)參數(shù) 并返回值
            function sayHi(message, name) {
                alert("your say: " + message + ", name: " + name);
                return "your say: " + message + ", name: " + name;
            }
        </script>    
     
      </head>
      
      <body>
        flex frame example html page!
        <input type="button" value="say" onclick="sayHello()"/>
      </body>
    </html>

    要注意的是:你的flex項(xiàng)目工程需要發(fā)表到http的應(yīng)用服務(wù)器(如tomcat、jboss、iis)這些服務(wù)器中,用http請求方式才能調(diào)用到頁面內(nèi)容和JavaScript方法。如果不發(fā)布到應(yīng)用服務(wù)器中,那樣只能在iframe中嵌套遠(yuǎn)程的http請求的頁面,本地靜態(tài)頁面是無法顯示的。



    作者:hoojo
    出處:
    blog:http://blog.csdn.net/IBM_hoojo
             http://hoojo.cnblogs.com
    本文版權(quán)歸作者和博客園共有,歡迎轉(zhuǎn)載,但未經(jīng)作者同意必須保留此段聲明,且在文章頁面明顯位置給出原文連接,否則保留追究法律責(zé)任的權(quán)利。


    版權(quán)所有,轉(zhuǎn)載請注明出處 本文出自:
    分享道版權(quán)所有,歡迎轉(zhuǎn)載,轉(zhuǎn)載請注明出處,謝謝
    posted on 2013-08-15 15:58 hoojo 閱讀(5858) 評(píng)論(2)  編輯  收藏 所屬分類: Flex/ActionScriptFrameWork IntegrationHTML/CSSJavaEEJavaScript

    評(píng)論:
    # re: 在Flex (Flash)中嵌入HTML 代碼或頁面&mdash;Flex IFrame 2013-08-18 12:45 | tb
    可以好好研究一下的  回復(fù)  更多評(píng)論
      
    # re: 在Flex (Flash)中嵌入HTML 代碼或頁面&mdash;Flex IFrame 2013-09-12 08:57 | 小村
    <flexiframe:IFrame id="iFrameByRemoteSource" width="100%" height="100%" source="http://www.baidu.com" visible="true"
    overlayDetection="true" />

    -------------------------
    怎樣獲取這里面的html代碼(遠(yuǎn)程的)  回復(fù)  更多評(píng)論
      
    主站蜘蛛池模板: 99热这里有免费国产精品| 成人免费一区二区三区| 黄色免费在线观看网址| 一级毛片aa高清免费观看| 人妻在线日韩免费视频| 98精品全国免费观看视频| 最近免费中文字幕大全视频 | a毛片免费观看完整| 亚洲精品免费在线观看| 亚洲婷婷综合色高清在线| 亚洲AV成人一区二区三区在线看| 亚洲Av永久无码精品黑人| 日韩精品无码永久免费网站| 国产午夜不卡AV免费| 免费精品国偷自产在线在线| 国产午夜免费福利红片| 亚洲中文字幕无码久久精品1| 久久水蜜桃亚洲av无码精品麻豆| 国产亚洲福利在线视频| 一个人看的www在线免费视频| 免费人成在线观看网站品爱网 | 亚洲女人初试黑人巨高清| 亚洲av永久无码天堂网| 久久久精品免费国产四虎| 成年大片免费视频| 亚洲色无码一区二区三区| 亚洲一区动漫卡通在线播放| 日韩免费码中文在线观看| 91制片厂制作传媒免费版樱花| 精品剧情v国产在免费线观看| 亚洲午夜国产精品无码老牛影视 | 在线播放亚洲精品| 可以免费观看的国产视频| 免费看a级黄色片| 亚洲av无码片在线播放| 亚洲精华国产精华精华液好用| 中文字幕一区二区免费| 午夜私人影院免费体验区| 国产aⅴ无码专区亚洲av| 久久精品国产亚洲AV未满十八| 99精品视频在线观看免费专区|