<?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/"
	>

<channel>
	<title>Iorana Flex</title>
	<atom:link href="http://alainthibodeau.com/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://alainthibodeau.com/blog</link>
	<description></description>
	<pubDate>Fri, 22 Jan 2010 20:43:00 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Flex 3 - How can I make links inside a TextArea?</title>
		<link>http://alainthibodeau.com/blog/?p=110</link>
		<comments>http://alainthibodeau.com/blog/?p=110#comments</comments>
		<pubDate>Wed, 10 Jun 2009 19:15:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Flex]]></category>

		<category><![CDATA[Add new tag]]></category>

		<guid isPermaLink="false">http://alainthibodeau.com/blog/?p=110</guid>
		<description><![CDATA[I was working on a project the other day that required me to take user input and parse out the links to make them clickable. For this particular project, I needed to create this as a method for my data class. I&#8217;ve stripped out the code for just the url parsing and made it just [...]]]></description>
			<content:encoded><![CDATA[<p>I was working on a project the other day that required me to take user input and parse out the links to make them clickable. For this particular project, I needed to create this as a method for my data class. I&#8217;ve stripped out the code for just the url parsing and made it just as a function. </p>
<p>CODE:</p>
<div class="codesnip-container" >
<div class="codesnip" style="font-family: monospace;">
<ol>
<li class="li1">
<div class="de1">public function getUrlParsedMessage(msg:String):String</div>
</li>
<li class="li1">
<div class="de1">{</div>
</li>
<li class="li1">
<div class="de1">&nbsp;//Display message and fix links</div>
</li>
<li class="li1">
<div class="de1">&nbsp;var isLink:RegExp = /(((http|https|ftp)\:\/\/)|(www\.))[a-z0-9.:\/]*/gi;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;//var msg:String = this.message;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li class="li1">
<div class="de1">if(msg.match(isLink).length &gt;= 1)</div>
</li>
<li class="li1">
<div class="de1">{</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;var t:String;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;var addHttp:String;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;for each (var match:String in msg.match(isLink))</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;{</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; match.search(&quot;www.&quot;)?(addHttp=&quot;&quot;):(addHttp=&quot;http://&quot;); </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; t = msg.replace(match,(&quot;<span class="sc3"><span class="re1">&lt;a</span> <span class="re0">href</span>=<span class="st0">&#8216;event:&quot;+ addHttp + match + &quot;&#8217;</span><span class="re2">&gt;</span></span>&quot; + match + &quot;<span class="sc3"><span class="re1">&lt;/a<span class="re2">&gt;</span></span></span>&quot;));</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; msg = t;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;}</div>
</li>
<li class="li1">
<div class="de1">}</div>
</li>
<li class="li1">
<div class="de1">return msg;</div>
</li>
<li class="li1">
<div class="de1">}</div>
</li>
</ol>
</div>
</div>
<p>So, what I am doing here is creating a regular expression pattern that will pick out my link starting with http, https, ftp or www. Once I find a link, I look to see if it starts with http:// and add it if it doesn&#8217;t. In the TextArea&#8217;s HtmlText, flash needs event: in front of the url address hence why I am adding it in the msg.replace call. The function then returns the text with the url&#8217;s sorted out.</p>
<p>The TextArea and link function would look like this:</p>
<div class="codesnip-container" >
<div class="codesnip" style="font-family: monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="sc3"><span class="re1">&lt;mx:Script<span class="re2">&gt;</span></span></span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&lt;![CDATA[</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">private function onLink( event : TextEvent ) : void</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">{ &nbsp; &nbsp; &nbsp; &nbsp;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2"> &nbsp; navigateToURL(new URLRequest(event.text));</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">}</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">]]&gt;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc3"><span class="re1">&lt;/mx:Script<span class="re2">&gt;</span></span></span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="sc3"><span class="re1">&lt;mx:TextArea</span> <span class="re0">link</span>=<span class="st0">&quot;onLink(event)&quot;</span> <span class="re2">/&gt;</span></span></div>
</li>
</ol>
</div>
</div>
<p>Keep in mind that I removed this from a member function and the parsing was called internally upon the object receiving a string. You have to wire this up the way you need.</p>
]]></content:encoded>
			<wfw:commentRss>http://alainthibodeau.com/blog/?feed=rss2&amp;p=110</wfw:commentRss>
		</item>
		<item>
		<title>Photographs - If Only They Could Speak</title>
		<link>http://alainthibodeau.com/blog/?p=107</link>
		<comments>http://alainthibodeau.com/blog/?p=107#comments</comments>
		<pubDate>Tue, 09 Jun 2009 19:34:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Applications & Experiments]]></category>

		<guid isPermaLink="false">http://alainthibodeau.com/blog/?p=107</guid>
		<description><![CDATA[I really liked working on this project for its visual challenges. This doesn&#8217;t look like a Flex application at all.
I did not create the visual design but I implemented everything you see. I used Cairngorm and leveraged some webservices for the data. I liked working with the new Flash player 10 features like saving and encoding [...]]]></description>
			<content:encoded><![CDATA[<p>I really liked working on this project for its visual challenges. This doesn&#8217;t look like a Flex application at all.<br />
I did not create the visual design but I implemented everything you see. I used Cairngorm and leveraged some webservices for the data. I liked working with the new Flash player 10 features like saving and encoding the images with a watermark.</p>
<p>Here is the link: <a href="http://culture.alberta.ca/archives/educationalresources/photographs/default.aspx">http://culture.alberta.ca/archives/educationalresources/photographs/default.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://alainthibodeau.com/blog/?feed=rss2&amp;p=107</wfw:commentRss>
		</item>
		<item>
		<title>Flex 3 and Air application icon bugs [Error 303]</title>
		<link>http://alainthibodeau.com/blog/?p=98</link>
		<comments>http://alainthibodeau.com/blog/?p=98#comments</comments>
		<pubDate>Thu, 28 May 2009 14:31:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Air]]></category>

		<guid isPermaLink="false">http://alainthibodeau.com/blog/?p=98</guid>
		<description><![CDATA[So there are lots of talk about this bug with “error 303” and the application icons. I read up a lot about it and I’ll share what worked for me.  
1. First, I put all my icons in a directory under the src folder called assets.
2. Then, in the –app.xml file I added the paths [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal" style="MARGIN: 0in 0in 10pt"><span style="font-size: small; font-family: Calibri;">So there are lots of talk about this bug with “error 303” and the application icons. I read up a lot about it and I’ll share what worked for me. <span style="mso-spacerun: yes"> </span></p>
<p>1. First, I put all my icons in a directory under the src folder called assets.</p>
<p>2. Then, in the –app.xml file I added the paths to these icons</span></p>
<p class="MsoNormal" style="MARGIN: 0in 0in 10pt"><span style="font-size: small; font-family: Calibri;">&lt;icon&gt;<br />
&lt;image16&#215;16&gt;assets/icon16.png&lt;/image16&#215;16&gt;<br />
&lt;image32&#215;32&gt;assets/icon32.png&lt;/image32&#215;32&gt;<br />
&lt;image48&#215;48&gt;assets/icon48.png&lt;/image48&#215;48&gt;<br />
&lt;image128&#215;128&gt;assets/icon128.png&lt;/image128&#215;128&gt;<br />
&lt;/icon&gt;<br />
</span></p>
<p class="MsoNormal" style="MARGIN: 0in 0in 10pt"><span style="font-size: small; font-family: Calibri;">3. I then created a bin-release directory in my application folder.</p>
<p>4. Once that was done I exported the project by going to the project-&gt;Export Release Build… menu item. After entering the digital signature and hitting next flex starts building and brings me to a sreen that shows me the Air file contents.</p>
<p>5. This is where the bug happens for me. Flex Builder does not transfer the files over to the air file contents.</p>
<p>6. I then open windows explorer and manually copy my icon files over to the bin-release/assets directory. Back to flex builder, I have to hit the back button and go back to the digital signature.</p>
<p>7. Then I hit next again, and Flex start building again.</p>
<p>8. Once I am back on the Air File Contents window I now see my icons.</p>
<p>9. I make sure they are checked. Then I hit finish and get no more error 303…</span></p>
<p class="MsoNormal" style="MARGIN: 0in 0in 10pt"> </p>
<p class="MsoNormal" style="MARGIN: 0in 0in 10pt"><span style="font-size: small; font-family: Calibri;">This is lame, but that is the way it is for now until they fix it. Hope this will save you time.</span></p>
<p class="MsoNormal" style="MARGIN: 0in 0in 10pt"><span style="font-size: small; font-family: Calibri;">Some more information about this:<br />
<a href="http://bugs.adobe.com/jira/browse/FB-11712" target="_blank">http://bugs.adobe.com/jira/browse/FB-11712</a><br />
<a href="http://chaos.corrupt.net/2009/01/06/avoiding-error-creating-air-file-303-when-compiling-a-flex-project-with-an-icon/" target="_blank">http://chaos.corrupt.net/2009/01/06/avoiding-error-creating-air-file-303-when-compiling-a-flex-project-with-an-icon/</a></span></p>
]]></content:encoded>
			<wfw:commentRss>http://alainthibodeau.com/blog/?feed=rss2&amp;p=98</wfw:commentRss>
		</item>
		<item>
		<title>Augmented Reality comes to flash with FLARToolKit</title>
		<link>http://alainthibodeau.com/blog/?p=94</link>
		<comments>http://alainthibodeau.com/blog/?p=94#comments</comments>
		<pubDate>Wed, 08 Apr 2009 14:33:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Air]]></category>

		<category><![CDATA[Flash]]></category>

		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://alainthibodeau.com/blog/?p=94</guid>
		<description><![CDATA[Things like this is why I started programming, it is the endless possibilities and the fact that we can now merge the reality with virtality. While the idea of augmented reality has been around for a while, it is not until recently that we could really start working with it at a personal level. I’ve [...]]]></description>
			<content:encoded><![CDATA[<p>Things like this is why I started programming, it is the endless possibilities and the fact that we can now merge the reality with virtality. While the idea of augmented reality has been <a href="http://en.wikipedia.org/wiki/Augmented_reality" target="_blank">around for a while</a>, it is not until recently that we could really start working with it at a personal level. I’ve finally found the time to play around with it, and there are several great resources around to get you started too. I’ve started learning it and learning how to use FLARToolKit along with papervision3D. I can tell you that my mind is spinning with possibilities and that I will be looking more into this in the future.<br />
First thing I thought of was this would be great for kids, <a href="http://playstation.joystiq.com/2008/08/20/new-playstation-eye-game-announced-eyepet/" target="_blank">seems like playstation thinks so too</a>. And <a href="http://duvet-dayz.com/archives/2008/12/03/1015/" target="_blank">this guy</a> as well. How about baseball cards? <a href="http://www.nytimes.com/2009/03/09/technology/09topps.html" target="_blank">Look at this</a>. How about adding air? No, not Adobe Air, but actually blowing into your microphone to make windmills spin! <a href="http://ge.ecomagination.com/smartgrid/?c_id=Matter#/augmented_reality" target="_blank">Check this out</a>.</p>
<p>Augmented reality has arrived to flash and there is definitely some coolness, now let’s find the business to it. I’ll post future experiments and findings on this here, so stay tuned. I haven’t checked to see if the adult industry found this yet, they usually push technology advancements….</p>
<p>Here are links to get you started:<br />
<a href="http://saqoosha.net/en/flartoolkit/start-up-guide/" target="_blank">http://saqoosha.net/en/flartoolkit/start-up-guide/</a><br />
<a href="http://saqoosha.net/en/2009/02/02/1694/" target="_blank">http://saqoosha.net/en/2009/02/02/1694/</a><br />
<a href="http://flash.tarotaro.org/blog/2008/12/14/artoolkit-marker-generator-online-released/" target="_blank">ARToolKit Marker Generator</a><br />
<a href="http://theflashblog.com/?p=901" target="_blank">Lee’s tutorial</a><br />
<a href="http://www.mikkoh.com/blog/?p=182" target="_blank">Mikko’s tutorial</a></p>
]]></content:encoded>
			<wfw:commentRss>http://alainthibodeau.com/blog/?feed=rss2&amp;p=94</wfw:commentRss>
		</item>
		<item>
		<title>FMS 3.5 and Flex 3 - How do I record data over time with NetStream.send()?</title>
		<link>http://alainthibodeau.com/blog/?p=82</link>
		<comments>http://alainthibodeau.com/blog/?p=82#comments</comments>
		<pubDate>Fri, 03 Apr 2009 14:45:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Flash Media Server]]></category>

		<guid isPermaLink="false">http://alainthibodeau.com/blog/?p=82</guid>
		<description><![CDATA[After I learned how to work with remote objects, I learned something that I did not know existed. This is the ability to record data over time. This allows us to store user or application actions over time. This data is saved in an flv file on the server thru the NetStream object. Personally, I [...]]]></description>
			<content:encoded><![CDATA[<p>After <a href="http://alainthibodeau.com/blog/?p=75">I learned how to work with remote objects</a>, I learned something that I did not know existed. This is the ability to record data over time. This allows us to store user or application actions over time. This data is saved in an flv file on the server thru the NetStream object. Personally, I find this to be very powerfull and can think of several ways of using this. In the meantime, I’ve created a sample application that demonstates how this works in flex.</p>
<p>In fact, it is very similar to the remote objects example, and it starts by running the init function upon creation complete. We then create a NetConnection. Once it is established, we call the openNetstream function that instantiates a NetStream object and assigns it a generic object to store the callback aliases. Once that is all set up the netstream starts to record, the syntax is the same as if we were recording from the webcam. </p>
<p>At this point the stream is recording, you can click on the record button, which does nothing on the UI, but in the backend it is making calls to the sendValues function with the hello world argument. This information is “recorded” and saved into the stream to the flv file on the server. Once you’ve clicked a few times, you can click on the play button. This will load the flv file and play in real time the saved data, which makes calls to the function sendValues which in turn will trace “hello world” as many times as you previously clicked on the record button.</p>
<p>This example is very basic and only works one way, which means you have to start the app again to test it over, but it gives you a good idea on how this works. Check out the send method of the NetStream object in the help files for more ways to work with it. Powerful stuff!</p>
<p>Here is the code:</p>
<div class="codesnip-container" >
<div class="codesnip" style="font-family: monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="sc3"><span class="re1">&lt;?xml</span> <span class="re0">version</span>=<span class="st0">&quot;1.0&quot;</span> <span class="re0">encoding</span>=<span class="st0">&quot;utf-8&quot;</span><span class="re2">?&gt;</span></span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc3"><span class="re1">&lt;mx:Application</span> <span class="re0">xmlns:mx</span>=<span class="st0">&quot;http://www.adobe.com/2006/mxml&quot;</span> </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">layout</span>=<span class="st0">&quot;absolute&quot;</span> </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">creationComplete</span>=<span class="st0">&quot;init()&quot;</span><span class="re2">&gt;</span></span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;mx:Script<span class="re2">&gt;</span></span></span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc2">&lt;![CDATA[</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; import mx.controls.Alert;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; private var nc:NetConnection;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; private var ns:NetStream;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; private var serverURL:String = &quot;rtmp://server/netstreamdata/myapp&quot;;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; private var callBacks:Object = new Object()</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; private function init():void</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nc = new NetConnection();</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; nc.client = this;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; nc.addEventListener(NetStatusEvent.NET_STATUS, connectHandler);</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; nc.connect(serverURL);</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; private function connectHandler(e:NetStatusEvent):void</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (e.info.code == &quot;NetConnection.Connect.Success&quot;) </span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; openNetStream();</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; private function openNetStream():void</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ns = new NetStream(nc);</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ns.client = callBacks;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; callBacks.sendValues = sendValues;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; callBacks.onMetaData = ns_onMetaData;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; callBacks.onCuePoint = ns_onCuePoint;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ns.publish(&quot;dataNetStream&quot;, &quot;record&quot;);</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; private function playStream():void</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2"> &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ns.close();</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2"> &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ns.play(&quot;dataNetStream&quot;, 0, -1);</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2"> &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //make sure this is public so others can access it</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public function sendValues(arg:String):void</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //update all clients.</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; trace(arg);</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; private function ns_onMetaData(item:Object):void </span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; trace(&quot;meta&quot;);</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; </span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; private function ns_onCuePoint(item:Object):void {</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //called when cuepoints are encountered</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; trace(&quot;cue&quot;);</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public function onBWDone():void{</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //called from asc</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; trace(&quot;onBandwithDone&quot;);</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } </span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ]]&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/mx:Script<span class="re2">&gt;</span></span></span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;mx:HBox<span class="re2">&gt;</span></span></span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;mx:Button</span> <span class="re0">id</span>=<span class="st0">&quot;btnSendValues&quot;</span> </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">label</span>=<span class="st0">&quot;record&quot;</span> </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">click</span>=<span class="st0">&quot;ns.send(&#8217;sendValues&#8217;,'hello world&#8217;);&quot;</span><span class="re2">/&gt;</span></span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;mx:Button</span> <span class="re0">id</span>=<span class="st0">&quot;btnPlayValues&quot;</span> </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">label</span>=<span class="st0">&quot;play&quot;</span> </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">click</span>=<span class="st0">&quot;playStream();&quot;</span><span class="re2">/&gt;</span></span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/mx:HBox<span class="re2">&gt;</span></span></span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc3"><span class="re1">&lt;/mx:Application<span class="re2">&gt;</span></span></span></div>
</li>
</ol>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://alainthibodeau.com/blog/?feed=rss2&amp;p=82</wfw:commentRss>
		</item>
		<item>
		<title>FMS 3.5 and Flex 3 - How do I use remote shared objects?</title>
		<link>http://alainthibodeau.com/blog/?p=75</link>
		<comments>http://alainthibodeau.com/blog/?p=75#comments</comments>
		<pubDate>Thu, 02 Apr 2009 19:58:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Flash Media Server]]></category>

		<guid isPermaLink="false">http://alainthibodeau.com/blog/?p=75</guid>
		<description><![CDATA[As I am learning FMS 3.5, I’ve come across shared objects and wanted to give a working example of it in Flex 3. Client shared objects can be really useful and behave similar to cookies in the browser. Remote shared objects are even more useful because you can share them with other people and call [...]]]></description>
			<content:encoded><![CDATA[<p>As I am learning FMS 3.5, I’ve come across shared objects and wanted to give a working example of it in Flex 3. Client shared objects can be really useful and behave similar to cookies in the browser. Remote shared objects are even more useful because you can share them with other people and call methods on them. Below is a basic example of a remote object working with FMS 3.5, it shows how to set data and call methods on the remote shared object.</p>
<p>The application calls the init() function upon the creation complete event, which creates a Net Connection object that we can work with. Once the connection is established the connectHandler function calls the getSharedObject function where the share object is actually created.</p>
<p>Inside this function the sharedObj is declared and given the name of “so” on the server at the location “nc.uri” which is the net connection address. sharedObjSyncHandler is the function called when there is a sync event on the object, which means when the data of the object changes or when you connect to it etc… The SyncEvent object is what gets returned from this event containing some information. Look up the SyncEvent’s changeList in the help docs for more details.  The sharedObj is persistant which means it will remain on the server and is not secure which means the object will not be served over https. This is set with the two last parameters on the getRemote method.</p>
<p>Now that we have an object ready and connected we can do stuff with it. The first thing I tested was to set data in the object. I created two buttons, one that calls the setData function and the other to get the data called getData. Notice that I had to use the setProperty on the object to set the color property in the object. In a real application, I would check to make sure we are connected to the object before trying to write to it by checking for “clear” on the sync handler. After setting the data, you can click on the get data button and see the data traced. Close the application and launch it again, then click the get data button to get the stored data from the server. Because we set the object as persistent, the shared object will remain on the server. It is stored under the application folder and the file extension is fso.</p>
<p>The other functionality of shared objects is the ability to call methods on it. I personally find this pretty powerful for several applications that I will one day share here. But for now, I show how to call a method on my shared object when clicking on the btnCallMethod. So, if you open two browsers with the application, click on the btnCallMethod in one application, you will see the text changing in the other browser. This demonstrates how both clients are sharing the object and update themselves when the data changes. I like it! </p>
<p>CODE:</p>
<div class="codesnip-container" >
<div class="codesnip" style="font-family: monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="sc3"><span class="re1">&lt;?xml</span> <span class="re0">version</span>=<span class="st0">&quot;1.0&quot;</span> <span class="re0">encoding</span>=<span class="st0">&quot;utf-8&quot;</span><span class="re2">?&gt;</span></span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc3"><span class="re1">&lt;mx:Application</span> <span class="re0">xmlns:mx</span>=<span class="st0">&quot;http://www.adobe.com/2006/mxml&quot;</span> </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">layout</span>=<span class="st0">&quot;absolute&quot;</span> </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">creationComplete</span>=<span class="st0">&quot;init()&quot;</span><span class="re2">&gt;</span></span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;mx:Script<span class="re2">&gt;</span></span></span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc2">&lt;![CDATA[</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; private var nc:NetConnection;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; private var ns:NetStream;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; private var serverURL:String = &quot;rtmp://server/sharedObjects/myapp2&quot;;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; private var callBacks:Object = new Object()</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; private function init():void</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nc = new NetConnection();</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; nc.client = this;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; nc.addEventListener(NetStatusEvent.NET_STATUS, connectHandler);</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; nc.connect(serverURL);</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; private function connectHandler(e:NetStatusEvent):void</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (e.info.code == &quot;NetConnection.Connect.Success&quot;) </span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; openNetStream();</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; private function openNetStream():void</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ns = new NetStream(nc);</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ns.client = callBacks;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; callBacks.sendValues = sendValues;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; callBacks.onMetaData = ns_onMetaData;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; callBacks.onCuePoint = ns_onCuePoint;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ns.publish(&quot;dataNetStream&quot;, &quot;record&quot;);</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; private function playStream():void</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2"> &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ns.play(&quot;dataNetStream&quot;, 0, -1);</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //make sure this is public so others can access it</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public function sendValues(arg:String):void</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //update all clients.</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; trace(arg);</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; private function ns_onMetaData(item:Object):void </span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; trace(&quot;meta&quot;);</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; </span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; private function ns_onCuePoint(item:Object):void {</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //called when cuepoints are encountered</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; trace(&quot;cue&quot;);</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public function onBWDone():void{</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //called from asc</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; trace(&quot;onBandwithDone&quot;);</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } </span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ]]&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/mx:Script<span class="re2">&gt;</span></span></span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;mx:HBox<span class="re2">&gt;</span></span></span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;mx:Button</span> <span class="re0">id</span>=<span class="st0">&quot;btnSendValues&quot;</span> </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">label</span>=<span class="st0">&quot;record&quot;</span> </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">click</span>=<span class="st0">&quot;ns.send(&#8217;sendValues&#8217;,'hello world&#8217;)&quot;</span><span class="re2">/&gt;</span></span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;mx:Button</span> <span class="re0">id</span>=<span class="st0">&quot;btnPlayValues&quot;</span> </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">label</span>=<span class="st0">&quot;play&quot;</span> </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">click</span>=<span class="st0">&quot;playStream();&quot;</span><span class="re2">/&gt;</span></span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/mx:HBox<span class="re2">&gt;</span></span></span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc3"><span class="re1">&lt;/mx:Application<span class="re2">&gt;</span></span></span></div>
</li>
</ol>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://alainthibodeau.com/blog/?feed=rss2&amp;p=75</wfw:commentRss>
		</item>
		<item>
		<title>Flex 3 - Databinding</title>
		<link>http://alainthibodeau.com/blog/?p=71</link>
		<comments>http://alainthibodeau.com/blog/?p=71#comments</comments>
		<pubDate>Thu, 26 Mar 2009 13:01:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://alainthibodeau.com/blog/?p=71</guid>
		<description><![CDATA[I&#8217;ve had this link for a while and never watched. I finally got around to it and I must say that it is very informative and thought I would pass it along.
Anything you ever wanted to know about how databinding in Flex works Michael Labriola covers it here.
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve had this link for a while and never watched. I finally got around to it and I must say that it is very informative and thought I would pass it along.</p>
<p>Anything you ever wanted to know about how databinding in Flex works Michael Labriola covers it <a href="http://link.brightcove.com/services/player/bcpid1733261879?bclid=1729365228&amp;bctid=1741212660" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://alainthibodeau.com/blog/?feed=rss2&amp;p=71</wfw:commentRss>
		</item>
		<item>
		<title>FMS 3.5 and Flex 3 - How do I load a video in AS3 from FMS?</title>
		<link>http://alainthibodeau.com/blog/?p=65</link>
		<comments>http://alainthibodeau.com/blog/?p=65#comments</comments>
		<pubDate>Tue, 24 Mar 2009 18:57:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Flash Media Server]]></category>

		<guid isPermaLink="false">http://alainthibodeau.com/blog/?p=65</guid>
		<description><![CDATA[I&#8217;ve started to learn Flash Media Server 3.5 and so far I like it. I got FMS server running and started the tutorials and all is running well. I did have a bit of a hart time to find good examples that intergrated FMS, Flex and AS3. So, I gathered some examples from the docs [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve started to learn Flash Media Server 3.5 and so far I like it. I got FMS server running and started the tutorials and all is running well. I did have a bit of a hart time to find good examples that intergrated FMS, Flex and AS3. So, I gathered some examples from the docs and <a href="http://blog.flexexamples.com">http://blog.flexexamples.com</a>. I combined them to create my own class; hopefully this can be helpful to you.</p>
<p>My class extends the UIComponent, and I start by creating a NetConnection. I assign it the client as being “this”, so any callbacks from the server will know where to be directed to. onBWDone() is a callback made by default from FMS and the vod application. I then declare some event listeners as we do not want to go any further if there are issues with our server connection. If I wanted to http stream, I would have passed my connection’s method connect a value of “null”, however, I want to connect to FMS at this point. So, I pass the address of my server.</p>
<p>Now that we have called the server with a netConnection in the constructor, the application waits for a reply from the server. This comes in the form of NetStatusEvent and sent to my netStatusHandler method. The NetStatusEvent contains an info code. From here we know if the connection was successful or not by which code was returned. If the code returned is “NetConnection.Connect.Success” than we can proceed and create the NetStream and the Video object.</p>
<p>In the connectStream() method, I start by declaring an object that will hold the meta data and cuepoints should there be any. This could have been another class, like they did in the docs of Flex. I deciced to go with flexexamples’ way, and I created an object. The next step is to create the netStream, specify its client which is the nsClient object. The last step for the NetStream is to give it the stream name to get off the server.</p>
<p>I then create a video object and attach the stream to it. I decided to apply the smoothing now in case in the future I want to stretch the movie. Finally, I add the movie to the display list. Take note that the ns_onMetaData method is called when the stream gets metadata; this is where I resize the movie based on this information. Below is the complete code.</p>
<p>VideoExample.as:</p>
<div class="codesnip-container" >
<div class="codesnip" style="font-family: monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">package</span> com.<span class="me1">alainthibodeau</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw2">import</span> flash.<span class="me1">events</span>.<span class="me1">NetStatusEvent</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw2">import</span> flash.<span class="me1">events</span>.<span class="me1">SecurityErrorEvent</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw2">import</span> flash.<span class="me1">media</span>.<span class="me1">Video</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw2">import</span> flash.<span class="me1">net</span>.<span class="me1">NetConnection</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw2">import</span> flash.<span class="me1">net</span>.<span class="me1">NetStream</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw2">import</span> mx.<span class="me1">controls</span>.<span class="kw3">Alert</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw2">import</span> mx.<span class="me1">core</span>.<span class="me1">UIComponent</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; </div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw2">public</span> <span class="kw2">class</span> VideoExample <span class="kw2">extends</span> UIComponent </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">private</span> <span class="kw2">var</span> serverURL:String = <span class="st0">&quot;rtmp://localhost/vod/&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">private</span> <span class="kw2">var</span> streamName:String = <span class="st0">&quot;mp4:sample1_1500kbps.f4v&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">private</span> <span class="kw2">var</span> connection:NetConnection;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">private</span> <span class="kw2">var</span> stream:NetStream;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">private</span> <span class="kw2">var</span> video:Video;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">private</span> <span class="kw2">var</span> meta:Object;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">public</span> <span class="kw2">function</span> VideoExample<span class="br0">&#40;</span><span class="br0">&#41;</span> </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//First, create the netconnection, assign some listeners and connect to the server.</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; connection = <span class="kw2">new</span> NetConnection<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; connection.<span class="me1">client</span> = <span class="kw1">this</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; connection.<span class="me1">addEventListener</span><span class="br0">&#40;</span>NetStatusEvent.<span class="me1">NET_STATUS</span>, netStatusHandler<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; connection.<span class="me1">addEventListener</span><span class="br0">&#40;</span>SecurityErrorEvent.<span class="me1">SECURITY_ERROR</span>, securityErrorHandler<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; connection.<span class="me1">connect</span><span class="br0">&#40;</span>serverURL<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">private</span> <span class="kw2">function</span> netStatusHandler<span class="br0">&#40;</span>event:NetStatusEvent<span class="br0">&#41;</span>:<span class="kw1">void</span> </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//Lets make sure we have a connection before moving on.</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//We could also check here for other codes, check the docs for NetStatusEvent codes.</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">switch</span> <span class="br0">&#40;</span>event.<span class="me1">info</span>.<span class="me1">code</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">case</span> <span class="st0">&quot;NetConnection.Connect.Success&quot;</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; connectStream<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">break</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">case</span> <span class="st0">&quot;NetStream.Play.StreamNotFound&quot;</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Alert</span>.<span class="me1">show</span><span class="br0">&#40;</span><span class="st0">&quot;An error occurred while connectiing to the server: &quot;</span> + serverURL + <span class="st0">&quot;nCode: &quot;</span> + event.<span class="me1">info</span>.<span class="me1">code</span>,<span class="st0">&quot;Error&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">break</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">case</span> <span class="st0">&quot;NetConnection.Connect.Rejected&quot;</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Alert</span>.<span class="me1">show</span><span class="br0">&#40;</span><span class="st0">&quot;An error occurred while connectiing to the server: &quot;</span> + serverURL + <span class="st0">&quot;nCode: &quot;</span> + event.<span class="me1">info</span>.<span class="me1">code</span>,<span class="st0">&quot;Error&quot;</span><span class="br0">&#41;</span>; &nbsp; &nbsp; &nbsp; </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">break</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">private</span> <span class="kw2">function</span> securityErrorHandler<span class="br0">&#40;</span>event:SecurityErrorEvent<span class="br0">&#41;</span>:<span class="kw1">void</span> </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; trace<span class="br0">&#40;</span><span class="st0">&quot;securityErrorHandler: &quot;</span> + event<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">private</span> <span class="kw2">function</span> connectStream<span class="br0">&#40;</span><span class="br0">&#41;</span>:<span class="kw1">void</span> </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//Create an object for the meta and cue points</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> nsClient:Object = <span class="br0">&#123;</span><span class="br0">&#125;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nsClient.<span class="me1">onMetaData</span> = ns_onMetaData;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nsClient.<span class="me1">onCuePoint</span> = ns_onCuePoint;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//Create the netstream object and pass it the client created above, and play the stream &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream = <span class="kw2">new</span> NetStream<span class="br0">&#40;</span>connection<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream.<span class="me1">client</span> = nsClient;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream.<span class="me1">play</span><span class="br0">&#40;</span>streamName<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//Create the video object and assign it our stream</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; video = <span class="kw2">new</span> Video<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; video.<span class="me1">attachNetStream</span><span class="br0">&#40;</span>stream<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; video.<span class="me1">smoothing</span> = <span class="kw2">true</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// put the video in the display list</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addChild<span class="br0">&#40;</span>video<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">private</span> <span class="kw2">function</span> ns_onMetaData<span class="br0">&#40;</span><span class="kw1">item</span>:Object<span class="br0">&#41;</span>:<span class="kw1">void</span> </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//Once we know the dimensions, change the video to match it.</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; video.<span class="me1">width</span> = <span class="kw1">item</span>.<span class="me1">width</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; video.<span class="me1">height</span> = <span class="kw1">item</span>.<span class="me1">height</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">private</span> <span class="kw2">function</span> ns_onCuePoint<span class="br0">&#40;</span><span class="kw1">item</span>:Object<span class="br0">&#41;</span>:<span class="kw1">void</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//called when cuepoints are encountered</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; trace<span class="br0">&#40;</span><span class="st0">&quot;cue&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">public</span> <span class="kw2">function</span> onBWDone<span class="br0">&#40;</span><span class="br0">&#41;</span>:<span class="kw1">void</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//called from asc</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; trace<span class="br0">&#40;</span><span class="st0">&quot;onBandwithDone&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> </div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">public</span> <span class="kw2">function</span> <span class="kw3">close</span><span class="br0">&#40;</span><span class="br0">&#41;</span>:<span class="kw1">void</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//called when the Netconnection is closed</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; trace<span class="br0">&#40;</span><span class="st0">&quot;close&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
</div>
<p>Now in my MXML, all I have to do is add my tag. I could also declare it in AS3 should I ever want to change it. Depends how it will be implemented I guess.</p>
<p>VideoExample.mxml:</p>
<div class="codesnip-container" >
<div class="codesnip" style="font-family: monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="sc3"><span class="re1">&lt;?xml</span> <span class="re0">version</span>=<span class="st0">&quot;1.0&quot;</span> <span class="re0">encoding</span>=<span class="st0">&quot;utf-8&quot;</span><span class="re2">?&gt;</span></span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc3"><span class="re1">&lt;mx:Application</span> </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">xmlns:mx</span>=<span class="st0">&quot;http://www.adobe.com/2006/mxml&quot;</span> </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">xmlns:alainthibodeau</span>=<span class="st0">&quot;com.alainthibodeau.*&quot;</span><span class="re2">&gt;</span></span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;alainthibodeau:VideoExample</span> <span class="re0">width</span>=<span class="st0">&quot;100%&quot;</span> <span class="re0">height</span>=<span class="st0">&quot;100%&quot;</span><span class="re2">/&gt;</span></span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li class="li1">
<div class="de1"><span class="sc3"><span class="re1">&lt;/mx:Application<span class="re2">&gt;</span></span></span></div>
</li>
</ol>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://alainthibodeau.com/blog/?feed=rss2&amp;p=65</wfw:commentRss>
		</item>
		<item>
		<title>Flex 3 - How do I incorporate addthis.com social bookmarking service?</title>
		<link>http://alainthibodeau.com/blog/?p=54</link>
		<comments>http://alainthibodeau.com/blog/?p=54#comments</comments>
		<pubDate>Fri, 20 Mar 2009 18:17:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Flex]]></category>

		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://alainthibodeau.com/blog/?p=54</guid>
		<description><![CDATA[I&#8217;ve recently needed to implement the addThis.com social bookmarking service in my flex application. I needed to pass a url to addthis with unique parameters based on certain conditions in the application.
Turns out it was pretty straight forward. I am sure there are several other ways to implement this, but this is how I did [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently needed to implement the addThis.com social bookmarking service in my flex application. I needed to pass a url to addthis with unique parameters based on certain conditions in the application.<br />
Turns out it was pretty straight forward. I am sure there are several other ways to implement this, but this is how I did it. I used the Externalinterface class to send the url and parameters to a js function in the html.</p>
<p>Basically, I am calling a function inside my flex application that declares 2 variables, gets the current path and then calls the javascript function sending the 2 variable values.<br />
In my case I had to strip the parameters from the url (if any), so I am removing everything after the ? from the href.</p>
<p>These are just stripped down snippets of code.</p>
<p><strong>AS3</strong></p>
<div class="codesnip-container" >
<div class="codesnip" style="font-family: monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">private</span> <span class="kw2">function</span> openAddThisWindow<span class="br0">&#40;</span><span class="br0">&#41;</span>:<span class="kw1">void</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> v1:String = v1;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> v2:int = <span class="nu0">2</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> urlWithParams:String = ExternalInterface.<span class="me1">call</span><span class="br0">&#40;</span><span class="st0">&quot;window.location.href.toString&quot;</span><span class="br0">&#41;</span>;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> urlSplit:Array = urlWithParams.<span class="me1">split</span><span class="br0">&#40;</span><span class="re0">/?/</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> urlNoParams = urlSplit<span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li class="li1">
<div class="de1">ExternalInterface.<span class="me1">call</span><span class="br0">&#40;</span><span class="st0">&quot;openAddThisWindow&quot;</span>,v1,v2,urlNoParams<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
</div>
<p>In the JS script on the html page I added this function that basically takes the params from flex and calls the addthis function that will open their html popup over my flex application.</p>
<p><strong>JS</strong></p>
<div class="codesnip-container" >
<div class="codesnip" style="font-family: monospace;">
<ol>
<li class="li1">
<div class="de1">&lt;script type=<span class="st0">&quot;text/javascript&quot;</span> src=<span class="st0">&quot;http://s7.addthis.com/js/200/addthis_widget.js&quot;</span>&gt;&lt;/script&gt;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&lt;script type=<span class="st0">&quot;text/javascript&quot;</span>&gt;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> addthis_pub=<span class="st0">&quot;youraccount&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">function</span> openAddThisWindow<span class="br0">&#40;</span>v1,v2,url<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> title = v1;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> url = url + <span class="st0">&quot;?v2=&quot;</span> + v2; </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> addthis_open<span class="br0">&#40;</span><span class="kw1">this</span>, <span class="st0">&#8216;email&#8217;</span>, url, title<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&lt;/script&gt;</div>
</li>
</ol>
</div>
</div>
<p>**Make sure you have &#8220;wmode&#8221;, &#8220;transparent&#8221; in your html template, otherwise the addthis popup will appear behind your flash in the browser. It is also a good idea to make a copy of this new html template in your flex project. Flex tends to overwrite it when you change sdk or swc&#8217;s for example..</p>
]]></content:encoded>
			<wfw:commentRss>http://alainthibodeau.com/blog/?feed=rss2&amp;p=54</wfw:commentRss>
		</item>
		<item>
		<title>Flex 3 - How do I make all my text uppercase or lowercase?</title>
		<link>http://alainthibodeau.com/blog/?p=50</link>
		<comments>http://alainthibodeau.com/blog/?p=50#comments</comments>
		<pubDate>Fri, 13 Mar 2009 14:57:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://alainthibodeau.com/blog/?p=50</guid>
		<description><![CDATA[I&#8217;ve found that the easiest way to make text all uppercase or lowercase is to apply it directly on the mxml tag. For example, on a label you use the string method toUpperCase() or toLowerCase() directly on the text property.
Example:




&#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62;


&#60;mx:Application xmlns:mx=&#34;http://www.adobe.com/2006/mxml&#34; layout=&#34;absolute&#34;&#62;


&#60;mx:Script&#62;


&#160; &#160; &#160; &#160; &#60;![CDATA[


&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve found that the easiest way to make text all uppercase or lowercase is to apply it directly on the mxml tag. For example, on a label you use the string method toUpperCase() or toLowerCase() directly on the text property.</p>
<p>Example:</p>
<div class="codesnip-container" >
<div class="codesnip" style="font-family: monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="sc3"><span class="re1">&lt;?xml</span> <span class="re0">version</span>=<span class="st0">&quot;1.0&quot;</span> <span class="re0">encoding</span>=<span class="st0">&quot;utf-8&quot;</span><span class="re2">?&gt;</span></span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc3"><span class="re1">&lt;mx:Application</span> <span class="re0">xmlns:mx</span>=<span class="st0">&quot;http://www.adobe.com/2006/mxml&quot;</span> <span class="re0">layout</span>=<span class="st0">&quot;absolute&quot;</span><span class="re2">&gt;</span></span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc3"><span class="re1">&lt;mx:Script<span class="re2">&gt;</span></span></span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc2">&lt;![CDATA[</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [Bindable]</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; private var lblText:String = &quot;this is my lower case string&quot;;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc2">&nbsp; &nbsp; &nbsp; &nbsp; ]]&gt;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc3"><span class="re1">&lt;/mx:Script<span class="re2">&gt;</span></span></span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc3"><span class="re1">&lt;mx:Label</span> <span class="re0">text</span>=<span class="st0">&quot;{lblText.toUpperCase()}&quot;</span> <span class="re2">/&gt;</span></span></div>
</li>
<li class="li1">
<div class="de1"><span class="sc3"><span class="re1">&lt;/mx:Application<span class="re2">&gt;</span></span></span></div>
</li>
</ol>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://alainthibodeau.com/blog/?feed=rss2&amp;p=50</wfw:commentRss>
		</item>
	</channel>
</rss>
