Chinaunix首页 | 论坛 | 博客
  • 博客访问: 598975
  • 博文数量: 96
  • 博客积分: 1464
  • 博客等级: 上尉
  • 技术积分: 1539
  • 用 户 组: 普通用户
  • 注册时间: 2011-11-12 23:24
文章分类

全部博文(96)

文章存档

2013年(29)

2012年(53)

2011年(14)

分类: Web开发

2013-05-22 22:51:00

最近要在flex中嵌套jsp页面,网上找了一个比较好的解决方案:flex-iframe
但是,郁闷的是,虽然网上能找到flex中使flex-iframe来插入网页。可是,当面临他们之间的交互时,资料几乎没有。是这个东西太小众了么?···

网上搜,没有,再搜,还没找到,继续搜索,依然没找到解决方案。
是自己技术水平太次,嗯,当前确是一个原因,还是这个问题太简单了,以致所有人都不认为这是一个问题?还是这实在是太小众的技术,还没人遇到这问题···
不管怎么样,问题依然在那里,怎么把这丫的给解决了呢···思考,再思考。

问身边的人吧,得到的提示是:看flex-iframe中的example
啊,什么,脑中一片晕眩。
flex-iframe里还有例子啊,虽说以前下载flex-iframe时,好像是有看到里面有example的包,可是当时只想着怎么把它的类库导进去,却忘了这一茬
古语说的好,出来混迟早是要还的,这不,一个错过看example,导致这个问题头疼了好久。
闲话少说,现在就补上,知错能改,善莫大焉^-^

打开包sources-example,找到CallIFrameFunction,将里面的src文件导入项目,当然只是一个CallIFrameFunction.mxml文件,如下







                xmlns:flexiframe=""
                horizontalAlign="center"
                verticalAlign="middle"
                viewSourceURL="srcview/index.html">


   
   

        import mx.controls.Alert;


        /**
         * Call the 'showAlert()' JavaScript method.
         */
        private function callShowAlert():void
        {
            iFrameWithJSfunctions.callIFrameFunction('showAlert');
        }


        /**
         * Call the 'showAlertWithParameter()' JavaScript method.
         */
        private function showAlertWithParameter():void
        {
            iFrameWithJSfunctions.callIFrameFunction('showAlertWithParameter', [ 'flex-iframe o//' ]);
        }


        /**
         * Call the 'getCurrentDate()' JavaScript method.
         */
        private function callGetCurrentDate():void
        {
            iFrameWithJSfunctions.callIFrameFunction('getCurrentDate',null,handleGetCurrentDateResult);
        }


        /**
         * Handle the 'getCurrentDate()' JavaScript method result.
         */
        private function handleGetCurrentDateResult(result : Object):void
        {
            Alert.show("The 'getCurrentDate()' method returned '" + result + "'.");
        }


    ]]>
   




   
   
       
            flex-iframe - callIFrameFunction() example
This example shows how to use the callIFrameFunction() method.]]>

       

   



   
                           label="Map"
                       source="pageWithJSfunctions.html"
                       width="400"
                       height="120"
                       overlayDetection="true" />


   
                 width="400">
                           label="call 'showAlert()'"
                   width="100%"/>
                           label="call 'showAlertWithParameter()'"
                   width="100%"/>
                           label="call 'callGetCurrentDate()'"
                   width="100%"/>
   





然后,再把html-template中的文件复制到项目中,当然,关键的是一个pageWithJSfunctions.html网页了,代码如下


 
   
 
 
   
    This is a web page with Javascript functions embedded.

    Click "View source to view the Javascript functions.
 


ok,运行CallIFrameFunction.mxml文件,再看代码,一切是那么清楚,我都不好意思再说什么了,只能感谢开发这些代码的大神···



阅读(6637) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~