A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: external PHP to Flash

  1. #1
    Junior Member
    Join Date
    Oct 2004
    Posts
    20

    external PHP to Flash

    How can I load php to Flash

    This is what I have:

    I created a Dynamic Text field with a variable name "Status".

    PHP Code:

    Sample Script:

    <?php

    // ---- How can I insert this message into the Status Variable in Flash
    Do I need loadVariablesNum;


    PRINT "Welcome to FlashKit.com";

    ?>

  2. #2
    Member
    Join Date
    Dec 2004
    Posts
    68
    Unfortunately it's usually not that easy as I just found out.

    It depends on what you are trying to do. If you are just trying to get some information back and forth between Flash and PHP then you can user loadVariablesNum if you are more comfortable with it, but what I have found out is that the information received can only be reliably received without a loading sequence if it is placed in a text field. The code for this would be:

    Code:
    loadVariablesNum("mypage.php", 0);
    and then in php you could have something like:
    Code:
    <?
      $message = "&message=blah blah blah";
      echo $message;
    ?>
    you must use the &message= part because this is how Flash reads variables. By setting the textfield varaible to message, once "message" is received in full from PHP, it will be automatically placed in the text field.

    Otherwise, if you need to know when it is loaded before doing something, use the following code:
    Code:
    <?
    $message = "&message=blah blah blah";
    echo $message;
    ?>
    Code:
    stop();
    
    myVars = new LoadVars();
    myVars.load("test.php");
    
    myVars.onLoad = function(success)
    {
    	if(success)
    	{
    		trace(this.message);
    		trace(this.getBytesTotal());
    		trace(this.getBytesLoaded());
    		message.text = this.message;
    	}
    	else
    	{
    		trace("error.");
    	}
    }
    the benefit of making a LoadVars Object is that you have access to a lot of methods such as getBytesTotal/Loaded in order to see if it's done as well as onData and onLoad. Only problem is that it takes a while to get a grasp on it and become comfortable with LoadVars instead of loadVariablesNum.

  3. #3
    Junior Member
    Join Date
    Oct 2004
    Posts
    20
    Thanks stryker52
    Good Explanation

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