• Hi

    I am wanting to have a small Flash unit on my static home page displaying the latest posts. I have looked around for solutions but they all seem to be focusing on an entire WordPress-powered Flash site which isn’t what I’m after. Does anyone know how I can use my existing php code in Flash?

    Thanks very much

Viewing 5 replies - 1 through 5 (of 5 total)
  • Do you know how to write actionscript? Thats the most important follow-up question.

    study up on how to use php, mysql, and flash together — thats really all you need to do.

    that or you can grab the data, drop it into an xml file, and display that.

    I could code up a simple flash object that accomplished what you want, but not for free, and Im not going to walk someone else through the process on these forums, sorry, as it’s really beyond the scope of a simple reply.

    Thread Starter triplex2k7

    (@triplex2k7)

    Ok, I have managed to write the code for the swf to get the current php date, because I thought that would be an easier place to start. I will continue to try to integrate the WP template tags into the php which is fed to Flash. This is the code I am using at the moment:

    In my PHP file:

    <?php
    $theDate = date('l jS F Y');  ;
    
    $passIn = "" ;
    $passIn .= "theDate=" . $theDate . "" ;
    
    echo $passIn ;
    ?>

    and in my actionscript:

    onEnterFrame = function() {
    
    addressVars = new LoadVars();
    	addressVars.load("https://localhost/testing/date.php");
    
    addressVars.onLoad = function() {
    
    _root.theDate = "The PHP date is 
    
    "+addressVars.theDate;
    
    }
    
    }

    Thank you for your quick response

    Thread Starter triplex2k7

    (@triplex2k7)

    Sorry it didn’t copy correctly, but you can still understand it.

    Thread Starter triplex2k7

    (@triplex2k7)

    Hooray!!!

    I have managed to get somewhere! So far it only displays the title and excerpt but the rest should be straightforward from now on.

    Here is the code in frame 1 of my swf:

    stop();
    
    addressVars = new LoadVars();
    addressVars.load("https://localhost/testing/posts.php");
    
    addressVars.onLoad = function(success) {
    	gotoAndStop(10);
    }

    In frame 10:

    stop();
    
    _root.theTitle0 = addressVars.title0;
    _root.theExcerpt0 = addressVars.excerpt0;

    (theTitle0 and theExcerpt0 are variable names of my two dynamic text boxes)

    And finally, the code in posts.php:

    <?php
    mysql_pconnect ("localhost", "myusername", "mypassword");
    
    mysql_select_db ("wordpress");
    $qResult = mysql_query ("SELECT * FROM wp_posts ORDER BY
         post_date DESC");
    $nRows = mysql_num_rows($qResult);
    $rString ="".$nRows;
    for ($i=0; $i< $nRows; $i++){
    
    $row = mysql_fetch_array($qResult);
    $datetime = strtotime($row['post_date']);
    $rString .="&title".$i."=".$row['post_title'].
    "&"."theTime".$i."=".date(jS." ".F." ".Y.", ".h.":".i."
         ".a,$datetime).
    "&"."link".$i."=".$row['guid'].
    "&"."comments".$i."=".$row['comment_count'].
    "&"."excerpt".$i."=".$row['post_excerpt'].
    "";
    
    }
    echo $rString."&";
    
    ?>

    (That has more code than is necessary as I have not set up Flash to receive anything other than the title and excerpt yet.)

    As I said, this is just a start but I hope it was the hardest part! I will keep this topic marked as unresolved until I have completed what I am trying to do so if anyone has any suggestions I will be very grateful.

    Thanks!

    Hello and I am glad that you’ve troubleshoot your error earlier. I am just curious and wondering how you are progressing. Thank you and many lucks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘WordPress PHP code in Flash’ is closed to new replies.