FlashTextFormatter with SWFObject (Release 2)

by Josh Tynjala

Last month, I released a patch for the FlashTextFormatter WordPress plugin to use Geoff Stern’s SWFObject script. If you’re unaware, the plugin is designed to color code with a Flash component. It’s pretty cool.

[ftf w=480 h=60]var greeting:String = “Hello, Galaxy!”;[/ftf]

Today, I enhanced it to display the code in plain-text if JavaScript is disabled. I should have done this in the first place, but I wasn’t very familar with WordPress PHP code. After some tinkering around, I got things all fixed up. Grab the plugin and try it out! You can view the source of this page to see the output. It’s pretty standard SWFObject-based code though.

About the Author

Josh Tynjala is an indie game developer, entrepreneur, Flash and Flex mercenary, and bowler hat enthusiast.

Discussion
  1. That’s very nice – what does the code look like on the admin side of things? Is it added automatically?

    Also, my code blocks are code tags with pre tags inside (sometimes), would I be able to customize the output of the text version?

    posted by Geoff on 06.21.2006
  2. In WordPress, you can type your code like this:

    [ftf w=450 h=150]var x:Number = 0;
    
    function doSomething():Void
    {
        callSomethingElse();
    }[/ftf]

    The plugin will remove any html tags (WordPress likes to add extra line breaks and things), and it places the code within pre tags. I should probably use code tags as well, since it’s for code. I believe the only customization options are for the width and height. Maybe the language definitions include more options. I’m not the original developer. I merely patched the plugin to display SWFs via SWFObject so that IE users didn’t have to click twice.

    posted by Josh Tynjala on 06.21.2006
  3. Great mod, but my concern with this plugin is it makes printing code from the page impossible. How would you implement an alternate stylesheet combined with the SWFObject that allows the text and not the SWF to show up when the user prints the page?

    posted by Joeflash on 08.17.2006
  4. Oh man, that’s a tough one. I don’t think a stylesheet would do it. Maybe you could add a print mode to your posts. Make the address look like this: http://your-blog/post/?print=true. The script will detect when the print variable is true and know to skip the SWF.

    posted by Josh Tynjala on 08.18.2006
  5. [...] We’re actually using this fix from zeuslab (FTF w/ SWFObject). [...]

    posted by aron / philipp development blog / FlashTextFormatter plugin for wordpress on 02.05.2008
Share Your Thoughts

To display code in comments: <pre>Code here. May be multiline. Format XML with &gt; and &lt; entities.</pre>

Some HTML allowed in comments: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>