将变量从HTML传递给Class

时间:2011-05-17 03:59:54

标签: html flash actionscript-3 class variables

我想将一些图像名称和数字作为字符串传递给我的flash,所以在html文件中我有:

src="imgvid-00.swf?imageData=image00/00.gif,3,image00/01.gif,6,image00/02.gif,10"

在flash swf我有这样一个类:

package src{
    import flash.display.*;
    import flash....

    public class imgvid extends MovieClip {
        public var dataBANK:Array = new Array();        

        public function imgvid():void {
            //put all var in Array dataBANK     
        }
    }
}

我是怎么做到的? 我尝试: public var paramObj = this.loaderInfo.parameters; 但这不起作用......

1 个答案:

答案 0 :(得分:1)

你需要将参数传递给flashvars。查询参数不会以您的示例中的方式传递到Flash中。阅读flashvars:

http://kb2.adobe.com/cps/164/tn_16417.html

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="550" height="400" id="myFlashMovie" align="middle">
    <param name="movie" value="myFlashMovie.swf" />
    <param name=FlashVars value="myVariable=Hello%20World&mySecondVariable=Goodbye">
    <!--[if !IE]>-->
    <object type="application/x-shockwave-flash" data="myFlashMovie.swf" width="550" height="400">
        <param name="movie" value="myFlashMovie.swf" />
        <param name=FlashVars value="myVariable=Hello%20World&mySecondVariable=Goodbye">
    <!--<![endif]-->
        <a href="http://www.adobe.com/go/getflash">
            <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
        </a>
    <!--[if !IE]>-->
    </object>
    <!--<![endif]-->
</object>

使用swf对象完成所有这些操作比上面手动操作更容易

http://code.google.com/p/swfobject/