jeudi 29 décembre 2016

How to pass variables from .fla file to .as file in as3

I have a .fla fine names test.fla and I have this variable in it:

var my_var;

stage.addEventListener(MouseEvent.CLICK, onLoaded);

function onLoaded(e:Event):void
 {
  my_var = "myVariable";
  //trace(my_var);
}

I have a .as file called Main.as.

I want to pass my_var from test.fla to the Main.as.

I will really appreciate, if you can help me in this matter!

It is noticeable that I have used the method mentioned in "Actionscript 3 : pass a variable from the main fla to external as file", but it does not work for me!!!

I wrote in my Main.as:

package 
{
 public class Main extends Sprite 
 {
  public function Main() 
  {
   trace(root.my_var);
  }
 }
}

Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire