zoukankan      html  css  js  c++  java
  • 在flex中使用嵌入html文件以解决显示html的问题

    想在flex中真实的显示html,但是texteara,lable,text中只支持部分html标签

    <a>、<b>、<br>、<font>、<img>如果用img又存在显示自动换行的问题。只有采用嵌入html的方法来解决。

    1.flexdemo1

    <?xml version="1.0" encoding="utf-8"?>


    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:local="*" width="427" height="282" viewSourceURL="srcview/index.html">

    <mx:Panel x="10" y="10" width="407" height="262" layout="absolute" title="TabNavigator with HTML IFrame Enclosures">

    <mx:TabNavigator x="10" y="10" width="367" height="202">

    <local:IFrame source="http://www.ff-power.com"  label="T网" width="100%" height="100%">

    </local:IFrame>

    <local:IFrame source="http://www.ctott.com" label="飞凡动力" width="100%" height="100%">

    </local:IFrame>

    <local:IFrame source="http://www.ff-power.com/bbs" label="飞凡动力-BBS" width="100%" height="100%">

    </local:IFrame>

    </mx:TabNavigator>

    </mx:Panel>    

    </mx:Application>

    2.Iframe.mxml

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"
        resize="callLater(moveIFrame)"
        move="callLater(moveIFrame)">
             <mx:Script>
        <![CDATA[
            import flash.external.ExternalInterface;
            import flash.geom.Point;
            import flash.net.navigateToURL;
            private var _source: String;

            private function moveIFrame(): void {

                var localPt:Point = new Point(0, 0);
                var globalPt:Point = this.localToGlobal(localPt);
                ExternalInterface.call("moveIFrame", globalPt.x, globalPt.y, this.width, this.height);
            }

            public function set source(source: String): void {
                if (source) {

                    if (! ExternalInterface.available)
                    {
                        // TODO: determine if this Error is actually needed.  The debugger
                        // build gives the error below.  Assuming that this error will not show
                        // up in the release build but haven't checked.
                        throw new Error("The ExternalInterface is not available in this container. Internet Explorer ActiveX, Firefox, Mozilla 1.7.5 and greater, or other browsers that support NPRuntime are required.");
                    }
                    _source = source;
                    ExternalInterface.call("loadIFrame", source);
                }
            }

            public function get source(): String {
                return _source;
            }

            override public function set visible(visible: Boolean): void {
                super.visible=visible;
                if (visible)
                {
                    ExternalInterface.call("showIFrame");
                }
                else
                {
                    ExternalInterface.call("hideIFrame");
                }
            }

        ]]>
        </mx:Script>

    </mx:Canvas>

    3.还有script代码

    <script language="JavaScript" type="text/javascript">
    <!--
    // -----------------------------------------------------------------------------
    // Globals
    // Major version of Flash required
    var requiredMajorVersion = 8;
    // Minor version of Flash required
    var requiredMinorVersion = 5;
    // Minor version of Flash required
    var requiredRevision = 0;
    // the version of javascript supported
    var jsVersion = 1.0;
    // -----------------------------------------------------------------------------
    // -->
    </script>
    <script language="VBScript" type="text/vbscript">
    <!-- // Visual basic helper required to detect Flash Player ActiveX control version information
    Function VBGetSwfVer()
      on error resume next
      Dim swControl, swVersion
      swVersion = 0
     
      set swControl = CreateObject("ShockwaveFlash.ShockwaveFlash")
      if (IsObject(swControl)) then
        swVersion = swControl.GetVariable("$version")
      end if
      VBGetSwfVer = swVersion
    End Function
    // -->
    </script>
    <script language="JavaScript1.1" type="text/javascript">
    <!-- // Detect Client Browser type
    var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
    var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
    var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
    jsVersion = 1.1;
    // JavaScript helper required to detect Flash Player PlugIn version information
    function JSGetSwfVer(){
        // NS/Opera version >= 3 check for Flash plugin in plugin array
        if (navigator.plugins != null && navigator.plugins.length > 0) {
            if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
                var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
                  var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
                descArray = flashDescription.split(" ");
                tempArrayMajor = descArray[2].split(".");
                versionMajor = tempArrayMajor[0];
                versionMinor = tempArrayMajor[1];
                if ( descArray[3] != "" ) {
                    tempArrayMinor = descArray[3].split("r");
                } else {
                    tempArrayMinor = descArray[4].split("r");
                }
                  versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
                flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
              } else {
                flashVer = -1;
            }
        }
        // MSN/WebTV 2.6 supports Flash 4
        else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
        // WebTV 2.5 supports Flash 3
        else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
        // older WebTV supports Flash 2
        else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
        // Can't detect in all other cases
        else {
            
            flashVer = -1;
        }
        return flashVer;
    }
    // When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
    function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
    {
         reqVer = parseFloat(reqMajorVer + "." + reqRevision);
        if (isIE && isWin && !isOpera) {
            versionStr = VBGetSwfVer();
        } else {
            versionStr = JSGetSwfVer();        
        }
        if (versionStr == -1 ) {
            return false;
        } else if (versionStr != 0) {
            if(isIE && isWin && !isOpera) {
                tempArray         = versionStr.split(" ");
                tempString        = tempArray[1];
                versionArray      = tempString .split(",");                
            } else {
                versionArray      = versionStr.split(".");
            }
            versionMajor      = versionArray[0];
            versionMinor      = versionArray[1];
            versionRevision   = versionArray[2];
            
            versionString     = versionMajor + "." + versionRevision;   // 7.0r24 == 7.24
            versionNum        = parseFloat(versionString);
            // is the major.revision >= requested major.revision AND the minor version >= requested minor
            if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
                return true;
            } else {
                return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );    
            }
        }
    }

    function moveIFrame(x,y,w,h) {
        var frameRef=document.getElementById("myFrame");
        frameRef.style.left=x;
        frameRef.style.top=y;
        frameRef.width=w;
        frameRef.height=h;
    }

    function hideIFrame(){
        document.getElementById("myFrame").style.visibility="hidden";
    }

    function showIFrame(){
        document.getElementById("myFrame").style.visibility="visible";
    }

    function loadIFrame(url){
        top.frames["myFrame"].location.href=url;
    }

    // -->
    </script>


     http://blog.eshangrao.com/2006/02/08/195/ 参考网站

    测试文件 flex3
  • 相关阅读:
    第7章例7-12
    第7章例7-11
    第7章例7-9
    第7章例7-8
    第7章例7-7
    第7章例7-6
    第7章例7-5
    第7章例7-4
    第7章例7-3
    第7章例7-2
  • 原文地址:https://www.cnblogs.com/guola/p/1272774.html
Copyright © 2011-2022 走看看