SwfObj Grows Up

It's been almost a year and the WordPress SwfObj plugin definitely needs some updating. A lot has happened in the last year with WordPress. To keep SwfObj relevant I've made a few changes with the new release. And I'm finally bumping it up to a 1.0 version. Not sure why I held off on that for so long, perhaps a paranoia that once I tacked on the 1.0 everything would break.

Keeping up with WordPress 3.0

There are a couple WordPress developments which are relevant to the SwfObj plugin.

First of all, with the 3.0 release WordPress now uses the latest swfobject.js file (version 2.2) so SwfObj no longer needs to re-register it. As a result, I've linked it up to the default swfobject.js file in WordPress 3.0+ installs. However, swfobject.js is still included in the plugin for WordPress installations that are using version 2.9 or older. The plugin automatically loads the most appropriate file for you.

Speaking of WordPress 2.9, apparently they fixed a bug that prevented me from using wp_enqueue_script in SwfObj and I didn't know about it until recently. Prior to version 2.9, if you set up WordPress on a secure server, with SSL, then the wp_enqueue_script function caused a bunch of security errors to pop up in the browser. Because of this, I avoided using this function. Now that it is fixed, though, I'm using it, which should make the plugin integrate much smoother with any installation of WordPress. Again, I've taken measures to make it backwards compatible with previous versions of WordPress as well.

A Newer More Powerful Alt

Additionally I've modified the way alt content is labelled in the shortcode. Several users have had problems getting more complicated alt content to load properly using SwfObj. After trying to escape, unescape, quote and otherwise get the complex alt content they were using to work under the original schema I'd set up, I gave up and decided to rewrite it.

To get the code to render properly, alt content now should be placed between opening and closing swfobj shorttags. Here is an example of the before and after.

Before: [swfobj ... alt="<img src='alt_image.jpg' />"]
After:  [swfobj ...]<img src="alt_image.jpg" />[/swfobj]

The change is meant to be simple. The original method is still supported, so upgrading won't break all of the content you've already got embedded in all of your posts. But from here on out I would recommend using the new way to include alt content. It allows you to embed more complicated content to support browsers that don't have Flash. I'm looking at you Apple. The Flash embed button now uses this method to include alt content in the swfobj tags as well.

Always Squashing Bugs

I've also fixed several other bugs that users were kind enough to point out to me. I really appreciate all of the feedback everyone has given for this plugin and especially those of you who have been kind enough to donate to the project. Thank you for all of the great support that is helping to make this plugin even better.

If you have any questions, bug reports or suggestions please send them over.

Thanks again and happy embedding.

