<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mark Foster's Blog &#187; Flash/ActionScript/Flex</title>
	<atom:link href="http://www.markfosteronline.com/category/flash-actionscript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.markfosteronline.com</link>
	<description>Misadventures in Technology</description>
	<lastBuildDate>Sat, 22 May 2010 05:18:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>How to add a custom context menu to a Spark TextArea in Flex 4</title>
		<link>http://www.markfosteronline.com/2010/05/22/how-to-add-a-custom-context-menu-to-a-spark-textarea-in-flex-4/</link>
		<comments>http://www.markfosteronline.com/2010/05/22/how-to-add-a-custom-context-menu-to-a-spark-textarea-in-flex-4/#comments</comments>
		<pubDate>Sat, 22 May 2010 05:18:27 +0000</pubDate>
		<dc:creator>mfoster</dc:creator>
				<category><![CDATA[Flash/ActionScript/Flex]]></category>
		<category><![CDATA[LinkedIn]]></category>

		<guid isPermaLink="false">http://www.markfosteronline.com/?p=756</guid>
		<description><![CDATA[There is a current known issue with adding custom context menus on a RichEditableText Spark component: http://bugs.adobe.com/jira/browse/SDK-23926 This includes the TextArea component. Essentially, any custom context menus will not show up. There is a work around mentioned in the comments for the bug on Adobe&#8217;s website but I thought I would re-hash and show an [...]]]></description>
			<content:encoded><![CDATA[<p>There is a current known issue with adding custom context menus on a RichEditableText Spark component:<br />
<a href="http://bugs.adobe.com/jira/browse/SDK-23926">http://bugs.adobe.com/jira/browse/SDK-23926</a> </p>
<p>This includes the TextArea component.  Essentially, any custom context menus will not show up.  There is a work around mentioned in the comments for the bug on Adobe&#8217;s website but I thought I would re-hash and show an example since this had me a bit stumped.</p>
<p>The work around is to attach the context menu to the TextArea&#8217;s TextDisplay object via the &#8220;textDisplay()&#8221; accessor method.  I have created a <a href="http://www.mkfoster.com/examples/TextAreaContextMenu/">simple example</a> with <a href="http://www.mkfoster.com/examples/TextAreaContextMenu/srcview/index.html">source</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:Application</span> <span style="color: #000066;">xmlns:fx</span>=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span> </span>
<span style="color: #009900;">               <span style="color: #000066;">xmlns:s</span>=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span> </span>
<span style="color: #009900;">               <span style="color: #000066;">xmlns:mx</span>=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/mx&quot;</span> <span style="color: #000066;">minWidth</span>=<span style="color: #ff0000;">&quot;400&quot;</span> <span style="color: #000066;">minHeight</span>=<span style="color: #ff0000;">&quot;200&quot;</span> <span style="color: #000066;">backgroundColor</span>=<span style="color: #ff0000;">&quot;#9FA0D4&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;500&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;300&quot;</span></span>
<span style="color: #009900;">               <span style="color: #000066;">creationComplete</span>=<span style="color: #ff0000;">&quot;init();&quot;</span> <span style="color: #000066;">viewSourceURL</span>=<span style="color: #ff0000;">&quot;srcview/index.html&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:layout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:BasicLayout</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/s:layout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fx:Declarations<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #808080; font-style: italic;">&lt;!-- Place non-visual elements (e.g., services, value objects) here --&gt;</span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/fx:Declarations<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fx:Script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #339933;">&lt;![CDATA[</span>
<span style="color: #339933;">            private function init():void{</span>
<span style="color: #339933;">                var cm:ContextMenu = new ContextMenu();</span>
&nbsp;
<span style="color: #339933;">                var red:ContextMenuItem = new ContextMenuItem('Red',false,true,true);</span>
<span style="color: #339933;">                red.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, handleRed);</span>
&nbsp;
<span style="color: #339933;">                var green:ContextMenuItem = new ContextMenuItem('Green',false,true,true);</span>
<span style="color: #339933;">                green.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, handleGreen);</span>
&nbsp;
<span style="color: #339933;">                var blue:ContextMenuItem = new ContextMenuItem('Blue',false,true,true);</span>
<span style="color: #339933;">                blue.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, handleBlue);</span>
&nbsp;
<span style="color: #339933;">                cm.customItems.push(red);</span>
<span style="color: #339933;">                cm.customItems.push(green);</span>
<span style="color: #339933;">                cm.customItems.push(blue);</span>
<span style="color: #339933;">                cm.clipboardMenu = true;</span>
<span style="color: #339933;">                textArea.textDisplay.contextMenu = cm;</span>
<span style="color: #339933;">            }</span>
&nbsp;
<span style="color: #339933;">            private function handleRed(e:Event):void{</span>
<span style="color: #339933;">                textArea.setStyle('contentBackgroundColor', 'red');</span>
<span style="color: #339933;">            }</span>
&nbsp;
<span style="color: #339933;">            private function handleGreen(e:Event):void{</span>
<span style="color: #339933;">                textArea.setStyle('contentBackgroundColor', 'green');</span>
<span style="color: #339933;">            }</span>
&nbsp;
<span style="color: #339933;">            private function handleBlue(e:Event):void{</span>
<span style="color: #339933;">                textArea.setStyle('contentBackgroundColor', 'blue');</span>
<span style="color: #339933;">            }</span>
<span style="color: #339933;">        ]]&gt;</span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/fx:Script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:TextArea</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;textArea&quot;</span> <span style="color: #000066;">x</span>=<span style="color: #ff0000;">&quot;161&quot;</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">&quot;74&quot;</span> <span style="color: #000066;">text</span>=<span style="color: #ff0000;">&quot;This is a Flex 4 Spark TextArea.  Right click to see the custom context menu. &quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/s:Application<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.markfosteronline.com/2010/05/22/how-to-add-a-custom-context-menu-to-a-spark-textarea-in-flex-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SWFObject flashvars, params, and attributes</title>
		<link>http://www.markfosteronline.com/2010/01/25/swfobject-flashvars-params-attributes/</link>
		<comments>http://www.markfosteronline.com/2010/01/25/swfobject-flashvars-params-attributes/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 05:08:33 +0000</pubDate>
		<dc:creator>mfoster</dc:creator>
				<category><![CDATA[Flash/ActionScript/Flex]]></category>
		<category><![CDATA[LinkedIn]]></category>

		<guid isPermaLink="false">http://www.markfosteronline.com/?p=732</guid>
		<description><![CDATA[I have been working with SWFObject a bit lately and was a little confused by how the flashvars, params, and attributes arguments for the embedSWF() function differ from each other and what exactly SWFObject did with them. Based on the documentation, I did a little experiment where I used each and then viewed the generated [...]]]></description>
			<content:encoded><![CDATA[<p>I have been working with <a href="http://code.google.com/p/swfobject/">SWFObject</a> a bit lately and was a little confused by how the flashvars, params, and attributes arguments for the embedSWF() function differ from each other and what exactly SWFObject did with them.  Based on the <a href="http://code.google.com/p/swfobject/wiki/documentation">documentation</a>, I did a little experiment where I used each and then viewed the generated source using the <a href="https://addons.mozilla.org/en-US/firefox/addon/60">Web Developer Toolbar</a> for <a href="http://www.mozilla.com/en-US/firefox/upgrade.html">Firefox</a>.</p>
<p>Here is my HTML and SWFObject JavaScript which uses the dynamic publishing method as described in the <a href="http://code.google.com/p/swfobject/wiki/documentation">SWFObject Documentation</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;html&gt;
&nbsp;
&lt;head&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;swfobject/swfobject.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
&nbsp;
&lt;body&gt;
&lt;div id=&quot;embedhere&quot;&gt;Embed Fail&lt;/div&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
&nbsp;
	var flashvars = {};
	flashvars.my_flashvar1 = &quot;my_flashvar_value1&quot;;
	flashvars.my_flashvar2 = &quot;my_flashvar_value2&quot;;
&nbsp;
	var params = {};
	params.my_param1 = &quot;my_param_value1&quot;;
	params.my_param2 = &quot;my_param_value2&quot;;
&nbsp;
	var attributes = {};
	attributes.my_attribute1 = &quot;my_attribute_value1&quot;;
	attributes.my_attribute2 = &quot;my_name_attribute&quot;;
&nbsp;
	swfobject.embedSWF(&quot;Test.swf&quot;, &quot;embedhere&quot;, &quot;300&quot;, &quot;250&quot;, &quot;9.0.0&quot;, false, flashvars, params, attributes);
&nbsp;
&lt;/script&gt;
&lt;/body&gt;
&nbsp;
&lt;/html&gt;</pre></div></div>

<p>Here is what the generated source looks like after I load the page in Firefox and SWFObject has done its thing:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;html&gt;&lt;head&gt;
&nbsp;
&nbsp;
&lt;script type=&quot;text/javascript&quot; src=&quot;swfobject/swfobject.js&quot;&gt;&lt;/script&gt;
&lt;style media=&quot;screen&quot; type=&quot;text/css&quot;&gt;#embedhere {visibility:hidden}&lt;/style&gt;&lt;/head&gt;&lt;div firebugversion=&quot;1.5.0&quot; style=&quot;display: none;&quot; id=&quot;_firebugConsole&quot;&gt;&lt;/div&gt;&lt;body&gt;
&lt;object data=&quot;300x250TestAdAS3.swf&quot; name=&quot;my_name_attribute&quot; id=&quot;my_id_attribute&quot; type=&quot;application/x-shockwave-flash&quot; height=&quot;250&quot; width=&quot;300&quot;&gt;&lt;param value=&quot;my_param_value&quot; name=&quot;my_param&quot;&gt;&lt;param value=&quot;clickTAG=http%3A//www.example.com&quot; name=&quot;flashvars&quot;&gt;&lt;/object&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
	var clickTAG = escape(&quot;http://www.example.com&quot;);
	var flashvars = {clickTAG:clickTAG};
&nbsp;
	var params = {
		my_param: &quot;my_param_value&quot;
	};
&nbsp;
	var attributes = {};
	attributes.id = &quot;my_id_attribute&quot;;
	attributes.name = &quot;my_name_attribute&quot;;
&nbsp;
	swfobject.embedSWF(&quot;Test.swf&quot;, &quot;embedhere&quot;, &quot;300&quot;, &quot;250&quot;, &quot;9.0.0&quot;, false, flashvars, params, attributes);
&lt;/script&gt;
&lt;/body&gt;&lt;/html&gt;</pre></div></div>

<p>As you can see the attributes are just attributes to the object tag.  The parameters show up inside of param tags with one param tag for each param following the object tag.  I would be curious to hear if anyone has used the &#8220;attributes&#8221; and &#8220;parameters&#8221; arguments when embedding Flash with SWFObject and for what.</p>
<p>The flashvars argument is the most useful in my case because that is how you can get external data passed into the SWF.  I think a lot of folks load in their data into a Flash movie using a separate call to load an XML document.  That is the way to go if you are pulling a large amount of data dynamically based on some type of user input.</p>
<p>If you only have a few name value pairs that are not going to change, passing these in during the embed using flashvars is probably the better option.  Assigning these values during the embed will save a second round trip you would normally make to get an XML document.</p>
<p>So let&#8217;s say you decide you want to pass in a couple key-value pairs to a Flash movie using SWFObject.  In the code example above there are two key-value pairs we assign to flashvars: &#8220;my_flashvar1&#8243; and &#8220;my_flashvar1&#8243;.  Now you will want access these two inside your ActionScript code.</p>
<p>For ActionScript 2 it would look something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>_level0.<span style="color: #006600;">my_flashvar1</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>_level0.<span style="color: #006600;">my_flashvar2</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>ActionScript 3 requires another line of code to get to the same place:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> paramList:<span style="color: #0066CC;">Object</span> = <span style="color: #0066CC;">this</span>.<span style="color: #006600;">root</span>.<span style="color: #006600;">loaderInfo</span>.<span style="color: #006600;">parameters</span>;
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>paramList<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;my_flashvar1&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>paramList<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;my_flashvar2&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>A word of caution:  When you use SWFObject&#8217;s embedSWF() function there are quite a few optional parameters.  Be sure that you put a &#8220;false&#8221; in for optional parameters you don&#8217;t intend to use before any parameters you ARE going to use.  In the embed example below I want to use the flashvars option but I don&#8217;t want to use the option to specify an express install file so I put in a false in that spot.  Also, just be careful in general because there are a total of 10 different arguments for the embedSWF() function (including all the optional ones) so it is easy to get them in the wrong order and such.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">swfobject.<span style="color: #660066;">embedSWF</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Test.swf&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;embedhere&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;300&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;250&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;9.0.0&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span> flashvars<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Take a look at the <a href="http://code.google.com/p/swfobject/wiki/documentation">SWFObject documentation</a> for a description of each parameter.</p>
<p>That&#8217;s it!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.markfosteronline.com/2010/01/25/swfobject-flashvars-params-attributes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
