A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Array PHP into Flash

  1. #1
    Junior Member
    Join Date
    Jun 2010
    Posts
    4

    Array PHP into Flash

    Hi all, I am making a site in php, however the header and menu is all made in flash, its a hybrid site u could say.

    Links and text the menu (flash) must be read from the php file, my question is how to make flash as2 to read this array in php, what to write on each button and where to refer.

    Thanks. =]


    PHP Code:
    get Object 

        [
    query] => Array 
            ( 
            ) 

        [
    pages] => Array 
            ( 
                [
    0] => Array 
                    ( 
                        [
    id] => 
                        
    [language_id] => 
                        
    [menu] => Home 
                    


                [
    1] => Array 
                    ( 
                        [
    id] => 
                        
    [language_id] => 
                        
    [menu] => Products 
                    


             ) 

        [
    c_page] => Array 
            ( 
                [
    id] => 
                
    [language_id] => 
                
    [menu] => %CD%E0%F7%E0%EB%EE 
            




    I thing the action script 2 code maybe you should look like:


    var testLoadVars = new LoadVars();

    testLoadVars.onLoad = function(success){

    if(success){
    trace(testLoadVars.var1);
    trace(testLoadVars.var2);
    }
    else
    trace("error");
    }
    testLoadVars.sendAndLoad("http://localhost/filename.php",testLoadVars,"POST");

    }
    Last edited by wopsreg; 06-25-2010 at 02:24 PM.

  2. #2
    Junior Member
    Join Date
    Jun 2010
    Posts
    4
    I convert PHP code as XML, but does it have no idea what should be the action script code

    PHP Code:
    <?php 
        
    require_once('inc/insert.php');
        
    //    pre($globals->get);
        
        
    $rss '<?xml version="1.0" encoding="windows-1251"?>' "\n";
        
    $rss .= '<rss version="0.91">' "\n";
        
    $rss .= '<menu>' "\n";
        foreach(
    $globals->get->pages as $key => $value) {
            
    $rss .= '<page>' "\n";
            
    $rss .= '<name>' $value['menu'] . '<name>' "\n";
            
    $rss .= '<link>' make_link($value['menu']) . '<link>' "\n";
            
    $rss .= '</page>' "\n";
        }
        
    $rss .= '</menu>' "\n";
        
    $rss .= '</rss>' "\n";
        
        
    header("Content-Type: text/xml");
        echo 
    $rss;

    ?>

  3. #3
    Senior Member
    Join Date
    Apr 2004
    Location
    LA
    Posts
    349
    Sephiroth's serializer is a good lightweight solution.

    AMFPHP is a really useful thing to learn for this kind of thing.

    Or you can serialize into JSON format in PHP 5 using native functions like json_encode and then in your flash client use as3corelib or some other JSON library.
    Write multiplayer games with FlashMOG 0.3.1
    Try the MyPlan Salary Calculator

  4. #4
    Junior Member
    Join Date
    Jun 2010
    Posts
    4
    Thank you very much!

  5. #5
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    first of all, your flash parts should not "read" from the php index page...
    So you can either have
    flash call a separate php page (and possibly use xml, amf or whatnot in the communication) or
    have the main php page sticj values into the swf movies via flashvars

    Musicman

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