This entry was posted in SwfObj and tagged , , , , , . Bookmark the permalink. Follow any comments here with the RSS feed for this post.
  • Michael

    I just download the plugin and followed the instructions and all I get is buffing message on my post. My .swf file is only 31k as a test and nothing is happening I’m using wordpress ver. 3.0.3

    This is the code that was generated in my post: [swfobj src="http://www.devonsimagingblog.com/wp-content/uploads/2011/01/devon.swf" width="940" height="625" allowfullscreen="false"]

    Can you help. Michael info@devonsimaging.com or 631 286 1447

    Thanking You In Advance!

    • http://orangesplotch.com Matt Carpenter

      Hi Michael,

      I’m guessing this swf is some kind of photo gallery/slideshow. Usually the problem is that the .swf is looking for data in the directory of the page’s url, which is not where the images are on the server. Most Flash slideshow files can be given a parameter to tell them the url of the images or xml config file.

      Not sure if any of that makes sense, but I’ll send you an email and hopefully we can figure out what is going on with your page.

  • Carlos Pelambres

    Can the alternative content for flash be something other than flash? let’s say a slideshow that actually works in those annoying i devices?

  • Carlos Pelambres

    Sorry i meant oask can the alt content for flash be something besides an image…

    • http://orangesplotch.com Matt Carpenter

      Yes, the alt can be any valid html content you want, it is not limited to just images.

  • Chris

    Hi Matt,

    Your plug-in for embedding flash in WordPress sounds really cool. I’ve got a few questions, so please bear with me. I’m a newbie.

    I’ve just started using WordPress. (I know Flex 3/ Actionscript. Unfortunately, I don’t know javascript.) I’d like to embed Flex 3 apps in my WordPress 3.1 page. Would it be possible to do so using your plug-in?

    If so, can you point me to a tutorial as to how to do so? Or an example somewhere?

    Do I need to change the default Flex HTML wrapper to use swfObject? (The default wrapper doesn’t use swfobject).

    Or do I simply download your plug-in, put the Flex app on the server, and add your embed tags to the WordPress page? As I understand it from your post, WordPress already has swfobject included, so I don’t need to download it. (I only need your plug-in.)

    My Flex app pulls data from a mySQL database. So, for example, if the user clicks button X or selects X in a ComboBox, they get different info than if they selected something else. Currently, I’ve got my Flex apps working as standalone Flex pages. If I embed them in WordPress pages, do I have to change the way that they connect to the database? I’m thinking in terms of the sending a variable to the database. So, would a remoting function like this still work?

    public function getData(series:uint):void {

    myRemote.getMyData(series);

    }

    Or, do I need to re-work it somehow to “escape” the WordPress page? Any suggestions?

    Again, thank you for your excellent work.

    -Chris

    • http://orangesplotch.com Matt Carpenter

      Hi Chris,

      These are good questions. As long as your Flex 3 apps are compiled as .swf
      files, then they can be embedded into your WordPress pages using the SwfObj
      plugin. Standalone executables aren’t embeddable.

      As far as embedding it, all you need to do is install the plugin, then on
      your post page you will see a little ‘f’ icon. Click on that and it will pop
      up a screen for uploading your .swf file and embedding it onto the current
      page. You can also upload the file to your server and then manually enter
      the shortcode into the post if you prefer to do it that way.

      Your Flex app will still have the same access to the MySQL database. The
      only caveat is if it depends on server side php code. It doesn’t sound like
      this is the case, though, so you should be good to go.

      Let me know if you have any other questions or if there are any issues with
      the plugin.

      Thanks,
      mattc

      • Chris

        Hi Matt,

        Thanks so much for taking the time to help me. I really, really appreciate it. I just want to clarify a couple of points in your reply:

        I’m not sure what you mean by “standalone executables aren’t embeddable”. For example, imagine that I have a Flex 3 panel with a dataGrid in it. And I’ve got a ComboBox to choose which data to show in the grid. When the Flex app opens I have a default in the ComboBox selected. So, the table is filled with default data pulled from the mySQL database. In this example, is it a standalone executable?

        If I watch a Youtube video in a Flash Player I have to click the “Play” button in the player to start it. But, in my case, Flex goes ahead and retrieves data for the default table when it starts? I’m also thinking about using a Flex treemap with default data and a Google Map that uses Flex 3 for displaying data.

        I guess that in a sense Flex auto executes– meaning that I don’t have to click a button for a panel or someother component to appear. It runs when the page loads.

        Also, I didn’t quite understand your point regarding php code and the mySQL database. When I connect to the mySQL database, I use a php file that contains the select statement. It uses the variable that the Flex3 function sent and puts it in the select statement. So, I use a php file to pull the data from the database and return it to Flex. I use php file that’s similar to the one in Mihai’s tutorial: http://corlan.org/2008/11/13/flex-and-php-remoting-with-zend-amf/ The php is about halfway down the page.

        I really hope that I can use your plugin in my project. Apologies for all of the questions. I’m still learning.

        Thank you!

        -Chris

        • http://orangesplotch.com Matt Carpenter

          Sorry for the slow response, it’s been a busy weekend.

          In Flex, you can compile an executable that runs outside of the browser
          using Adobe AIR. This object is not embeddable in the browser and won’t work
          with SwfObj. That is what I mean by the standalone executable. It isn’t an
          issue of the objects you’ve included in your Flex project, just how you are
          compiling it.

          As far as using php code, the problem is if you are using relative urls to
          call the php file from within your Flex code. The way WordPress sets up urls
          makes it difficult for Flex to find the php file if it is a relative
          url. Contact
          me offline for more info about this, as
          it’s a bit of a long explanation.

        • Chris

          Hi Matt,

          No worries– hope that you had a good weekend. Thank you for the clarification. I understand what you mean now. I don’t have an AIR project, so that’s good. I’ll have to check, but I probably use relative URLs to call the php. So I’ll have to re-write those as absolute URLs. I’ll contact you in a few days (offline), as you suggested. Again, thanks Matt. You’ve been really cool helping me out.

  • http://dess.me/ Denis

    What I wanted was to see if this plugin can do a rotating flash ads into WP. Just couldn’t figure out. Something like flash tag cloud.

  • Poopeegames

    Hi,

    As i see it’s been 3 years you didn’t update your plugin, but i’m not desesperate and i’ll try to ask you a question about it.

    Firstly thank you for this plugin, indeed i had problems with others wp flash plugins but not with your.

    But now i have a more complicated usage to take from it : How could i send a dynamic flashvar to your shortcode ? 
    Example, i run a flash games wp/buddypress website, i embed every flash games with shortcode. But now i would like to retrieve $userid from buddypress (i know how doing it in php) and send it in a flash var to your plugin.

    What do you think about that, is this possible? How would you do this? Would i need to hack the plugin?

    • http://orangesplotch.com Matt Carpenter

      Since WordPress Posts cannot contain PHP code, the best way that I can think to implement this would be to hack the SwfObj plugin. You will need to modify the swfobj_func function to add the $userid as a flashvar parameter.

      I wish there were an easier way to do this. Feel free to shoot me an email from the contact form if you have any questions.

      • mouffles

        Thanks, that’s what i started to do today.

        I don’t konw why, but i can’t use dynamic integration, no flash displayed at all when i active it (it would have been finished in a couple of minute with dynamic part of your code) so i’m going to tweak the static one ;)

        Thank you for your answer.