路过的FlashVars风格的参数加载的SWF [英] Passing flashvars-style parameters to a loaded SWF

查看:259
本文介绍了路过的FlashVars风格的参数加载的SWF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Flex 3的应用程序(播放器V9)它加载一个动画的SWF(AS3,也播放V9)和需要动态传递给它的已知在运行时的参数的集合。这些是通常通过 Flash变量元素在HTML页面中传递的参数。嵌入的电影访问通过 loaderInfo.parameters 对象,这些参数。

I have a Flex 3 app (player v9) which loads a Flash SWF (AS3, also player v9) and needs to dynamically pass it a collection of parameters which are known at run-time. These are parameters that are normally passed via the flashvars element in an HTML page. The embedded movie accesses these parameters via the loaderInfo.parameters object.

我用的SWFLoader 装载机教学班,在参数扯皮没有成功尝试。

I've tried using SWFLoader and Loader classes with no success in param-passing.

相关细节:

  • 这是一个本地程序,不能依靠查询字符串参数。
  • 在我搞乱设置 loaderInfo.parameters [富] =123从埋入code,但参数似乎从来没有拉闸在嵌入式电影。
  • 在我不能把额外的参数传递机制在嵌入式电影(S),因为它们是由第三方发布的。
  • It's a local program, and cannot rely on query string parameters.
  • I've mucked with setting loaderInfo.parameters["foo"] = "123" from the embedding code, but the parameter never seems to wind up in the embedded movie.
  • I cannot place extra parameter-passing machinery in the embedded movie(s), as they are created by third parties.

推荐答案

通过这项PARAMS的URL不会帮助,因为他们采取了使用JavaScript code。在HTML的包装。 该Flash变量PARAMS使用Application.application.parameters拍摄,所以,你必须在你的情况下,手动设置这些PARAMS。

Passing this params in URL won't help, because they're taken using javascript code in the html-wrapper. The 'flashVars' params are taken using the Application.application.parameters, so, you have to set these params manually in your case.

如果你正在使用的SWFLoader加载另一个应用程序,你应该创建对象,将重新present应用程序加载和应用你所需要的:

If you are using SWFLoader to load another app, you should create the object, that will represent the application loaded and apply all you need:

<mx:Script>
	<![CDATA[
		import mx.managers.SystemManager;
		import mx.controls.Alert;
		import mx.events.FlexEvent;

		private var loadedApp:Application;

		private function onLoadComplete(event:Event):void {
			var smAppLoaded:SystemManager = SystemManager(event.target.content);
			smAppLoaded.addEventListener(FlexEvent.APPLICATION_COMPLETE, onLoadedAppComplete);
		}

		private function onLoadedAppComplete(event:FlexEvent):void {
			try {
				loadedApp = Application(event.target.application);
				if(!loadedApp) throw new Error();

				loadedApp.parameters["param1"] = "value1";
			} catch (e:Error) {
				Alert.show("Failed to get application loaded.", "Error", Alert.OK); 
			}
		}

		private function onLoadError():void {
			Alert.show("Failed to load an application.", "Error", Alert.OK);
		}

	]]>
</mx:Script>

<mx:SWFLoader 
	width="100%" height="100%"
	source="./AppToLoad.swf" 
	complete="onLoadComplete(event)" 
	ioError="onLoadError()" securityError="onLoadError()" />

这篇关于路过的FlashVars风格的参数加载的SWF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