We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21560
    • 145 Posts
    Because I am lazy as sin, but crazy, I made this little snippet. If anyone thinks it’s worth it, add it to resources?

    Basically, this adds a flash movie to a page. Notice the flash version set in the snippet itself (10.0.0)

    Requirements:
    SWFObject: http://code.google.com/p/swfobject/
    (place "swfobject.js" and "expressInstall.swf" in /assets/flash)

    Snippet call:
    [[Flash? &swf=`show` &width=`400` &height=`300`]]
    Notice you do not use the SWF extension.

    Snippet itself:
    <?php
    /*
    *	Simple Flash SWF snippet - By Nimja.com
    *
    *	Requirements: SWFObject - http://code.google.com/p/swfobject/
    *		(place "swfobject.js" and "expressInstall.swf" in /assets/flash)
    *
    *	SWF files should be placed in /assets/flash - Subdirs can be used.
    *	Snippet call uses the name of the swf WITHOUT .swf, to prevent stupidity.
    *
    *	Snippet name: Flash
    *	Snippet call: [[Flash? &swf=`example` &width=`400` &height=`300`]]
    *
    *	Version history:
    *	1.1 - Added DIV holder, with classname and style that contains the same width/height.
    * 	1.0 - Working fine.
    */
    
    $result = 'Please set a proper filename.';
    if (!empty($swf)) {
    	//Add JS to <head>
    	$swfobject = $modx->config['base_url'] . 'assets/flash/swfobject.js';
    	$modx->regClientStartupScript($swfobject);
    	
    	//Get settings (and add .swf to filename)
    	$swf = $modx->config['base_url']. 'assets/flash/'.$swf.'.swf';
    	$width = (!empty($width)) ? $width : 200;
    	$height = (!empty($height)) ? $height : 200;
    		
    	//Create the output.
    	$result = '<div class="Flash" style="width:'.$width.'px; height: '.$height.'pd;" ><object id="flashMovie" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'.$width.'" height="'.$height.'">';
    	$result .= '<param name="movie" value="'.$swf.'" />';
    	$result .= '<!--[if !IE]>-->';
    	$result .= '<object type="application/x-shockwave-flash" data="'.$swf.'" width="'.$width.'" height="'.$height.'">';
    	$result .= '<!--<![endif]-->';
    	$result .= '<div><h1>Obtain Flash Player</h1><p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p></div>';
    	$result .= '<!--[if !IE]>-->';
    	$result .= '</object>';
    	$result .= '<!--<![endif]-->';
    	$result .= '</object></div>';
    	$result .= '<script type="text/javascript">swfobject.registerObject("flashMovie", "10.0.0", "expressInstall.swf");</script>';
    }
    return $result;
    ?>
      [font=Times]Comics, stories, music, graphics, games and more! http://Nimja.com
      • 21560
      • 145 Posts
      Added holding DIV class that sets it’s width/height to be equal to the flash itself.
      This means you can center a Flash block on the page nicely. (or position it any other way).

      I hope people find this useful. smiley
        [font=Times]Comics, stories, music, graphics, games and more! http://Nimja.com
        • 26931
        • 2,314 Posts
        thanks for sharing Nimja smiley
          • 16610
          • 634 Posts
          Nice! Add it the resources, so it won’t get lost in the forums.
            Mikko Lammi, Owner at Maagit
            • 21560
            • 145 Posts
            Good point, have added it as: Easy Flash Snippet

            Hope people will like it smiley
              [font=Times]Comics, stories, music, graphics, games and more! http://Nimja.com
              • 19298
              • 76 Posts
              MichaelHarringtonDesigns Reply #6, 16 years, 7 months ago
              Hi Nimja

              Thanks for this snippet its great

              I am not to sure how to position the swf file on the page, you mentioned you could position the swf in any other way.

              For example if I needed the swf to be positioned 13px from he top of the page, how would I do this? I tried

              [[Flash? &swf=`example` &width=`900` &height=`209` &margin-top=`13`]] but with no luck
                • 21560
                • 145 Posts
                The snippet, at the moment, uses "Flash" as the CSS class.

                (here)
                $result = '<div class="Flash"...


                In your site’s CSS, you would define the class and set it to however you want.

                .Flash {
                	margin-top: 13px;
                }
                  [font=Times]Comics, stories, music, graphics, games and more! http://Nimja.com