从一个SWF通过VAR值,是谁在AS3的firts人在里面加载另一个SWF [英] pass var values from one swf to another swf who is loaded inside the firts one in AS3

查看:121
本文介绍了从一个SWF通过VAR值,是谁在AS3的firts人在里面加载另一个SWF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即时通讯使用这种方法来加载在另一个SWF的SWF: (此code里面的main.swf)

im using this method to load an SWF inside another SWF: (this code is inside main.swf)

function loadImage(url:String):void {
imageLoader = new Loader();
imageLoader.load(new URLRequest(url));
imageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, imageLoading);
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
}
loadImage("test1.swf");

function imageLoaded(e:Event):void {
MyMovieClip.addChild(imageLoader); 
} 

本想这是test1.swf需要的值是谁在装载机瑞士法郎(main.swf中),我怎么能传递价值?谢谢!

The think is the test1.swf needs a value who is in the loader swf (main.swf), how can i pass the value? Thanks!

推荐答案

您可以创建一个类加载的SWF(test1.swf),你可以用文件类分配。

You could create a class for the loaded SWF ( test1.swf ) which you can assign with the Document class.

在这个类来创建一个setter你需要传递给加载的SWF中的值。

In this class create a setter for the values you need to pass to the loaded SWF.

   //Here the choice of Array is arbitrary & depends on what values
   //you need to pass to the SWF...
   private var _params:Array;
   public function set params( value:Array ):void
   {
      _params = value;
   }

然后在你的主类,你可以做到以下几点:

Then in your Main class, you can do the following:

  //Assuming you'd like to pass a number of values...
  function imageLoaded(e:Event):void {

      var content:MovieClip = imageLoader.content as CustomClass;
      content.params = [ value1 , value2... valueN];
      MyMovieClip.addChild(content);
  } 

这篇关于从一个SWF通过VAR值,是谁在AS3的firts人在里面加载另一个SWF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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