Categories Displayed in Flash

WordPress + GoogleCode’s SVN = FlashTextEditor + FlashVars + PHPProxy

Been looking for a way to get the actionscript code in SVN, onto the blog, nicely formatted, colorized, with eventually smart help and highlighting. So the blog and upcoming wiki can 'decorate' it. Finally figured it out.

I use Google Code SVN as it's free, and solid. To get it work with Wordpress a with the plugins 1)pb-embedFlash and 2) FlashTextEditor. through PHP Proxy for Flash Cross-Domain Security problems

Strictly speaking, 1) isn't required but the syntax is cleaner than using 2) directly. A sample post in wordpress looks like

[flash http://troyworks.com/blog/wp-content/plugins/FlashTextFormatter/ftf.swf f={file= http://troyworks.googlecode.com/svn-history/r7/trunk/AS3/dev/src/com/troyworks/ui/LayoutUtil.as} ]

Where f={} is the passing of the flashvars with the proxy and actionscript file name. I had to make a patch to the pb-embedFlash.php to pass flashvars...though honestly I'd prefer to be using SWFObject instead. Here's a snippet of the patch :

  1.  
  2.  } else { // not a flv file - what may it be?
  3.  
  4.        $i = 0; global $pb_embedflash;  if (preg_match('%f={(.+?)}%',$match[2],$hit) && $hit[1] != ' ') {
  5.  
  6.                $flashvars = '?'.$hit[1];
  7.  
  8.        }
  9.  
  10.  while (isset($pb_embedflash[$i][0])) // search for YouTube, Google Video, etc.
  11.  
  12.        {
  13.  
  14.                if (preg_match(pb_buildpattern($pb_embedflash[$i][0]),$match[1],$hit) && (count($pb_embedflash[$i]) == 5))
  15.  
  16.                {
  17.  
  18.                        $output = str_replace('###URL###', str_replace('###ID###', $hit[1], $pb_embedflash[$i][1]), $output);
  19.  
  20.                        $output = str_replace('###WIDTH###', $pb_embedflash[$i][2], $output);
  21.  
  22.                        $output = str_replace('###HEIGHT###', $pb_embedflash[$i][3], $output);
  23.  
  24.                        $break = TRUE; break 1; // stop searching if we found sth.
  25.  
  26.                }
  27.  
  28.                $i++; // we don't want an infinite loop ;)
  29.  
  30.        }
  31.  
  32. if (!isset($break)) // seems to be a normal swf or an unknown video hoster
  33.  
  34.        {
  35.  
  36.                $output = str_replace('###URL###', $match[1].$flashvars, $output);
  37.  
  38.        }
  39.  
  40. }

and also had to add a whitespace trim() to the FlashTextEditor, as for whatever reason the flash vars are getting passed in with an extra space in the front (I don't know PHP so I'm probably doing something), which causes it to fail.

Since my framework will be up on google, and I check in via SVN it's a sound development practice to make sure the latest code that shows up on the blog is that from SVN, instead of being cut and pasted here or uploaded to the webserver. Unfortunately, Google doesn't have a cross domain file in place so loading the text isn't possible directly, thus the need for PHP Proxy.

Here's an example of getting LayoutUtil.as from Google Code.

(Either JavaScript is not active or you are using an old version of Adobe Flash Player. Please install the newest Flash Player.)

What I'd like to do in the future as examples start coming out is highlighting selected lines + folding, and automatic linking to the adobe docs, making it more of a wiki. Probably will be a rewrite of FlashTextEditor.

If your contributing to this blog use the following tips:

All these require editing on the 'code' tab (not 'visual' tab) when writing a post.  When embedding classes examples that are on google SVN use this

You can upload and then embed flash examples via:

(Either JavaScript is not active or you are using an old version of Adobe Flash Player. Please install the newest Flash Player.)

and use this flash based editor for pulling code off of google

(Either JavaScript is not active or you are using an old version of Adobe Flash Player. Please install the newest Flash Player.)

and pretty format it via:

<pre lang="actionscript">
YOUR CODE
</pre>

but you'll need an return before the first pre

2) You can make small blocks like

"In order to print, You will need to listen for <code> addListener</code>"

Add a Comment: