无法将flashvars传递给flex生成的swf

时间:2011-07-13 17:31:52

标签: flash flex flashvars

无法将flashvars传递给flex生成的swf              

        import com.rubenswieringa.interactivemindmap.*;

        private var fullscreenListenerAdded:Boolean = false;

        private function onCreationComplete ():void {
            Controller.boot(this.springGraph, "assets/mindmap.xml");
            Security.allowDomain("dual99.com");
        }

        private function fullscreen (event:Event=null):void {
            if(!this.fullscreenListenerAdded){
                this.fullscreenListenerAdded = true;
                Application.application.stage.addEventListener(Event.FULLSCREEN, this.onFullscreen);
            }
            Application.application.stage.displayState = StageDisplayState.FULL_SCREEN;
        }

        private function onFullscreen (event:Event):void {
            this.fullscreenButton.visible = (Application.application.stage.displayState == StageDisplayState.NORMAL);
        }
        // Declare bindable properties in Application scope.
        [Bindable]
        public var myName:String;
        [Bindable]
        public var myHometown:String;

        // Assign values to new properties.
        private function initVars():void {
        myName = Application.application.parameters.myName;
        myHometown = Application.application.parameters.myHometown;
        }

    ]]>
</mx:Script>

这是在html中

<script type="text/javascript">
    // <![CDATA[

    var so = new SWFObject("flash.swf", "flasher", "100%", "100%", "9", "#FFFFFF");
    so.addParam("allowFullScreen", "true");
    so.addVariable("myName","samvirtual");
    so.addVariable("myHometown","canton");
    so.write("flashcontent");

    // ]]>
</script>

2 个答案:

答案 0 :(得分:2)

我的猜测是你过早地调用initVars。尝试将其添加到创建完成处理程序:

private function onCreationComplete ():void {
   Controller.boot(this.springGraph, "assets/mindmap.xml");
   Security.allowDomain("dual99.com");
   myName = Application.application.parameters.myName;
   myHometown = Application.application.parameters.myHometown;
}

答案 1 :(得分:0)

尝试使用

private function initVars():void {        
  var paramObj:Object = LoaderInfo(root.loaderInfo).parameters;
  myName = paramObj.myName;
  myHometown = paramObj.myHometown;
}