EasySWF - a small SWFObject helper


Easy SWF is a helper for SWFobject.js, and allows you to quickly add SWF files to your pages without all the hassles.

With the SWFobject javascript library, you have to:

- Hard-code a "target DIV" in your page.
- Establish seperate objects for the attributes, parameters.
- Establish indiviidual argments for width, height, SWF source, and all the other options.
- Hard-code the "Upgrade / No Flash" stuff into your page.

With EasySWF, we've boiled everything down to a single jQuery style "call":

- No additional DIVs or HTML necessary.
- Core SWF attributes are defined with a single object. (Flashvars require an additional object)
- Built-in the upgrade and no-flash display for users without flash (
- Can still use the target DIV concept.
- Can also render the SWF directly with an easyswf() call.

Easy SWF is not an alternative or replacement for SWFObject, just a small wrapper to help make using SWFobject easier.


easyswf({ swf:        "example.swf",
          width:      400,
          height:     100


Using Flashvars

If you need to include flashvars, well, you'll need an additional object, but at least everything is relatively consistant:


easyswf({ swf:        "example.swf",
          width:      400,
          height:     100,
          flashvars:  { foo: "fooValue",
                        bar: "barValue"


Additional Options

Of course, you can include all of the standard options as needed.


easyswf( {  swf:         "path_to.swf",
            swfversion:  "10,0,0,0",
            targetDiv:   "div_to_replace",
            bgcolor:     "#000000",
            width:       500,
            height:      300,
            scale:       "default",
            salign:      "tl",
            align:       "l", // <-- Note commas after each argument (NOT semicolons)
            allowScriptAccess: true,
            allowFullScreen: true,
            menu:        true,
            wmode:       "transparent",
            swfid:       "unique_swf_id",
            flashvars:   {   foo: "foo",
                             bar: "bar" // <-- Note NO comma after last argument 
            noFlashImage: "path/to/flash_icon.jpg",
            noFlashFont: "Arial",
            noFlashFontSize: 16,
            noFlashFontWeight: "bold",
            noFlashFontColor: "#FFFFFF" // <-- Note NO comma after last argument 



Bookmark and Share







View Source

© Michael Gieson