Welcome, Guest
  • Author Topic: How to initialize the variable in flex with the variable from flash AS3?..  (Read 1937 times)

    hinomotoblade

    • Seasoned Programmer
    • ***
    • Posts: 131
    • Flash Never Die :D
      • View Profile
    Hello i have the problem here,

    For exmaple i have some mxml Application, and i have the variable name "A",
    then i try to load my flash that containt variable inside the flash thats call the name "B"
    with the SWFLoader..

    nah can i initialize the "A" with "B"?..

    I mean in my AS3 Flash i have B=10;

    Then i have the variable in my mxml App is A=0;

    How to make the A=B?..

    Thank you very much.. I am really confuse aboout this because i am still like combine mxml with flash,
    because flash is more interactive about the animation and another..

    Thank you :)

    Huihihi~ :D

    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    you have to fetch some events.

    Before you can access a value of an object, you have to wait for the object to be completed.
    If the object is completed, it can fire a user defined event, or call a function to initialize.

    In flash you can do the initialize into the first frame - just make sure, it will not be touched after it initialized first ;)

    With flex components you can define a creationComplete_handler, which will be executed, when the component is ready to use.
    happy flashing
    8)
    Ronald

    hinomotoblade

    • Seasoned Programmer
    • ***
    • Posts: 131
    • Flash Never Die :D
      • View Profile
    Ummm, can you give me some example?..

    Sry i am confused.. :p

    I mean how to make the function / method to initialize the variable in my SWF Loader (External As3) to the variable in my mxml application,

    For example like this,

    In mxml i have some textArea id="B"..
    Then in flash i have the variable A="Heheheh i am from Flash :D";
    Then in my flash i have a button, if i clicked that it will control/initialize the textArea id="B" with
    the variable "A" from flash in my mxml..

    The summary is, how to control method/object/state/whatever in flex with external flash(.swf) which
    we place that in SWFLoader in mxml.. :)

    Nah in mxml we can adjust the textArea id="B" just like this : B.text = "Blahblahblah";

    Now how to make the interaction with flash and flex?..

    I am sry, i cant do anything about this, its really stuck here.. :)

    Thank you very much :)

    « Last Edit: 03/14/10, 19:53 by hinomotoblade »
    Huihihi~ :D

    hinomotoblade

    • Seasoned Programmer
    • ***
    • Posts: 131
    • Flash Never Die :D
      • View Profile
    Huihihi~ :D

    mark40

    • Server what's that
    • *
    • Posts: 1
      • View Profile
      • Email
    The code on the page does not work you need to download the source file in order to get a propper code. 
    The Greeter.as is ok, but the .fla file is : 
    (type this code in the actions layer - if you have one - or in the first keyframe of your fla timeline - if you decided to write the code in the same layer and keyframe with your text field) 
     
    /*You need to have your Greeter.as file in a folder named quickstart that is in a folder named example that is in a folder named com that is in the folder with your fla file ... or you can simply remove "com.example.quickstart. " from both the Greeter.as and the HelloWorld.fla code.*/ 
     
    import com.example.quickstart.Greeter; 
     
    // Create a Greeter instance with the initial name "Steve" 
    var myGreeter:Greeter = new Greeter("Steve"); 
    // Say hello to Steve 
    var steveGreeting:String = myGreeter.sayHello(); 
    output.text = steveGreeting; 
    // Move the cursor to the next line 
    output.appendText("\n"); 
    // Set the Greeter instance's name to "Harold" 
    myGreeter.name = "Harold"; 
    // Say hello to Harold 
    var haroldGreeting:String = myGreeter.sayHello(); 
    output.appendText(haroldGreeting); 
    mark
    mcse