pass var values from one swf to another swf who is loaded inside the firts one in AS3

后端 未结 2 1909
自闭症患者
自闭症患者 2021-01-24 01:47

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();
imageLoa         


        
2条回答
  •  感动是毒
    2021-01-24 02:24

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

    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);
      } 
    

提交回复
热议问题