thefoundationhttp://www.thefoundation.de2009-07-06T17:28:16Z(c) 2012 Michael Kurze, Aachen, GermanyDie Klimaschützer2009-07-06T17:28:16ZDaniel Beckerhttp://www.thefoundation.de/about/danieldie-klimaschutzer<p>Start using green energy – install the <a href="http://apps.facebook.com/dieklimaschuetzer/">Carbon Clock</a> on your Facebook-Profile or homepage!</p><p>Finally the <a href="http://apps.facebook.com/dieklimaschuetzer/">Carbon Clock</a> is online! The Layout was created by <a href="http://www.widjet.de/">widjet</a>, my task was the Flash and programming stuff. It is my first <a href="http://facebook.com">Facebook</a>-Application! After some struggle with the <a href="http://developers.facebook.com/">API</a> the application works fine – needless to say, I am a bit proud!<br />Depending on the installs of this application, the Carbon Clock shows how many carbon dioxide is prevented from emitting by users of green energy.</p>
<div style="width:184px;height:250px;text-align:center"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="184" height="225" id="CarbonClock" align="middle"> <param name="allowScriptAccess" value="always" /> <param name="allowFullScreen" value="false" /> <param name="movie" value="http://klima.stromauskunft.de/application/media/main.swf?wid=4a4dfaa1d1b04826&pid=4a5214a7bd60dc6b" /> <param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /> <param name="flashvars" value="wid=4a4dfaa1d1b04826&pid=4a5214a7bd60dc6b&getAppUrl=http://www.clearspring.com/widgets/4a4dfaa1d1b04826" /> <embed src="http://klima.stromauskunft.de/application/media/main.swf?wid=4a4dfaa1d1b04826&pid=4a5214a7bd60dc6b" flashvars="wid=4a4dfaa1d1b04826&pid=4a5214a7bd60dc6b&getAppUrl=http://www.clearspring.com/widgets/4a4dfaa1d1b04826" quality="high" bgcolor="#ffffff" width="184" height="225" name="CarbonClock" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object><a href="http://www.stromauskunft.de/de/html/oekostrom/klimaschuetzer.html" style="font-size:12px;color:#6198C2;font-family:Helvetica,Arial,sans;display:block;padding-top:4px">Mach mit! Werde Klimaschützer!</a></div>
<p>Click the <q>Wer macht mit?</q>-Button to <a href="http://www.clearspring.com/widgets/4a4dfaa1d1b04826">install the widget</a> on your homepage or go to <a href="http://apps.facebook.com/dieklimaschuetzer/">the Facebook-Application</a> and install <q>Die Klimaschützer</q> to your profile!</p>
<p>Since I felt lost sometimes during the development, I soon will write down my experiences and techniques in a short article.</p>
<p>
<script type="text/javascript" src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/en_US"></script>
<script type="text/javascript">FB.init("590725159c942c465f24ecb1efdc2d2d");</script>
<fb:fan profile_id="69907595492" stream="" connections="" width="400"></fb:fan>
</p>How to bring AS3 Tweens to an end2009-03-24T19:28:52ZDaniel Beckerhttp://www.thefoundation.de/about/danielhow-bring-as3-tweens-end<p>Have you ever assigned a tween to a local variable? Have you ever detected non-determining tweens, tweens which do not start at all? Blame ActionScript 3.0's ruthless garbage collector!</p><p>Back then in the old days of ActionScript 2.0 scripts like the following were just as easy as useful to program sequences of animations (<abbr title="exempli gratia">e. g.</abbr> assembling animations for site sections):</p>
<code class="block">
function transitionToolTip():void {
var toolTipAlpha:Tween = new Tween( toolTip, "alpha", Regular.easeOut, 0, 1, .75, true );
toolTipAlpha.addEventListener( TweenEvent.MOTION_FINISHED, handleToolTipTransition );
}
function handleToolTipTransition( e:TweenEvent ):void { … }
</code>
<p class="annotation notice right">Just to make things clear: The ActionScript 3.0 garbage collector does a good job in deleting these local variables. Obviously the ActionScript 2.0 garbage collector should have done this way, too.</p><p>In most cases one does not want to stop or modify tweens after firing them, thus one won't need a reference to the exact tween ever again. The next function would be triggered after the tween has finished. Great!<br />But, nowadays things are different. ActionScript 3.0's garbage collector seriously and unrelentingly works on what it is supposed to work: deleting everything with a lack of relation. In the sample case, shown above, this clearly means that the variable <code>toolTipAlpha</code>, declared with local scope of function <code>transitionToolTip</code> will be deleted – taking along our tween if the garbage collection cycle is awkward. In consequence our tween will not play to its end.</p>
<p>One solution would be the declaration of a class level or global variable to store the reference to the tween. This would look something like this:</p>
<code class="block">
var toolTipAlpha:Tween;
function transitionToolTip():void {
toolTipAlpha = new Tween( toolTip, "alpha", Regular.easeOut, 0, 1, .75, true );
toolTipAlpha.addEventListener( TweenEvent.MOTION_FINISHED, handleToolTipTransition );
}
function handleToolTipTransition( e:TweenEvent ):void { … }
</code>
<p class="annotation notice center">All the samples are in short form and not taken from real-life ActionScript 3.0 projects thus may not work properly. They are inserted for illustration purposes to show up possible problematics.</p>
<p>A far more elaborated description of the coexistence of tweens, variables and the garbage collector can be found on <a title="Scott Morgan – LA Flash and Flex Developer" href="http://www.scottgmorgan.com/">Scott Morgan's</a> <a href="http://www.scottgmorgan.com/blog/">blog</a> in the article <a title="AS3 Garbage Collection, the reason your tweens are ending early." href="http://www.scottgmorgan.com/blog/index.php/2007/11/18/as3-garbage-collection-the-reason-your-tweens-are-ending-early/">AS3 Garbage Collection, the reason your tweens are ending early.</a></p>
<p><a hreF="http://www.scottgmorgan.com/blog/index.php/2007/11/18/as3-garbage-collection-the-reason-your-tweens-are-ending-early/">via Scott Morgan's blog – http://www.scottgmorgan.com/</a></p><p class="annotation notice center">Sorry! Our Ping- and Trackback is not yet working.</p>Stuck for gift ideas?2008-12-17T00:35:30ZDaniel Beckerhttp://www.thefoundation.de/about/danielstuck-gift-ideas<p>Santa will help you out! Get some great last minute tipps from <a href="http://www.myspace.com/thewidjetsanta">Santa</a> himself directly on your own homepage!</p><h2>Santa's Last Minute Tipps</h2>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="100%" height="330" id="Santa" align="middle">
<param name="allowScriptAccess" value="always" />
<param name="allowFullScreen" value="false" />
<param name="movie" value="http://widjet.de/santa/santaWidget/santaWidget.swf" />
<param name="quality" value="high" /> <param name="wmode" value="transparent" />
<embed src="http://widjet.de/santa/santaWidget/santaWidget.swf" quality="high" width="100%" height="330" name="Santa" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent" />
</object>
<h2>Get Santa on your homepage!</h2>
<p>This widget was programmed using the <a href="http://www.clearspring.com/">Clearspring</a> <a href="http://www.clearspring.com/services/launchpad/in-widget">In-Widget-<abbr title="application programming interface">API.</abbr></a> The layout of <a href="http://www.myspace.com/thewidjetsanta">Santa's MySpace-Site</a> and the widget was created by <a href="http://widjet.de/">widjet</a> – a cologne based agency, focused on <a href="http://en.wikipedia.org/wiki/Widget_engine">widget-development.</a><br />My part was the implementation of the widget in <a href="http://www.adobe.com/products/flash/">Adobe Flash.</a> After being doomed with the <a href="http://www.clearspring.com/services/launchpad/in-widget">Clearspring-<abbr title="application programming interface">API</abbr></a> I had fun animating Santa and his Tipps!</p>
<p>You can really look forward to see Santa's next Tipps – and be sure not to miss a single one!</p>Integrating a plug-in into JW-Player 2008-09-20T02:06:41ZDaniel Beckerhttp://www.thefoundation.de/about/danielintegrating-plugin-jw-player<p>If you spent time watching web videos in the popular <abbr title="Flash Video"><a href="http://www.adobe.com/devnet/flash/articles/video_guide.html">FLV</a></abbr> format you might have stumbled upon the <a href="http://www.jeroenwijering.com/?item=JW_FLV_Media_Player">Jeroen Wijering player</a>. Version 4.1 features a plug-in interface – which I found pretty much undocumented.</p><p>In the following article I will try to give you a short insight on how to integrate plug-ins into the free and open-source Flash video player by <a href="http://www.jeroenwijering.com/">Jeroen Wijering</a>. All techniques described in this article worked with version 4.1.</p>
<h2>JW-Player plug-ins</h2>
<p class="annotation notice center">There are some restrictions for commercial use of the player. You have to apply for a commercial license at <a href="http://www.jeroenwijering.com/?page=order">http://www.jeroenwijering.com/?page=order</a></p>
<h3>What is JW-Player?</h3>
<p>In my eyes this player is a masterpiece in structured programming regarding the <abbr title="Model-View-Controller"><a href="http://en.wikipedia.org/wiki/Model-view-controller">MVC</a></abbr> architectural pattern. The source is as modular as possible so it can easily modified to fit new requirements. As an example it can be adapted to display videos from other sources (<abbr title="exempli gratia">e. g.</abbr> <a href="http://youtube.com/">YouTube</a>) by adding a new class as a <q>submodel</q>. The player allows <a href="http://code.jeroenwijering.com/trac/wiki/FlashSkinning">skinning</a> and provides a wide range of <a href="http://code.jeroenwijering.com/trac/wiki/FlashVars">settings</a> as well as an useful <a href="http://code.jeroenwijering.com/trac/wiki/FlashAPI">JavaScript interface</a>. While the majority of possibilities is documented in the <a href="http://code.jeroenwijering.com/trac">Wiki</a> I could not find any helpful information about the plug-ins. Maybe due a lack of time, perhaps because this possibility could be used to emulate the functionality of <a href="">longtail video</a> – a side project of Jeroen Wijering.<br />But this is just speculation so let us start over! This article will not give you turnkey sources nor will it be a full tutorial on how this or that could be realized with the JW-Player. I presume that you have already been dealing with Adobe Flash in a basic matter, so you can use my depictions as foundation for your own projects.</p>
<h3>How to integrate plug-ins</h3>
<p class="annotation warning left">You will need to have the <a href="http://www.miniml.com/">kroeger 05/63</a> pixel font installed / activated to not break the default player skin layout!</p><p>First you should get the source files and create an <abbr title="HyperText Markup Language">HTML</abbr> file which loads the JW-Player in order to set up a test-bench. In the next step we will create a Adobe Flash file to house our plug-in functionality. First and foremost the size and frame rate does not matter, however I suggest you to choose a size around 300x200 pixels – which should be <del>both, somewhat around the default as well as </del><ins>slightly smaller than the default size and </ins>the smallest display, the video player should be used with. This way you can layout your plug-in and perhaps add a script for scalable display later. Wether you will use scripts or not, you need to define a function called <q>initialize</q>. Otherwise the player will throw an error!<br />The plug-in <abbr title="ShockWave File"><a href="http://www.adobe.com/devnet/swf/">swf</a></abbr> should be published somewhere relative to your test <abbr title="HyterText Markup Language">HTML</abbr> file at best similar to later production environments. In the following code snippets I will assume, that the plug-in is placed in a subdirectory <q>media/flash/plugins/</q> and is called <q>plug-in.swf.</q><br />We will now pass some values to the JW-Player swf making use of the so-called flashvars. (I am sorry, I really tried to find some information about flashvars on the official sites of Adobe. I could not find anything helpful even in the <a href="http://livedocs.adobe.com/flash/9.0/">livedocs</a>. Except some outdated samples for <a href="http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_16417">Flash 6</a> and the use with <a href="http://www.adobe.com/livedocs/flash/9.0/main/wwhelp/wwhimpl/js/html/wwhelp.htm?href=00000887.html">ActionScript 2.0</a> which in this case are best of a basic use to understand what we are talking about. Perhaps someone can help out here? As there are several common ways to implement Adobe Flash in todays webpages I will attach a short paragraph containing samples of flashvar use at the end of this article.) Let us give the JW-Player a hint where to look for the plug-in. Add the flashvar <code>plugin</code> with the relative path to our plug-in as value, in our case <code>media/flash/plugins/plug-in.swf</code>. Your <abbr title="HyperText Markup Language">HTML</abbr> code should look somewhat like this:</p><code class="block"><object type="application/x-shockwave-flash"
data="player.swf"
width="300px"
height="200px" >
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="true" />
<em><param name="flashvars" value="plugins=media/flash/plugins/plug-in.swf" /></em>
<param name="quality" value="high" />
<p>Please get the Adobe Flash Player!</p>
</object>
</code>
<p class="annotation notice right">Be sure to use the relative path originated at the <abbr title="HyperText Markup Text">HTML</abbr> document – not the <abbr title="ShockWave File"><a href="http://www.adobe.com/devnet/swf/">swf</a></abbr>!</p><p>Yes, it is as easy as that! Now your plug-in should be loaded automatically. But wait! Offline everything works fine, but the Flash player is not able to find the plug-in on the server. After some investigation, we know why there are troubles: We have to navigate through the ActionScript package of the JW-Player to the main view class (com → jeroenwijering → player → View.as). Just at the end of the class header there is a private string <q>directory</q> with an <abbr title="Uniform Resource Locator"><a href="http://en.wikipedia.org/wiki/URL">URL</a></abbr> assigned as value: <q>http://plugins.longtailvideo.com/</q>. Perhaps this is a hint at how the plug-in interface usually gains utilization. If you set the <q>directory</q> value to be an empty string (like this <code>private var directory:String = "";</code>) the whole thing should work online. (Better way to solve this problem would be, <q>take the deep dive into this piece of code and understand what really is happening here</q> before removing some hardcoded value.)<br />From now on the rest is just some ActionScript wherewith we can do some magic! Since the code of the video player is well-structured and nearly every event you could imagine is dispatched all you have to do is: listen to the certain part (Model, View, Controller) and invoke some action!</p>
<h3>The fun part – ActionScript!</h3>
<p>Here we go: Include the View-class and declare a variable to hold the reference to the players View-instance:</p>
<code class="block"> // includes
import com.jeroenwijering.player.View;
// variables
// Reference to View-instance of video player
var v_player:View;
</code>
<p class="annotation note right">At this point, lazy guys, there is no short version, no <q>init</q>, no programmers stenography!</p><p>And again, Jeroen Wijering made life with plug-ins easy. If you set up a function called <q>initialize</q> it will be called as soon as your plug-in is properly loaded by the player:</p>
<code class="block">…
// Called after loading of plugin is completed
function initialize( par_playerView:View ) {
v_player = View( par_playerView );
trace( "do something useful" );
}
</code>
<p>The simple call to do something does not help much. I will give you an example of what could come next. For example it would be handy if the plug-in content would be centered if the player is resized! Let us assume we have a movie clip containing a graphic (<code>mc_content</code>, movie clip registration point should be on the top left) which should be horizontally centered and positioned somewhere above the vertical center (since there is this nice button to start the playback). But this graphic should disappear on playback start. We have to start with adding some lines to our plug-ins code <q>header</q>, furthermore we will instantiate a transition manager to handle a nice fade out of our plug-in content:</p>
<code class="block"> // imports
// video player stuff
import com.jeroenwijering.player.View;
import com.jeroenwijering.events.ModelEvent;
import com.jeroenwijering.events.ModelStates;
import com.jeroenwijering.events.ControllerEvent;
// eye candy
import fl.transitions.Fade;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.Transition;
import fl.transitions.TransitionManager;
// variables
// Reference to View-instance of video player
var v_player:View;
// Transition manager
var trnsmngr_content:TransitionManager = new TransitionManager( mc_content );
// functions
// Configure standard transitions used to fade plugin content in and out
var obj_contentFadeOut:Object = new Object();
obj_contentFadeOut.type = Fade;
obj_contentFadeOut.direction = Transition.OUT;
obj_contentFadeOut.duration = .7;
obj_contentFadeOut.easing = Regular.easeOut;
var obj_contentFadeIn:Object = new Object();
obj_contentFadeIn.type = Fade;
obj_contentFadeIn.direction = Transition.IN;
obj_contentFadeIn.duration = .7;
obj_contentFadeIn.easing = Regular.easeOut;
…
</code>
<p>Now we have to set up some functions to handle the positioning of the content elements and kick-off the vanishing of this content element on playback.</p>
<code class="block">…
// Invoked on resize
function onPlayerResize( par_arg ) {
alignContent( Number( par_arg.data.width ), Number( par_arg.data.height ) );
}
// Align content movie clip
function alignContent( par_width:Number, par_height:Number ) {
mc_content.x = Number( par_width / 2 - mc_content.width / 2 );
mc_content.y = Number( par_height / 2 - ( mc_content.height + 40 ) );
}
// Invoked on status change of video player
// - if playback has finished: fade in plugin content
// - if playback is (re-)started: hide plugin content
function onPlayerStateChange( par_arg ) {
if( par_arg.data.newstate == "COMPLETED" ) {
trnsmngr_content.startTransition( obj_contentFadeIn );
}else if( par_arg.data.newstate == "PLAYING" && par_arg.data.oldstate == "COMPLETED" ) {
trnsmngr_content.startTransition( obj_contentFadeOut );
}
}
…
</code>
<p>Obviously, the next thing to care about: event listeners! The listeners are registered in our <q>initialize</q> function:</p>
<code class="block">…
// Called after loading of plugin is completed
function initialize( par_playerView:View ) {
v_player = View( par_playerView );
v_player.addControllerListener( ControllerEvent.RESIZE, onPlayerResize );
v_player.addModelListener( ModelEvent.STATE, onPlayerStateChange );
alignContent( v_player.config.width, v_player.config.height );
}
</code>
<p>Now everything should work fine. The content will be realigned if the player should ever be resized on runtime (not very likely) and faded out on playback start or in respectively on playback end. To initially align the content, there is one line added, which calls <code>alignContent</code>. For convenience, the whole clump of code:</p>
<code class="block"> // imports
// video player stuff
import com.jeroenwijering.player.View;
import com.jeroenwijering.events.ModelEvent;
import com.jeroenwijering.events.ModelStates;
import com.jeroenwijering.events.ControllerEvent;
// eye candy
import fl.transitions.Fade;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.Transition;
import fl.transitions.TransitionManager;
// variables
// Reference to View-instance of video player
var v_player:View;
// Transition manager
var trnsmngr_content:TransitionManager = new TransitionManager( mc_content );
// functions
// Configure standard transitions used to fade plugin content in and out
var obj_contentFadeOut:Object = new Object();
obj_contentFadeOut.type = Fade;
obj_contentFadeOut.direction = Transition.OUT;
obj_contentFadeOut.duration = .7;
obj_contentFadeOut.easing = Regular.easeOut;
var obj_contentFadeIn:Object = new Object();
obj_contentFadeIn.type = Fade;
obj_contentFadeIn.direction = Transition.IN;
obj_contentFadeIn.duration = .7;
obj_contentFadeIn.easing = Regular.easeOut;
// Invoked on resize
function onPlayerResize( par_arg ) {
alignContent( Number( par_arg.data.width ), Number( par_arg.data.height ) );
}
// Align content movie clip
function alignContent( par_width:Number, par_height:Number ) {
mc_content.x = Number( par_width / 2 - mc_content.width / 2 );
mc_content.y = Number( par_height / 2 - ( mc_content.height + 40 ) );
}
// Invoked on status change of video player
// - if playback has finished: fade in plugin content
// - if playback is (re-)started: hide plugin content
function onPlayerStateChange( par_arg ) {
if( par_arg.data.newstate == "COMPLETED" ) {
trnsmngr_content.startTransition( obj_contentFadeIn );
}else if( par_arg.data.newstate == "PLAYING" && par_arg.data.oldstate == "COMPLETED" ) {
trnsmngr_content.startTransition( obj_contentFadeOut );
}
}
// Called after loading of plugin is completed
function initialize( par_playerView:View ) {
v_player = View( par_playerView );
v_player.addControllerListener( ControllerEvent.RESIZE, onPlayerResize );
v_player.addModelListener( ModelEvent.STATE, onPlayerStateChange );
alignContent( v_player.config.width, v_player.config.height );
}
</code>
<p>There are some additional things you should know while working with this nice player and its plug-in possibilities. Let me give you some arbitrary dodges!</p>
<dl>
<dt><code>v_player.config.[any name]</code></dt>
<dd>If you pass your own flashvars to the JW-Player, you can get the value of certain variables by this path plus your variable name at the end. It would be easy to display the videos title if you pass the flashvar <q>title</q>. You just need a textfield and assign the value <code>v_player.config.title</code>.</dd>
<dt><code>v_player.config.volume</code>, <code>v_player.config.width</code>, <code>v_player.config.height</code>, <code>v_player.config.fullscreen</code></dt>
<dd>There is a bunch of information in the config object of the View-instance. Here you can get the current value, width and height of the player, as well the configuration wether fullscreen is allowed and implemented or not (Nevertheless you cannot alter the state of fullscreen here! See below). To get information about the current display state watch <code>v_player.skin.stage[ "displayState" ]</code><br />If you want to know more, have a look in the Player class' (com → jeroenwijering → player → Player.as) <q>defaults</q> object!</dd>
<dt><code>v_player.sendEvent( [event], [value] )</code></dt>
<dd>Using the function <q>sendEvent</q> you can take control of various parts of the player. Set volume to 50 % by using following code: <code>v_player.sendEvent( "VOLUME", 50 )</code>, set player into fullscreen mode: <code>v_player.sendEvent( "FULLSCREEN", true )</code> or seek to closest keyframe to second two: <code>v_player.sendEvent( "SEEK", 2 )</code>.</dd>
<dt><code>v_player.addViewListener</code>, <code>v_player.addModelListener</code>, <code>v_player.addControllerListener</code></dt>
<dd>Like shown in the sample, you have the possibility to add listeners to every part of the player (Model, View, Controller). For further information about the various events, have a look at the <q>events</q> part of the player class package (com → jeroenwijering → events → *).</dd>
</dl>
<p class="annotation hint center">In the above samples, I assume you work in the plug-in of this tutorial. Otherwise the <code>v_player</code> has to be replaced by your reference to the View-instance of the JW-Player!</p><p>This article is not meant as a full featured tutorial to a full working this-and-that-performing plug-in, rather an insight on the different parts of plug-in programming for JW-Player with some short examples.</p>
<p class="annotation warning center">I am not quite sure about the legal matters on the use of JW-Player with altered code. So please check the information on <a href="http://www.jeroenwijering.com/">Jeroen Wijerings homepage</a> or contact him to assure you are not cracking anything besides the legal regulations here!</p>
<h2>Flashvars in todays webpages</h2>
<p>As mentioned before, there are several ways of integrating Flash files into webpages. Today a lot of people use JavaScript to embed Flash movies, there is the famous <a href="http://code.google.com/p/swfobject/">swfobject</a> as well as the Standard Adobe Flash way to use <a title="Not exactly what I wanted, but for sure interesting further reading for the use of AC_FL_Content." href="http://www.adobe.com/devnet/activecontent/articles/devletter.html">AC_FL_RunContent</a>. One main reason to use JavaScript is the outline rectangle the InternetExplorer shows up and which forces you to click on the Flash movie once, before you can interact with the movie. Moreover there is a check if the correct version of Adobe Flash Player is installed on the client machine.<br />Next we have the former standard way using markup with <code>object</code>- and <code>embed</code>-tags to integrate flash. Finally there is one possibility, first shown in an <a href="http://www.alistapart.com/articles/flashsatay/">A List Apart</a> article (for more information please visit: <a href="http://latrine.dgx.cz/how-to-correctly-insert-a-flash-into-xhtml">http://latrine.dgx.cz/how-to-correctly-insert-a-flash-into-xhtml</a>) to integrate Flash XHTML-Strict valid with markup and without the <code>embed</code>-tag which is in fact a relic from times with Netscape.<br />For each of these methods I will give you a short code snippet on how to pass Flashvars. This is known and far from being new, but get this as a compact reference for the most popular ways to integrate Flash.</p>
<h3>Flashvars and markup methods for Flash integration</h3>
<p>First the markup methods, in the following example the former standard way:</p>
<code class="block"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com
/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
width="300px"
height="200px" >
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="true" />
<param name="movie" value="player.swf" />
<em><param name="flashvars" value="plugins=media/flash/plugins/plug-in.swf&title=A%20shortfilm" /></em>
<embed src="player.swf"
<em>flashvars="plugins=media/flash/plugins/plug-in.swf&title=A%20shortfilm"</em>
quality="high"
width="300px"
height="200px"
allowScriptAccess="sameDomain"
allowFullScreen="true"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer" />
<param name="quality" value="high" />
<p>Please get the Adobe Flash Player!</p>
</object>
</code>
<p>In this example we pass the variables <q>plugin</q> and <q>title</q> to the <abbr title="ShockWave File"><a href="http://www.adobe.com/devnet/swf/">swf</a></abbr>. You can append as much variables as you needed, as long as you keep the pattern: seperate the variables using the ampersand <q>&</q>, assign value by using the equal sign <q>=</q>: <code>&[variable name]=[value]</code>.<br />Now for the XHTML-Strict compatible method. Analogue to the sample at the beginning of this article, passing Flashvars would look like this:</p>
<code class="block"><object type="application/x-shockwave-flash"
data="player.swf"
width="300px"
height="200px">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="true" />
<em><param name="flashvars" value="plugins=media/flash/plugins/plug-in.swf&title=A%20shortfilm" /></em>
<param name="quality" value="high" />
<p>Please get the Adobe Flash Player!</p>
</object>
</code>
<p class="annotation notice right">Variable names must not contain any special characters (as usual in ActionScript), the values should be <a href="http://www.w3schools.com/TAGS/ref_urlencode.asp"><abbr title="Uniform Resource Locator">URL</abbr>-encoded</a>.</p><p>In the first example you have to declare the variables and values <u>twice</u> to assure, that every browser (using either the <code>object</code>- or the <code>embed</code>-tag) gets the correct values!</p>
<h3>The JavaScript way</h3>
<p>Since the JavaScript methods are kinda proprietary, you have to find the correct solution for every specific JavaScript Flash integration. So, the following examples feature specific code for the <q>AS_FL_RunContent</q> (first) and the <q>swfobject</q> (second) method:</p>
<code class="block"><script language="javascript">
if (AC_FL_RunContent == 0) {
alert("This page requires \"AC_RunActiveContent.js\".");
} else {
AC_FL_RunContent(
'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
'width', '300',
'height', '200',
'src', 'player',
'quality', 'high',
'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
'id', 'player',
'name', 'player',
'allowFullScreen', 'true',
'allowScriptAccess','sameDomain',
'movie', 'player',
<em>'FlashVars', 'plugin=media/flash/plugins/plug-in.swf&title=A%20shortfilm'</em>
); //end AC code
}
</script>
<noscript>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"
width="300"
height="200"
id="player"
align="middle" >
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="true" />
<param name="movie" value="player.swf" />
<em><param name="flashvars" value="plugins=media/flash/plugins/plug-in.swf&title=A%20shortfilm" /></em>
<embed src="player.swf"
<em>flashvars="plugins=media/flash/plugins/plug-in.swf&title=A%20shortfilm"</em>
quality="high"
width="300"
height="200"
name="player"
allowScriptAccess="sameDomain"
allowFullScreen="true"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer" />
<param name="quality" value="high" />
<p>Please get the Adobe Flash Player!</p>
</object>
</noscript>
</code>
<p>Be sure to pass the Flashvars in the JavaScript code, as well as in the <code>object</code>-tag as <code>param</code>-tag and in the <code>embed</code>-tag as attribute <q>flashvars</q>.<br />Finally, the <q>swfobject</q> method:</p>
<code class="block"><script type="text/javascript" src="swfobject.js"></script>
<div id="playerContainer">
This is a flash video player.
</div>
<script type="text/javascript">
var so = new SWFObject("player.swf", "player", "300", "200", "9");
<em>so.addVariable("plugin", "media/flash/plugins/plug-in.swf");
so.addVariable("title", "A shortfilm");</em>
so.write("playerContainer");
</script>
</code>
<h2>Sample sources</h2>
<p>The Flash source codes are uploaded here:<br /><a href="/files/daniel/sources/jwplayer-plugin.zip">ZIP file containing plugin.fla</a><br />Set up an <abbr title="HyperText Markup Language">HTML</abbr> document with flashvars <q>plugins</q> and <q>title</q>:</p>
<code class="block">plugins=[path to plug-in.swf without extension]&title=[video title]</code>
<p>Outcome should be a headline showing the video title on the JW-Player <q>splash screen</q>.</p>