我可以通过使用ActionScript 3.0的参数和外部瑞士法郎?瑞士法郎、可以通过、参数、ActionScript

2023-09-09 21:57:53 作者:微笑dě眼泪℡

我有我使用加载的三场比赛序列的主FLA文件。如果用户赢得了比赛,他们继续到下一场比赛。它是在任何可能的方式传递给主项目的用户是否已经赢得了比赛?我已经使用loader.content尝试过,但似乎并不奏效。我使用Flash CS3。

I have a main .fla file that I am using to load a sequence of three games. If the user wins a game, they go on to the next game. Is it in any way possible to pass to the main project whether the user has won the game? I have tried using loader.content, but that does not seem to be working. I am using Flash CS3.

推荐答案

您可以传递数据和从下载的SWF没有问题。这听起来像你正在试图做的是从所加载的SWF到加载SWF沟通。理想的方式做,这是调度事件上加载的SWF和加载SWF听吧。粗略地(没有测试它,因为我是在赶时间),你需要这样的事情。加载瑞士法郎。有一个负载完整的处理程序。获取加载的内容,并听取自定义事件。你可以通过这个自定义事件无论你想要的。

You can pass data to and from loaded swfs no problem. What it sounds like you are trying to do is communicate from the loaded swf to the loading swf. The ideal way to do this is to dispatch an event on the loaded swf and listen for it in the loading swf. Roughly (not tested it because i'm in a rush) you need something like this. Load the swf. Have a load complete handler. Get the content of the loader and listen to a custom event. You can pass whatever you want on this custom event.

var myLoader:Loader = new Loader(); 
var url:URLRequest = new URLRequest("myExternalMovie.swf"); 
myLoader.load(url);
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, function(event : Event)
{
    var contenet : MovieClip = event.target.content;
    content.addEventListener(yourGameEvent.GAME_COMPLETE, yourGameEventHandler);

}

如果您从未使用自定义事件之前,检查此链接(或谷歌更多)

If you've never used custom events before check this link (or google for more)

http://www.adobe.com/devnet/flash/articles/ creating_events.html

作为一个声明那的快捷方式来获取数据到你的主类。我个人不传送数据的事件,一个巨大的风扇。我宁愿触发一个空的事件,并从发射对象的属性获取数据)...但是这只是一个个人的preference。

As a disclaimer thats the quick way to get the data into you main class. Personally i'm not a massive fan of passing data in events. I'd rather fire a empty event and the get data from properties of the firing object)... but that's just a personal preference.