六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 158|回复: 0

HTML页面中内嵌的flash应用的传参方法

[复制链接]

升级  32.8%

208

主题

208

主题

208

主题

进士

Rank: 4

积分
664
 楼主| 发表于 2013-2-7 20:14:49 | 显示全部楼层 |阅读模式
How to pass data to a Flex application using SWFObject 2.0
http://cookbooks.adobe.com/index.cfm?event=showdetails&postId=15806
【Flex 应用】
package com.palleas{  import mx.controls.TextArea;  import mx.events.FlexEvent;    import spark.components.Application;    public class Facade extends Application  {    protected var logBox:TextArea;        public function Facade()    {      super();      logBox = new TextArea();      logBox.width = 500;      logBox.height = 300;      addEventListener(FlexEvent.CREATION_COMPLETE, creationCompleteHandler);    }        protected function creationCompleteHandler(e:FlexEvent):void    {      removeEventListener(FlexEvent.CREATION_COMPLETE, creationCompleteHandler);      addElement(logBox);      parseParameters();    }        /**    * This method display the name and the value    * of every parameters passed to the Flex Application    */    protected function parseParameters():void    {      logBox.text = "";      var currentParamIndex:uint = 1;      for(var parameterName:String in parameters)      {        logBox.text += "Parameter #"+currentParamIndex + ": ";        logBox.text += parameterName + " " + parameters[parameterName] + "\n";        currentParamIndex++;      }    }  }}
【内嵌的html页面】
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr"><head>  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />  <title>Load some parameters</title></head><body>  <div id="componentBox">    <!-- alternate content -->    <p>Woops, it seems you don't have Flash player installed, shame on you! ;-)  </div>    <script type="text/javascript" src="js/swfobject/swfobject.js"></script>  <script type="text/javascript">  window.onload = function()  {    var params = {      cookbook : "Flex",      author : "Romain 'Palleas' Pouclet",      version : "1.0",      website : "http://www.adobe.com",      air : "best technology ever!"    }    /*    * Loading a SWF to my webpage    * parameter #1 is the path to the SWF I want to load    * parameter #2 is the id of the HTML container (here it's a div containing alternative content (in case Flash in not installed     * or javascript is not activated    * parameters #3 and #4 are the dimension of the application (here 500px x 500px)    * parameter #4 is the required version to make the application work    * parameter #5 is path to the express installer (it will install flash)    * parameter #6 is an anonymous object containing my parameters    */    swfobject.embedSWF("Parameters.swf","componentBox","500","500","9.0.0","js/swfobject/expressInstall.swf", params);  }  </script></body></html>
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表