How to connect WordPress and Flash – part #2

Finally, part 2 of this tutorial is here. Part 1 can be seen HERE. There you can find out how to prepare and format data for Flash and now we are about to do something with it. I’ve made a package of all required files for download so you can see what else will be used. Please download ZIP, unpack and open WP_flash.fla. Code is well commented and I am not about to explain how and why. This is just an example of my own implementation, you may develop your own and display data differently in Flash. My goal was to demonstrate WP – Flash data exchange on the simplest possible way.

How to use it?

Just for demo purpose upload all the files (and ’script’ folder as well!) to the root of your theme, it doesn’t matter which one. Now you need to call ‘WP_flash_holder.php’ in Browser but full path to this file must be used because we are currently out of WP ‘native environment’:
http://yourdomain.com/wp-content/themes/your_theme_name/WP_flash_holder.php.
For a case you are about to include WP_flash.swf in any existing template file of your theme (for example sidebar.php), things will work normally.

NOTE:

Open WP_flash_holder.php and change path to match your domain and theme name otherwise it’ll not work. For example the line reading:


<script src="http://your_domain.com/wp-content/themes/your_theme_name/script/swfobject.js" type="text/javascript"></script>

As well as:


var so = new SWFObject( "http://your_domain.com/wp-content/themes/your_theme_name/WP_flash.swf", "wpflash", "550", "400", "8" );

…must be replaced with your own data!

Files in package…

  • slidestyle.css
    Flash Player supports a subset of properties in the original CSS1 specification only so basic text formatting can be done here. Not much but enough for this tutorial.
  • WP_flash_holder.php
    This file is here just to properly include/embed Flash file into HTML page. In source code you can read how to include Flash in native WordPress environment (for example sidebar.php).
  • script > swfobject.js
    As already mentioned, swf must be properly embed so this is nothing but a piece of javascript code required to avoid page errors and Browser warnings.
  • WP_flash.fla and WP_flash.swf
    Source and rendered file used for demonstration purpose.

It’s good to know

I guess some of you already plan to make a first Flash theme so it’s good to know that each and every WP theme must fulfill minimum requirements. Theme folder MUST contain the following files: index.php, style.css and functions.php (screenshot.png). In that case you can keep all of your Flash styles in style.css and embed Flash into index.php. Remember, it’s a long way to develop Flash theme and this tutorial is just a little tiny foot step on the long path up to the hill. Enjoy!

Share with others...

deliciousdiggreddittechnoratifacebooktwittergoogleyahoowikioblinklistsimpyspurl
Comments (5)

Track comments via RSS 2.0 feed. Feel free to post the comment, or trackback from your web site.

  • jlo on Jul 9, 2009

    is there and easy way to specify which category the php file pulls from in word press? I have tried looking up the category ID but that seems to not work or if i specify the direct name of the category

  • Feeleep on Jul 9, 2009

    You must definitely know category ID if you are about to pull posts from certain category. So the query_posts() call should read something like

    
    query_posts( 'showposts=' . $num_of_posts_to_display . '&post_type=post&post_status=publish&order=DESC&cat=YOUR_CAT_ID' );
    
    

    Dont forget to replace YOUR_CAT_ID with numeric value! For more information please refer to http://codex.wordpress.org/Template_Tags/query_posts. Hopefully it helps!

  • André Beltrame on Jul 20, 2009

    Great tutorial…
    im waiting now the next.. wordpress is a best cms for me… this integration is perfect… many thanks for it!

  • chris on Mar 9, 2010

    Hi,
    I want to locate my swf file in the root of my wordpress blog not in the template dir.

    But for some reason, i keep getting errors in flash when i try to call the “slide_serve.php” from anywhere outside the template dir. Does the swf have to live in the same dir as the slide_serve.php file to get access?

    Any help would be much appreciated!

    Thanks,
    Chris

  • Feeleep on Mar 10, 2010

    Yeap, ’slide_serve.php’ by default MUST share location with Flash file (SWF) which checks its own path in file system on server – according to which PHP file is found.

    However, if you take a look at FLA, line number 53 which reads:

    
    extXML.load( myloc + "/slide_serve.php" );
    
    

    …you can easily change location/path to ’slide_serve.php’ manually.
    Hopefully it helps!

Leave a Comment

Latest comment by Feeleep

Yeap, 'slide_serve.php' by default MUST share location with Flash file (SWF) which checks its own path in file system on server - according to which PHP file is found. However, if you take a look at FLA, line number 53 which reads:


extXML.load( myloc + "/slide_serve.php" );

...you can easily change location/path to 'slide_serve.php' manually. Hopefully it helps!

Search

Advertisement

GraphicRiver ThemeForest