Professional Web Applications Themes

php to flash - Macromedia Flash Data Integration

I have a dynamic text instance in Flash named dynamic_txt and I want it to display information from a php file. What command allows me to do this? Here is the code: PHP <?php print "dynamo_txt=DYNAMIC"; ?> ActionScript (2.0) var my_lv:LoadVars = new LoadVars(); my_lv.onLoad = function(success:Boolean) { if (success) { //HERE IS WHERE I WANT THE COMMAND THAT WILL ALLOW DYNAMO_TXT TO DISPLAY THE STRING //FROM THE PHP FILE }; my_lv.load("cars.php");...

  1. #1

    Default php to flash

    I have a dynamic text instance in Flash named dynamic_txt and I want it to
    display information from a php file. What command allows me to do this? Here
    is the code:

    PHP

    <?php

    print "dynamo_txt=DYNAMIC";

    ?>

    ActionScript (2.0)

    var my_lv:LoadVars = new LoadVars();
    my_lv.onLoad = function(success:Boolean) {
    if (success) {
    //HERE IS WHERE I WANT THE COMMAND THAT WILL ALLOW DYNAMO_TXT TO DISPLAY THE
    STRING //FROM THE PHP FILE
    };
    my_lv.load("cars.php");



    budd101 Guest

  2. #2

    Default Re: php to flash

    Read my threads - you use LoadVars and put value-pairs into an array.

    Unfortunately, it was answered in AS 1.0/2.0 forum, not here so perhaps you
    didn't find it.

    //sqlcache
    /* fyi you can always create some valid test data locally by doing something
    like this:
    var mytest:LoadVars=new LoadVars();
    mytest.keyword10="keyword1"
    mytest.keyword11="organelle"
    mytest.keyword12="photosynthesis"
    mytest.keyword13="digestion"
    mytest.keyword14=""
    mytest.keyword15=""
    trace(mytest.toString())
    */

    var my_lv:LoadVars = new LoadVars();

    my_lv.onLoad = function (success:Boolean):Void {
    if (success) {

    //assuming _global.keywords is already defined as an array:
    //assuming _global.keywords might already have some keywords in it (otherwise
    this could be simpler)
    //create a temporary array:
    var tmpkeywords:Array =[];
    // Iterate over properties in my_lv
    for (var prop in my_lv) {

    if (typeof(my_lv[prop])=="string"){
    tmpkeywords.push(my_lv[prop]);

    }

    }
    trace("loaded in this order:"+tmpkeywords); //it is reversed, so:
    tmpkeywords.reverse(); //turn it around
    trace("reversed:"+tmpkeywords);
    //now assuming that the _global.keywords is already an array with some
    words... and we want to
    //add to the end:
    //the following 'function.apply' method lets the 'push' method take the
    elements of tempwords as an array an adds them individually
    _global.keywords.push.apply(_global.keywords,tmpke ywords);
    trace("global keywords now has:"+_global.keywords)


    } else {
    trace("Unable to load external file.");
    }
    }

    //make _global.keywords an array for testing:
    _global.keywords=["hello","world"];
    trace("global keywords starts with:"+_global.keywords)

    my_lv.load("sqlcache.txt");
    //sqlcache.txt

    GWD
    User is offline
    View Profile

    Senior Member Posts: 1927
    Joined: 06/24/2002
    Send Private Message
    03/11/2008 05:30:13 AM
    Reply | Quote | Top | Bottom

    You wouldn't usually want to or need to load the same data in twice.
    I checked the link to your swf and I couldn't see it attempting to load any
    external data via http activity. So I don't think this code is running in your
    full swf (or perhaps it's only after signing in etc?)
    Also, LoadVars automatically calls its own decode method by default, so you do
    not need to use 'decode' in the onLoad handler.

    Here's something which might help. Hopefully the comments etc, explain a
    little bit. The function.apply line is probably the one that might be a little
    difficult to comprehend. Its only there as a quick way to append the values to
    the _global.keywords array (assuming that you want append them).



    MYSCREENNAMEISUNAVAILABLE Guest

  3. #3

    Default Re: php to flash

    any insight in going the other way - from flash to php? - see my other post
    MYSCREENNAMEISUNAVAILABLE Guest

Similar Threads

  1. Replies: 21
    Last Post: March 24th, 07:45 PM
  2. Replies: 3
    Last Post: March 24th, 11:37 AM
  3. Replies: 5
    Last Post: May 26th, 01:46 AM
  4. convert all flash site to both flash and no flash
    By Terry Richards in forum Macromedia Flash Sitedesign
    Replies: 1
    Last Post: January 26th, 07:35 AM
  5. Send data to Flash from a page without reloading the flash file
    By PoPsork webforumsuser@macromedia.com in forum Macromedia Flash Sitedesign
    Replies: 1
    Last Post: August 24th, 08:12 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139