A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: AS2/CS4: ExternalInterface passing Variable

  1. #1
    Junior Member
    Join Date
    Feb 2010
    Posts
    12

    AS2/CS4: ExternalInterface passing Variable

    hi there,
    maybe it is a simple question, but it took me allready 3 hours to try several ways and none work. so i am looking around for help, read many threats and tried many ways ...

    i send variables to flash inside the html document:
    Code:
     ... value="name.swf?myname=<?php echo $myname; ?>&myhobby=<?php echo $myhobby; ?>" />
    inside flash i can print the variables as dynamic text, its working fine. but now i want to use one of this variables to be sent inside a "ExternalInterface.call" after pressing a button.

    Here is my code, but i failed:

    Code:
    import flash.external.* 
    ExternalInterface.call('getdata','content.php?myname='+myname+'&detail='+myhobby+'' ,'content');
    stop();
    (getdata loads content.php inside a div with id="content" - Script works fine in all ways, even with flash. so the code above works now without variable variables)

    i played around with '+...+' linke this:

    Code:
    import flash.external.* 
    ExternalInterface.call('getdata','content.php?myname="+myname+"&detail="+myhobby+"' ,'content');
    stop();
    i tried many ways, but nothing works. i realy wonder how i can pass my variables ...

    is there anyone who could tell me how to set the variables in the right way? in another forum they said its not possible ... ??
    Last edited by whatchagonnado; 03-04-2010 at 06:27 PM. Reason: explain getdata

  2. #2
    Junior Member
    Join Date
    Feb 2010
    Posts
    12
    in a more eazy way:

    this movie is called about 6 times on the website. each time this variable change and the button inside calls the ExternalInterface Action. it works fine .. but how to change this:

    Code:
    ExternalInterface.call('getdata','content.php?myname=MARCUS&detail=PAINTER' ,'content');

    into kind of

    Code:
    ExternalInterface.call('getdata','content.php?myname='+myname+'&detail='+myhobby+'' ,'content');
    the variables are available in flash, but how to write it in the correct way? ;o(((
    Last edited by whatchagonnado; 03-04-2010 at 06:27 PM.

  3. #3
    Junior Member
    Join Date
    Feb 2010
    Posts
    12
    hi,

    i finally found out that i can use my variables for dynamic textfields, but no matter what i try in flash, it seems my variables dont work the right way.

    even this dont work:
    Code:
    if (myname=="THOMAS") {
    	stop();
    }

    can anyone tell me what i have to do inside flash to make my variables work inside AS? they show up on the textfield, but AS dont react.

    maybe anyone knows a good link or tutorial so i can understand how to eazily play with my variables inside flash ? i am little bit confused about this ... ;(

  4. #4
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,876
    the if statement should work if myname contains the correct value:

    try putting a trace to see what the variable contains:

    trace("my name is " + myname + " and the length is " + myname.length)
    if (myname=="THOMAS") {
    stop();
    }
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  5. #5
    Junior Member
    Join Date
    Feb 2010
    Posts
    12
    Actionscript Code:
    import flash.external.*

    that was the problem. i had this code, but not on main timeline. now it is working, thank you !!!

  6. #6
    Junior Member
    Join Date
    Feb 2010
    Posts
    12
    thank you silentweed!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center