Flash(ActionScript3.0)で、swf起動時にhtmlから引数を渡す

Flashで、swf起動時にhtmlから引数を渡すには以下のようにします。(ActionScript3用)

html側で

<param name="FlashVars" value="hoge=1&fuga=2">
<embed src="hoge.swf" FlashVars="hoge=1&fuga=2" />

Flash側では

var flashVars:Object = this.loaderInfo.parameters;
var hoge:String = flashVars['hoge'];

// traceで確認
trace(hoge);

// javascriptのalertで確認
import flash.external.ExternalInterface;
ExternalInterface.call("function(){ javascript:alert('" + hoge + "'); }");

参考:http://yakinikunotare.boo.jp/orebase/index.php?Flash%2Fswf%A4%CB%A5%D1%A5%E9%A5%E1%A1%BC%A5%BF%A1%CA%B0%FA%BF%F4%A1%CB%A4%F2%CD%BF%A4%A8%A4%EB

関連エントリー

No.672

03/02 14:15


ActionScript3.0




Powered By flat memo Ver 0.9.6.2 © econosys system