<?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>Jozef Chúťka&#039;s blog &#187; Flex</title>
	<atom:link href="http://blog.yoz.sk/tag/flex/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.yoz.sk</link>
	<description>My life, my work</description>
	<lastBuildDate>Tue, 31 Jan 2012 12:40:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Quick tip: Embedded MovieClip not MovieClip?</title>
		<link>http://blog.yoz.sk/2010/05/quick-tip-embedded-movieclip-not-movieclip/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=quick-tip-embedded-movieclip-not-movieclip</link>
		<comments>http://blog.yoz.sk/2010/05/quick-tip-embedded-movieclip-not-movieclip/#comments</comments>
		<pubDate>Thu, 06 May 2010 10:14:46 +0000</pubDate>
		<dc:creator>Jozef Chúťka</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash / Flex]]></category>
		<category><![CDATA[embed]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[MovieClip]]></category>
		<category><![CDATA[Sprite]]></category>
		<category><![CDATA[TypeError]]></category>

		<guid isPermaLink="false">http://blog.yoz.sk/?p=1586</guid>
		<description><![CDATA[When embedding MovieClips (with only one frame) from Flash .swf file into your Flex projects, you can fall into runtime issues: Why coercion failed when my symbol is for sure MovieClip? The answer is simple: Flash will type the symbol based on the number of frames in it&#8217;s timeline. If the symbol has only 1 [...]]]></description>
			<content:encoded><![CDATA[<p>When embedding MovieClips (with only one frame) from Flash .swf file into your Flex projects, you can fall into runtime issues:</p>
<pre class="brush: as3; title: ; notranslate">[Embed(source=&quot;assets/preloader.swf&quot;, symbol=&quot;preloader&quot;)]
public static const PRELOADER_CLASS:Class;
MovieClip(new Assets.PRELOADER_CLASS());</pre>
<pre class="brush: plain; title: ; notranslate">TypeError: Error #1034: Type Coercion failed: cannot convert *** to flash.display.MovieClip.</pre>
<p><span id="more-1586"></span></p>
<p>Why coercion failed when my symbol is for sure MovieClip? The answer is simple:</p>
<blockquote><p>Flash will type the symbol based on the number of frames in it&#8217;s timeline. If the symbol has only <strong>1 frame</strong> it will be typed as a <strong>Sprite</strong>, 2 or more frames it will be typed as a MovieClip.</p></blockquote>
<p>Possible solutions:</p>
<ul>
<li>add 1 more frame (so the frame count is more than 1)</li>
<li>or cast embedded asset as flash.display.Sprite (prefered while there is no need for MovieClip with one usable frame + Sprite container consumes less memory)</li>
</ul>
<p>The day is saved thanks to <a href="http://www.airtightinteractive.com/news/?p=112">Felix Turner</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.yoz.sk/2010/05/quick-tip-embedded-movieclip-not-movieclip/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex Charts &#8211; interpolating values in Series</title>
		<link>http://blog.yoz.sk/2009/12/flex-charts-interpolating-values-in-series/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=flex-charts-interpolating-values-in-series</link>
		<comments>http://blog.yoz.sk/2009/12/flex-charts-interpolating-values-in-series/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 10:12:16 +0000</pubDate>
		<dc:creator>Jozef Chúťka</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash / Flex]]></category>
		<category><![CDATA[Charts]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[interpolateValues]]></category>
		<category><![CDATA[LineChart]]></category>
		<category><![CDATA[LineSeries]]></category>
		<category><![CDATA[Stroke]]></category>

		<guid isPermaLink="false">http://blog.yoz.sk/?p=740</guid>
		<description><![CDATA[Recently, I felt into problem with chart when using interpolateValues parameter set to true. You expect it to work as described in Language Reference. And guess what, it works , but make sure you provide correct numeric values (not strings &#8211; those were problematic in my case). Parameter interpolateValues is able to draw a continuous [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.yoz.sk/wp-content/uploads/interpolateValues.png"><img src="http://blog.yoz.sk/wp-content/uploads/interpolateValues-200x100.png" alt="interpolateValues" title="interpolateValues" width="200" height="100" class="alignleft size-medium wp-image-741" /></a></p>
<p>Recently, I felt into problem with chart when using interpolateValues parameter set to true. You expect it to work as described in <a href="http://www.adobe.com/livedocs/flex/3/langref/mx/charts/series/LineSeries.html#interpolateValues">Language Reference</a>. And guess what, it works <img src='http://blog.yoz.sk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  , but make sure you provide correct numeric values (not strings &#8211; those were problematic in my case). Parameter interpolateValues is able to draw a continuous line by interpolating the missing value. Missing values means null (v1 in example) or when key is omited (v2).</p>
<p>If you want to use Charts in Flex, download <a href="http://www.adobe.com/cfusion/entitlement/index.cfm?e=flex3sdk">data visualization components for your flex builder</a> and copy content into sdk directory.</p>
<p><span id="more-740"></span></p>
<pre class="brush: xml; title: ; notranslate">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; layout=&quot;vertical&quot;
    backgroundColor=&quot;#ffffff&quot;&gt;
&lt;mx:Script&gt;
&lt;![CDATA[
    import mx.collections.ArrayCollection;

    [Bindable]
    private var dp:ArrayCollection = new ArrayCollection([
        {Month: &quot;Jan&quot;, v1: 1000, v2: 900, v3: &quot;800&quot;, v4: &quot;700&quot;},
        {Month: &quot;Feb&quot;, v1: null, v3: null},
        {Month: &quot;Mar&quot;, v1: 2000, v2: 1900, v3: &quot;1800&quot;, v4: &quot;1700&quot;}
    ]);
]]&gt;
&lt;/mx:Script&gt;

&lt;mx:Stroke id = &quot;s1&quot; color=&quot;blue&quot; weight=&quot;2&quot;/&gt;
&lt;mx:Stroke id = &quot;s2&quot; color=&quot;red&quot; weight=&quot;2&quot;/&gt;
&lt;mx:Stroke id = &quot;s3&quot; color=&quot;green&quot; weight=&quot;2&quot;/&gt;
&lt;mx:Stroke id = &quot;s4&quot; color=&quot;yellow&quot; weight=&quot;2&quot;/&gt;

&lt;mx:LineChart id=&quot;lineChart&quot; height=&quot;100%&quot; width=&quot;100%&quot; dataProvider=&quot;{dp}&quot;&gt;
    &lt;mx:horizontalAxis&gt;
        &lt;mx:CategoryAxis categoryField=&quot;Month&quot;/&gt;
    &lt;/mx:horizontalAxis&gt;
    &lt;mx:series&gt;
        &lt;mx:LineSeries yField=&quot;v1&quot; form=&quot;curve&quot; displayName=&quot;v1&quot;
            lineStroke=&quot;{s1}&quot; interpolateValues=&quot;true&quot;/&gt;
        &lt;mx:LineSeries yField=&quot;v2&quot; form=&quot;curve&quot; displayName=&quot;v2&quot;
            lineStroke=&quot;{s2}&quot; interpolateValues=&quot;true&quot;/&gt;
        &lt;mx:LineSeries yField=&quot;v3&quot; form=&quot;curve&quot; displayName=&quot;v3&quot;
            lineStroke=&quot;{s3}&quot; interpolateValues=&quot;true&quot;/&gt;
        &lt;mx:LineSeries yField=&quot;v4&quot; form=&quot;curve&quot; displayName=&quot;v4&quot;
            lineStroke=&quot;{s4}&quot; interpolateValues=&quot;true&quot;/&gt;
    &lt;/mx:series&gt;
&lt;/mx:LineChart&gt;
&lt;mx:Legend dataProvider=&quot;{lineChart}&quot; direction=&quot;horizontal&quot;/&gt;
&lt;/mx:Application&gt;</pre>
<p>Notice numeric vs. string values in dataProvider. Result:</p>
<p><a href="http://blog.yoz.sk/wp-content/uploads/interpolateValues.png"><img src="http://blog.yoz.sk/wp-content/uploads/interpolateValues.png" alt="interpolateValues" title="interpolateValues" width="643" height="323" class="alignnone size-full wp-image-741" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.yoz.sk/2009/12/flex-charts-interpolating-values-in-series/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>9 slice scale for bitmaps in flash (no hacks)</title>
		<link>http://blog.yoz.sk/2009/11/9-slice-scale-for-bitmaps-in-flash-no-hacks/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=9-slice-scale-for-bitmaps-in-flash-no-hacks</link>
		<comments>http://blog.yoz.sk/2009/11/9-slice-scale-for-bitmaps-in-flash-no-hacks/#comments</comments>
		<pubDate>Sun, 15 Nov 2009 10:37:22 +0000</pubDate>
		<dc:creator>Jozef Chúťka</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Flash / Flex]]></category>
		<category><![CDATA[9 slice scale]]></category>
		<category><![CDATA[Bitmap]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[solution]]></category>

		<guid isPermaLink="false">http://blog.yoz.sk/?p=645</guid>
		<description><![CDATA[9 slice scale is a nice feature, but when you try to use 9 slice in flash ide on MovieClip with bitmap, you will notice a problem. It will just not work as expected. So first thing you try is &#8220;Break Apart&#8221;, with same result. You are almost there, but due to the solution is [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.yoz.sk/wp-content/uploads/9slice_result_flash.png"><img src="http://blog.yoz.sk/wp-content/uploads/9slice_result_flash-200x168.png" alt="9slice_result_flash" title="9slice_result_flash" width="200" height="168" class="alignleft size-medium wp-image-649" /></a></p>
<p><a href="http://www.adobe.com/devnet/flex/quickstart/embedding_assets/#EmbeddingImagesScale9">9 slice scale</a> is a nice feature, but when you try to use 9 slice in flash ide on MovieClip with bitmap, you will notice a problem. It will just not work as expected. So first thing you try is &#8220;Break Apart&#8221;, with same result. You are almost there, but due to the solution is not documented you need a small hint: After break apart (ctrl + b), select each of nine slices one by one and group (ctrl + g) individually and voilà its done. See snapshot and result images&#8230;</p>
<div style="clear:both"></div>
<p><span id="more-645"></span></p>
<p>1. original image.png</p>
<p><a href="http://blog.yoz.sk/wp-content/uploads/9slice_image.png"><img src="http://blog.yoz.sk/wp-content/uploads/9slice_image.png" alt="9slice_image" title="9slice_image" width="30" height="30" class="alignnone size-full wp-image-646" /></a></p>
<p>2. <strong>symbol</strong> after break apart</p>
<p><a href="http://blog.yoz.sk/wp-content/uploads/9slice_flash_bitmap_break.png"><img src="http://blog.yoz.sk/wp-content/uploads/9slice_flash_bitmap_break.png" alt="9slice_flash_bitmap_break" title="9slice_flash_bitmap_break" width="207" height="180" class="alignnone size-full wp-image-647" /></a></p>
<p>3. <strong>symbol2</strong> after break apart and individual grouping</p>
<p><a href="http://blog.yoz.sk/wp-content/uploads/9slice_flash_bitmap.png"><img src="http://blog.yoz.sk/wp-content/uploads/9slice_flash_bitmap.png" alt="9slice_flash_bitmap" title="9slice_flash_bitmap" width="210" height="181" class="alignnone size-full wp-image-648" /></a></p>
<p>4. result in flash cs4 ide <strong>symbol</strong>, <strong>symbol2</strong></p>
<p><a href="http://blog.yoz.sk/wp-content/uploads/9slice_result_flash.png"><img src="http://blog.yoz.sk/wp-content/uploads/9slice_result_flash.png" alt="9slice_result_flash" title="9slice_result_flash" width="326" height="274" class="alignnone size-full wp-image-649" /></a></p>
<p>5. 9 slice scale in flex (maintainAspectRatio used just for purpose, no impact on 9 slice scale)</p>
<pre class="brush: xml; title: ; notranslate">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; layout=&quot;horizontal&quot;&gt;
&lt;mx:Script&gt;
&lt;![CDATA[
    [Embed(source=&quot;image.png&quot;,
        scaleGridTop=&quot;5&quot;, scaleGridBottom=&quot;15&quot;,
        scaleGridLeft=&quot;5&quot;, scaleGridRight=&quot;15&quot;)]
    public static const imageClass:Class;

    [Embed(source=&quot;lib.swf&quot;, symbol=&quot;symbol&quot;)]
    public static const symbolClass:Class;

    [Embed(source=&quot;lib.swf&quot;, symbol=&quot;symbol2&quot;)]
    public static const symbol2Class:Class;
]]&gt;
&lt;/mx:Script&gt;
&lt;mx:Image width=&quot;100&quot; height=&quot;200&quot; source=&quot;{imageClass}&quot;
    maintainAspectRatio=&quot;false&quot;/&gt;
&lt;mx:Image width=&quot;100&quot; height=&quot;200&quot; source=&quot;{symbolClass}&quot;
    maintainAspectRatio=&quot;false&quot;/&gt;
&lt;mx:Image width=&quot;100&quot; height=&quot;200&quot; source=&quot;{symbol2Class}&quot;
    maintainAspectRatio=&quot;false&quot;/&gt;
&lt;/mx:Application&gt;</pre>
<p>6. result from flex</p>
<p><a href="http://blog.yoz.sk/wp-content/uploads/9slice_result_flex.png"><img src="http://blog.yoz.sk/wp-content/uploads/9slice_result_flex.png" alt="9slice_result_flex" title="9slice_result_flex" width="357" height="231" class="alignnone size-full wp-image-652" /></a></p>
<p>gSkinner released <a href="http://www.gskinner.com/blog/archives/2010/04/bitmapslice9_sc.html">BitmapSlice9 command for Flash Pro</a>. It makes all this happen by one click.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.yoz.sk/2009/11/9-slice-scale-for-bitmaps-in-flash-no-hacks/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Flex 3 profiling not working (update)</title>
		<link>http://blog.yoz.sk/2009/10/flex-3-profiling-not-working/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=flex-3-profiling-not-working</link>
		<comments>http://blog.yoz.sk/2009/10/flex-3-profiling-not-working/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 16:03:53 +0000</pubDate>
		<dc:creator>Jozef Chúťka</dc:creator>
				<category><![CDATA[Flash / Flex]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[debug player]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[mm.cfg]]></category>
		<category><![CDATA[port]]></category>
		<category><![CDATA[PreloadSwf]]></category>
		<category><![CDATA[profiler]]></category>
		<category><![CDATA[web browser]]></category>

		<guid isPermaLink="false">http://blog.yoz.sk/?p=527</guid>
		<description><![CDATA[The profiler is a part of the Flex Builder IDE, that listens for messages from the profiler agent. The profiler agent is a swf launched in parallel to your main swf. It is located in your Flex workspace at .metadata/.plugins/com.adobe.flash.profiler/ProfilerAgent.swf. Your IDE gets this agent to start by editing your mm.cfg and adding a “PreloadSwf” [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>The profiler is a part of the Flex Builder IDE, that listens for messages from the profiler agent. The profiler agent is a swf launched in parallel to your main swf. It is located in your Flex workspace at .metadata/.plugins/com.adobe.flash.profiler/ProfilerAgent.swf. Your IDE gets this agent to start by editing your mm.cfg and adding a “PreloadSwf” line. The agent uses the flash.sampler.* API to gather data on your main swf, and sends it to the IDE using TCP on a preconvened port. This port is 9999 by default, you can change it in Preferences/Flex/Profiler/Connections.</p></blockquote>
<p>If you can not get your profiler working, there are few methods you should try:</p>
<ul>
<li>close all other tabs</li>
<li>install debug player</li>
<li>change browser</li>
<li>change port</li>
<li>disable firewall / antivirus</li>
<li>define PreloadSwf path</li>
<li>localhost / 127.0.0.1</li>
<li>allocate console</li>
<li>ultimate methods (what worked for me)</li>
</ul>
<p><span id="more-527"></span></p>
<h3>Update (Feb 12, 2010): Close all other tabs</h3>
<p>Fastest thing to do is to close all other tabs in your browser, close all other instances of browser and than try profile again.</p>
<h3>Install debug player</h3>
<p>Make sure you have installed <a href="http://www.adobe.com/support/flashplayer/downloads.html">debug version of flash player</a>. Well, you probably have&#8230; so skip this one.</p>
<h3>Change browser</h3>
<p>It may seem to be weird but it works. All browsers (chrome, opera, ff) except for internet explorer use same flash player, switching to any other browser may fix your profiling. You can change browser in flex / window / preferences / general / web browser / use external / add &#8230; </p>
<h3>Change port</h3>
<p>Try change default port (flex / window / preferences / flex / profiler / connections / port number) to something else (7777, 8888), there were reports that simple port change helped to solve problem.</p>
<h3>Disable firewall / antivirus</h3>
<p>Do this on your own, if you are not sure about what you are doing call admin. The aim is to unblock port that is used for profiling. Try disable default windows (os) firewall or make exception. To make exception on your eset smar security use following procedure:</p>
<ul>
<li>Open Smart Security.</li>
<li>If you are in standard mode and do not see a menu in the top right hand corner click Setup->Toggle Advanced Mode.</li>
<li>Click on the ‘Enter entire advanced setup tree…’ link at the bottom.</li>
<li>Click Personal Firewall->Protocol Filtering.</li>
<li>Make sure ‘Enable application protocol content filtering’ is selected.</li>
<li>Below that select Redirect traffic for filtering->HTTP and POP3 ports.</li>
</ul>
<h3>Define PreloadSwf path</h3>
<p>If your IDE does not edit your <strong>mm.cfg</strong> file properly, change PreloadSwf property in manually. This is undocumented, but adding the property manually is reported as working solution. Try add the following line to the file</p>
<pre>PreloadSwf= C:/...flexworkspace/.metadata/.plugins/com.adobe.flash.profiler/ProfilerAgent.swf?host=localhost&#038;port=9999</pre>
<p>If you got the the path to the profile agent wrong. You can check this by looking in the flash text logs. If the preload went wrong, you should see a message like:</p>
<pre>PreloadSwf paths must be local trusted: C:/...flexworkspace/.metadata/.plugins/com.adobe.flash.profiler/ProfilerAgent.swf?host=localhost&#038;port=9999</pre>
<p>Make sure path directs to local trusted area!</p>
<h3>localhost / 127.0.0.1</h3>
<p>If the profiler in Flash Builder does not work, check if localhost does resolve to 127.0.0.1 on your machine. If not fix the hosts file. &#8211; <a href="http://twitter.com/quasimondo">Mario Klingemann (quasimondo)</a></p>
<h3>allocate console</h3>
<p>If the Flash Profiler does not start: switch off &#8220;Allocate Console&#8221; in the Profile Configurations Common tab. &#8211; <a href="http://twitter.com/quasimondo">Mario Klingemann (quasimondo)</a></p>
<h3>Ultimate methods (what worked for me)</h3>
<p>I spent almost hour trying to figure out why my profiler wont connect in one workspace and works just fine in another even with same settings. I tried every mentioned method but niether worked. While randomly trying all methods I finally came to something new:</p>
<blockquote><p>Profiling can only be performed on the debug version of an application.</p></blockquote>
<p>What the hell? Of course I am using debug player and pushing &#8220;profile it&#8221; button so what is wrong? I tried reinstall player to <a href="http://kb2.adobe.com/cps/142/tn_14266.html">other versions</a> but did not worked. Well, if you were able to came this far you may wonder what solution I finally figurd out. It is definitely not elegant solution nor correct but works, thats why I called it ultimate <img src='http://blog.yoz.sk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  . <strong>Click profile button as fast as you can (5 times in row)</strong> and behold! Randomly you get your profile perspective connected and working (if not, try few times)! So definitely a flex bug.</p>
<p>Sources:</p>
<ul>
<li><a href="http://www.grindstonemedia.net/2008/06/29/flex-profiler-connection-problems/">http://www.grindstonemedia.net/2008/06/29/flex-profiler-connection-problems/</a></li>
<li><a href="http://arielsommeria.com/blog/2008/12/22/getting-the-flex-profiler-to-work/">http://arielsommeria.com/blog/2008/12/22/getting-the-flex-profiler-to-work/</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.yoz.sk/2009/10/flex-3-profiling-not-working/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Flex IFrame &#8211; Web browser in flash (update)</title>
		<link>http://blog.yoz.sk/2009/10/flex-iframe-web-browser-in-flash/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=flex-iframe-web-browser-in-flash</link>
		<comments>http://blog.yoz.sk/2009/10/flex-iframe-web-browser-in-flash/#comments</comments>
		<pubDate>Mon, 19 Oct 2009 10:45:21 +0000</pubDate>
		<dc:creator>Jozef Chúťka</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash / Flex]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[Canvas]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[FlexIFrame]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[IFrame]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.yoz.sk/?p=139</guid>
		<description><![CDATA[You can not have a web browser inside your web flash applications right? Well, you can! This solution uses html iframe to generate fake build in browser. So the behaviour of the browser in flash is the same as the one you are previewing this flash in (it is the same one). The best part [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.yoz.sk/wp-content/uploads/Clipboard02.png"><img src="http://blog.yoz.sk/wp-content/uploads/Clipboard02-200x196.png" alt="Clipboard02" title="Clipboard02" width="200" height="196" class="alignleft size-medium wp-image-370" /></a></p>
<p>You can not have a web browser inside your web flash applications right? Well, you can! This solution uses html iframe to generate fake build in browser. So the behaviour of the browser in flash is the same as the one you are previewing this flash in (it is the same one). The best part of it is, you can manipulate with the position and size of this browser directly from flash. <a href="http://classes.yoz.sk/sk/yoz/html/IFrame.as">sk.yoz.html.IFrame</a> solution was inspired by <a href="http://www.netthreads.co.uk/">Alistair Rutherford, www.netthreads.co.uk</a>.</p>
<ul style="float: left;">
<li><a href="http://classes.yoz.sk/sk/yoz/html/IFrame.as">sk.yoz.html.IFrame</a></li>
<li>FlexIFrame.js</li>
<li>Application</li>
<li>Application html</li>
</ul>
<p><span id="more-139"></span></p>
<p style="clear:both;">Flex Iframe application</p>
<p><iframe src="http://blog.yoz.sk/examples/flexIframe/" width="100%" height="350" style="border:none;"></iframe></p>
<p>Core of this thing is <a href="http://classes.yoz.sk/sk/yoz/html/IFrame.as">sk.yoz.html.IFrame</a> class. It extends Canvas that is used to inherit properties and methods for positioning and sizing. There is one in order to make it work &#8211; every IFrame element must have id!</p>
<pre class="brush: as3; title: ; notranslate">package sk.yoz.html
{
    import flash.events.Event;
    import flash.external.ExternalInterface;
    import flash.geom.Point;

    import mx.containers.Canvas;

    public class IFrame extends Canvas
    {
        public var methodResize:String = &quot;FlexIFrame.resize&quot;;
        public var methodMove:String = &quot;FlexIFrame.move&quot;;
        public var methodNavigate:String = &quot;FlexIFrame.navigate&quot;;
        public var methodVisibility:String = &quot;FlexIFrame.visibility&quot;;

        public var positionChanged:Boolean = false;
        public var sizeChanged:Boolean = false;

        private var _autoResize:Boolean = false;
        private var _url:String = '';

        public function IFrame()
        {
            super();
            addEventListener(Event.ADDED_TO_STAGE, addedToStageHandler)
        }

        override public function set id(value:String):void
        {
            super.id = value;
        }

        protected function addedToStageHandler(event:Event):void
        {
            positionChanged = true;
            sizeChanged = true;
            invalidateProperties();
        }

        public function set autoResize(value:Boolean):void
        {
            _autoResize = value;
            if(value)
                addEventListener(Event.RESIZE, autoResizeHandler);
            else
                removeEventListener(Event.RESIZE, autoResizeHandler);
        }

        public function get autoResize():Boolean
        {
            return _autoResize;
        }

        protected function autoResizeHandler(event:Event):void
        {
            positionChanged = true;
            sizeChanged = true;
            invalidateProperties();
        }

        override protected function commitProperties():void
        {
            super.commitProperties();

            if(positionChanged)
            {
                var point:Point = localToGlobal(new Point(0, 0));
                callJS(methodMove, point.x, point.y);
                positionChanged = false;
            }

            if(sizeChanged)
            {
                callJS(methodResize, width, height);
                sizeChanged = false;
            }
        }

        public function set url(value:String):void
        {
            _url = value;
            callJS(methodNavigate, value)
        }

        public function get url():String
        {
            return _url;
        }

        protected function callJS(method:String, ... values):void
        {
            if(!id)
                throw new Error(&quot;IFrame id is not defined&quot;);
            var args:Array = [method, id];
            try
            {
                ExternalInterface.call.apply(ExternalInterface, args.concat(values));
            }
            catch(error:Error)
            {
                trace(error.message);
            }
        }

        override public function set visible(value:Boolean):void
        {
            super.visible = value;
            callJS(methodVisibility, value);
        }

        override public function set width(value:Number):void
        {
            super.width = value;
            callJS(methodResize, value, height);
        }

        override public function set height(value:Number):void
        {
            super.height = value;
            callJS(methodResize, width, value);
        }

        override public function set x(value:Number):void
        {
            super.x = value;
            var point:Point = localToGlobal(new Point(0, 0));
            callJS(methodMove, point.x, point.y);
        }

        override public function set y(value:Number):void
        {
            super.y = value;
            var point:Point = localToGlobal(new Point(0, 0));
            callJS(methodMove, point.x, point.y);
        }
    }
}</pre>
<p> FlexIFrame.js is JavaScript file. It uses your flex IFrame id from to create (html iframe) or use html element (any element) with the same id (id in flash = id in html). So you can use your prefabricated html elements (banners etc).</p>
<pre class="brush: jscript; title: ; notranslate">var FlexIFrame = {
    get: function(id)
    {
        var iframe = document.getElementById(id);
        if(!iframe)
            return FlexIFrame.create(id);
        return iframe;
    },

    create: function(id)
    {
        var iframe = document.createElement('iframe');
        iframe.id = id;
        iframe.frameborder = 0;
        iframe.style.position = &quot;absolute&quot;;
        iframe.style.zIndex = 1;
        iframe.style.border = &quot;none&quot;;
        document.body.insertBefore(iframe, document.body.firstChild);
        return iframe;
    },

    resize: function(id, width, height)
    {
        var iframe = FlexIFrame.get(id);
        iframe.style.width = width + &quot;px&quot;;
        iframe.style.height = height + &quot;px&quot;;
    },

    move: function(id, x, y)
    {
        var iframe = FlexIFrame.get(id);
        iframe.style.left = x + &quot;px&quot;;
        iframe.style.top = y + &quot;px&quot;;
    },

    navigate: function(id, url)
    {
        var iframe = FlexIFrame.get(id);
        iframe.src = url;
    },

    visibility: function(id, visible)
    {
        var iframe = FlexIFrame.get(id);
        iframe.style.display = visible ? &quot;block&quot; : &quot;none&quot;;
    }
}</pre>
<p>This is simple applicationion presenting draggable TitleWindow with &#8220;web browser&#8221; inside:</p>
<pre class="brush: xml; title: ; notranslate">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; layout=&quot;vertical&quot; applicationComplete=&quot;init()&quot; xmlns:html=&quot;sk.yoz.html.*&quot;&gt;
&lt;mx:Script&gt;
&lt;![CDATA[
    private function init():void
    {
        go();
    }

    private function go():void
    {
        iframe.url = iframeURL.text;
    }

    private function mouseDownHandler():void
    {
        container.startDrag();
        container.addEventListener(Event.ENTER_FRAME, enterFrameDrag);
    }

    private function mouseUpHandler():void
    {
        container.stopDrag();
    }

    private function enterFrameDrag(event:Event):void
    {
        iframe.positionChanged = true;
        iframe.invalidateProperties();
    }
]]&gt;
&lt;/mx:Script&gt;
&lt;mx:TitleWindow id=&quot;container&quot; layout=&quot;vertical&quot; width=&quot;300&quot; height=&quot;300&quot;
    mouseDown=&quot;mouseDownHandler()&quot; mouseUp=&quot;mouseUpHandler()&quot; &gt;
    &lt;mx:HBox width=&quot;100%&quot;&gt;
        &lt;mx:TextInput id=&quot;iframeURL&quot; text=&quot;http://blog.yoz.sk&quot; width=&quot;100%&quot;
            enter=&quot;go()&quot;/&gt;
        &lt;mx:Button label=&quot;Go&quot; click=&quot;go()&quot;/&gt;
    &lt;/mx:HBox&gt;
    &lt;html:IFrame width=&quot;100%&quot; height=&quot;100%&quot; id=&quot;iframe&quot; autoResize=&quot;true&quot;/&gt;
&lt;/mx:TitleWindow&gt;
&lt;/mx:Application&gt;</pre>
<p>Finally do not forget to add flexiframe.js into your .html file:</p>
<pre class="brush: xml; title: ; notranslate">&lt;html&gt;
    &lt;head&gt;
        &lt;script type=&quot;text/javascript&quot; src=&quot;js/flexiframe.js&quot;&gt;&lt;/script&gt;
        ...</pre>
<p>Update (Feb 8, 2010): flexiframe.js resize() method uses style property for width and height (instead of original html element width, height)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.yoz.sk/2009/10/flex-iframe-web-browser-in-flash/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>Embedding assets wisely</title>
		<link>http://blog.yoz.sk/2009/10/embedding-assets-wisely/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=embedding-assets-wisely</link>
		<comments>http://blog.yoz.sk/2009/10/embedding-assets-wisely/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 08:16:07 +0000</pubDate>
		<dc:creator>Jozef Chúťka</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Flash / Flex]]></category>
		<category><![CDATA[asset]]></category>
		<category><![CDATA[Bitmap]]></category>
		<category><![CDATA[Class]]></category>
		<category><![CDATA[embed]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[SpriteAsset]]></category>
		<category><![CDATA[symbol]]></category>

		<guid isPermaLink="false">http://blog.yoz.sk/?p=302</guid>
		<description><![CDATA[You can embed various types of assets in your Adobe Flex applications (.jpeg, .png, .swf, .mp3, .svg, .ttf &#8230;). Embedded assets are compiled into the SWF file of your Flex application. They are not loaded at run time and you do not have to deploy the original asset files with your application. Read more about [...]]]></description>
			<content:encoded><![CDATA[<p>You can embed various types of assets in your Adobe Flex applications (.jpeg, .png, .swf, .mp3, .svg, .ttf &#8230;). Embedded assets are compiled into the SWF file of your Flex application. They are not loaded at run time and you do not have to deploy the original asset files with your application. Read more about embedding assets <a href="http://www.adobe.com/devnet/flex/quickstart/embedding_assets/">on Adobe</a>.</p>
<p>Basics first. How to make your symbol from Flash library visible for Flex (see images on the bottom of the artice):</p>
<ul>
<li>1. Create your symbol and linkage (library (Ctrl+L) / {your symbol} / Linkage&#8230;).</li>
<li>2. Linkage Properties, set your class name that will be used in [Embed] meta.</li>
<li>3. Export .swf file and make Assets.as.</li>
</ul>
<p><span id="more-302"></span></p>
<p>It is very handy to use central assets class. This is how I make my assets accessible in Flex application:</p>
<pre class="brush: as3; title: ; notranslate">package
{
    import mx.core.SpriteAsset;

    public class Assets extends Object
    {
        // change/to/your/uber/cool/path/and/filename.whatsoever
        // you can also embed graphic files (.jpeg, .png, )
        [Embed(source=&quot;../libs/assets.swf#symbol1&quot;)]
        public static const symbol1Class:Class;
        public static const symbol1SpriteAsset:SpriteAsset = new symbol1Class();

        [Embed(source=&quot;../libs/assets.swf&quot;, symbol=&quot;symbol2&quot;)]
        public static const symbol2Class:Class;

        // embedding Bitmap
        [Embed(source=&quot;../libs/image.png&quot;)]
        public static const imageClass:Class;
        public static const imageBitmap:Bitmap = new imageClass();

        public function Assets()
        {
            super();
        }
    }
}</pre>
<p>There are two ways how to ask for your symbol from .swf library &#8211; <em>1. source=&#8221;&#8230;#symbol1&#8243;</em> or <em>2. source=&#8221;&#8230;&#8221; symbol=&#8221;symbol2&#8243;</em>. Symbol name is whatever you set in Linkage Properties Class in Flash (not symbol name in library!).</p>
<p>Usage example:</p>
<pre class="brush: as3; title: ; notranslate">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; layout=&quot;horizontal&quot; applicationComplete=&quot;init()&quot;&gt;
&lt;mx:Script&gt;
&lt;![CDATA[
    import Assets;

    private function init():void
    {
        container1.setStyle(&quot;backgroundImage&quot;, Assets.symbol1Class);
        container2.setStyle(&quot;backgroundImage&quot;, Assets.symbol2Class);
        container3.addChild(Assets.symbol1SpriteAsset);
    }
]]&gt;
&lt;/mx:Script&gt;
&lt;mx:Box id=&quot;container1&quot; width=&quot;100&quot; height=&quot;100&quot;/&gt;
&lt;mx:Box id=&quot;container2&quot; width=&quot;100&quot; height=&quot;100&quot;/&gt;
&lt;mx:UIComponent id=&quot;container3&quot; width=&quot;100&quot; height=&quot;100&quot;/&gt;
&lt;/mx:Application&gt;</pre>
<p>Embedding proccess and example result in images:</p>
<p><div id="attachment_305" class="wp-caption alignnone" style="width: 210px"><a href="http://blog.yoz.sk/wp-content/uploads/how_to_linkage_symbol.png"><img src="http://blog.yoz.sk/wp-content/uploads/how_to_linkage_symbol-200x157.png" alt="Flash linkage symbol" title="how_to_linkage_symbol" width="200" height="157" class="size-medium wp-image-305" /></a><p class="wp-caption-text">Flash linkage symbol</p></div><br />
<div id="attachment_306" class="wp-caption alignnone" style="width: 210px"><a href="http://blog.yoz.sk/wp-content/uploads/linkage_properties.png"><img src="http://blog.yoz.sk/wp-content/uploads/linkage_properties-200x158.png" alt="Flash linkage properties" title="linkage_properties" width="200" height="158" class="size-medium wp-image-306" /></a><p class="wp-caption-text">Flash linkage properties</p></div><br />
<div id="attachment_307" class="wp-caption alignnone" style="width: 210px"><a href="http://blog.yoz.sk/wp-content/uploads/embeded.png"><img src="http://blog.yoz.sk/wp-content/uploads/embeded-200x125.png" alt="Flex embedded symbols" title="embeded" width="200" height="125" class="size-medium wp-image-307" /></a><p class="wp-caption-text">Flex embedded symbols</p></div></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.yoz.sk/2009/10/embedding-assets-wisely/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Update: ActionScript 3 singleton pattern</title>
		<link>http://blog.yoz.sk/2009/10/actionscript-singleton-pattern/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=actionscript-singleton-pattern</link>
		<comments>http://blog.yoz.sk/2009/10/actionscript-singleton-pattern/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 09:20:26 +0000</pubDate>
		<dc:creator>Jozef Chúťka</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Flash / Flex]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[instance]]></category>
		<category><![CDATA[lock]]></category>
		<category><![CDATA[private]]></category>
		<category><![CDATA[singleton]]></category>

		<guid isPermaLink="false">http://blog.yoz.sk/?p=81</guid>
		<description><![CDATA[In software engineering, the singleton pattern is a design pattern that is used to restrict instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the system. The concept is sometimes generalized to systems that operate more efficiently when only one object exists, or that [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>In software engineering, the singleton pattern is a design pattern that is used to restrict instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the system. The concept is sometimes generalized to systems that operate more efficiently when only one object exists, or that restrict the instantiation to a certain number of objects (say, five). Some consider it an anti-pattern, judging that it is overused, introduces unnecessary limitations in situations where a sole instance of a class is not actually required, and introduces global state into an application. (<a href="http://en.wikipedia.org/wiki/Singleton_pattern">wikipedia</a>)</p></blockquote>
<p>In search of the best actionscript 3 singleton pattern I came to this one. It uses private lock so user is not allowed to create new instance&#8230;</p>
<p><span id="more-81"></span></p>
<pre class="brush: as3; title: ; notranslate">package
{
    public class MySingleton
    {
        private static const SINGLETON_LOCK:Object = {};
        private static const _instance:MySingleton = new MySingleton(SINGLETON_LOCK);

        public function MySingleton(lock:Object):void
        {
            if (lock != SINGLETON_LOCK)
                throw new Error(&quot;Invalid Singleton access. Use MySingleton.instance.&quot;);
        }

        public static function get instance():MySingleton
        {
            return _instance;
        }
    }
}</pre>
<p>usage:</p>
<pre class="brush: as3; title: ; notranslate">var singleton:MySingleton = MySingleton.instance;</pre>
<p>Simplier method:</p>
<pre class="brush: as3; title: ; notranslate">package
{
    public class MySingleton
    {
        private static const _instance:MySingleton = new MySingleton();

        public function MySingleton()
        {
            if(instance)
                throw new Error(&quot;Invalid Singleton access. Use MySingleton.instance.&quot;);
        }

        public static function get instance():MySingleton
        {
            return _instance;
        }
    }
}</pre>
<p>Lazy instance:</p>
<pre class="brush: as3; title: ; notranslate">package
{
    public class MySingleton
    {
        private static var _instance:MySingleton;
        private static var creationPhase:Boolean = false;

        public function MySingleton()
        {
            if(!creationPhase)
                throw new Error(&quot;Invalid Singleton access. Use MySingleton.instance.&quot;);
        }

        public static function get instance():MySingleton
        {
            if(!_instance)
            {
                creationPhase = true;
                _instance = new Singleton();
                creationPhase = false;
            }
            return _instance;
        }
    }
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.yoz.sk/2009/10/actionscript-singleton-pattern/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

