WordPress.org

Ready to get started?Download WordPress

Forums

WordPress PHP code in Flash (6 posts)

  1. tripleX2k7
    Member
    Posted 6 years ago #

    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

  2. whooami
    Member
    Posted 6 years ago #

    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.

  3. tripleX2k7
    Member
    Posted 6 years ago #

    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("http://localhost/testing/date.php");
    
    addressVars.onLoad = function() {
    
    _root.theDate = "The PHP date is 
    
    "+addressVars.theDate;
    
    }
    
    }

    Thank you for your quick response

  4. tripleX2k7
    Member
    Posted 6 years ago #

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

  5. tripleX2k7
    Member
    Posted 6 years ago #

    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("http://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!

  6. xtool
    Member
    Posted 6 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags