<?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>Making Waves Labs &#187; Mats Mikkel</title>
	<atom:link href="http://labs.makingwaves.com/author/mats/feed/" rel="self" type="application/rss+xml" />
	<link>http://labs.makingwaves.com</link>
	<description></description>
	<lastBuildDate>Fri, 03 Sep 2010 13:27:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Flash Player 10.1 debug released, CS5 preview (but no beta)</title>
		<link>http://labs.makingwaves.com/2009/12/18/flash-player-10-1-debug-released-cs5-preview-but-no-beta/</link>
		<comments>http://labs.makingwaves.com/2009/12/18/flash-player-10-1-debug-released-cs5-preview-but-no-beta/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 12:02:20 +0000</pubDate>
		<dc:creator>Mats Mikkel</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Front-end]]></category>

		<guid isPermaLink="false">http://labs.makingwaves.com/?p=768</guid>
		<description><![CDATA[The debug version of the Flash Player 10.1 beta is available now, which is a relief. As for the upcoming CS5 release, Lee Brimelow&#8217;s put up another preview video. In addition to the iPhone compiler previously uncovered, this is our first peek at some of the other features we&#8217;re looking forward to, such as the [...]]]></description>
			<content:encoded><![CDATA[<p>The debug version of the Flash Player 10.1 beta is <a href="http://labs.adobe.com/downloads/flashplayer10.html">available now</a>, which is a relief.</p>
<p>As for the upcoming CS5 release, Lee Brimelow&#8217;s <a href="http://gotoandlearn.com/play?id=118">put up another preview video</a>. In addition to the iPhone compiler previously uncovered, this is our first peek at some of the other features we&#8217;re looking forward to, such as the new text engine, improved font embedding, the XLF format, improved code panel with custom class completion and various other improvements and tweaks. Looks pretty good, although I get the feeling that CS5 is a far smaller update than CS3 and 4; this feels more like CS4.5 than a fullbred new version. As for CS4, it was just upgraded to 10.0.2, and it seems far more stable and responsive now.<span id="more-768"></span></p>
<p>That&#8217;s the good news, the bad is that Adobe decided to <a href="http://blogs.adobe.com/flashplatform/2009/12/there_will_not_be_a_beta_for_f.html?trackingid=FBNTZ">pull the plug</a> on the public beta version of CS5 that was announced at MAX 2009. A real disappointment, especially when the cited reason for the termination is to &#8220;<em>get the release version completed and in your hands as quickly as possible</em>&#8220;. Does this mean that Adobe feels that they can&#8217;t afford the time to fix any eventual bugs uncovered during a public beta period? Considering how many bugs were shipped with CS4, I personally think Adobe would really benefit from putting out a rock solid CS5 &#8211; the community is already frowning. Either way, looks like I have to find another pasttime for the holidays now&#8230;</p>
<p>What do you think about the new features of CS5? Which ones are you looking the most forward to? What do you think of Adobes cancellation of the public beta?</p>
<p>Edit: Lee Brimelow updated The Flash Blog with a new post, which goes a bit more into detail as to the reasons behind the beta cancellation. <a href="http://theflashblog.com/?p=1546">Read it here</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.makingwaves.com/2009/12/18/flash-player-10-1-debug-released-cs5-preview-but-no-beta/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Wrapping text around an image or movieclip in Flash</title>
		<link>http://labs.makingwaves.com/2009/10/29/wrapping-text-around-an-image-or-movieclip-in-flash/</link>
		<comments>http://labs.makingwaves.com/2009/10/29/wrapping-text-around-an-image-or-movieclip-in-flash/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 17:07:46 +0000</pubDate>
		<dc:creator>Mats Mikkel</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Front-end]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://labs.makingwaves.com/?p=667</guid>
		<description><![CDATA[Text has always been a bit of a pain in the ass in Flash (luckily, Flash CS5 will include the new Text Layout Framework) &#8211; apart from the fact that rich text and custom typography isn&#8217;t a problem, it&#8217;s really one of those areas where plain old HTML takes the win. Still, I just discovered [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://labs.makingwaves.com/wp-content/uploads/2009/10/textwrapping011.jpg"><img class="aligncenter size-medium wp-image-682" title="textwrapping01" src="http://labs.makingwaves.com/wp-content/uploads/2009/10/textwrapping011-502x409.jpg" alt="textwrapping01" width="502" height="409" /></a></p>
<p>Text has always been a bit of a pain in the ass in Flash (luckily, <a href="http://cs5.org/?p=179">Flash CS5</a> will include the new <a href="http://opensource.adobe.com/wiki/display/tlf/Text+Layout+Framework;jsessionid=D8428483B4A2B59A26F1B4F8D55B19C8">Text Layout Framework</a>) &#8211; apart from the fact that rich text and custom typography isn&#8217;t a problem, it&#8217;s really one of those areas where plain old HTML takes the win. Still, I just discovered something that makes life a little easier if you&#8217;re going to design a text heavy website in Flash &#8211; the ability to wrap text around images (and MovieClips) in a fairly easy way &#8211; without multiple text fields, split up strings and whatnot.</p>
<p><span id="more-667"></span></p>
<p>So how is it done? Well, it turns out that Flash actually has the ability to <em>embed </em>an image directly into a dynamic text field, using HTML markup. I for one wasn&#8217;t aware of this at all, and the documentation was <em>really </em>thin in regards to embedded TextField media, so I hope this little walk-through will be helpful to someone.</p>
<p><code>textfield.htmlText = "&lt;img src='monkey.jpg' /&gt;";</code></p>
<p>And that&#8217;s it. The image loads (without having to assign a Loader object, an URLRequest or anything) and is placed into the textfield, with any text wrapped neatly around it. Great! You can even specify the alignment of the image (align=&#8221;left&#8221;) to make the text wrap to the left or right of the photo. Additional properties can be set, such as <code>vspace</code> and <code>hspace</code> to control padding &#8211; but it&#8217;s all quite limited. For example, you have no way of adding a preloader, you can&#8217;t control the left/right/bottom/top padding individually, you can&#8217;t add a background/frame, tinker with the alpha channel etc. Actually, right now, you&#8217;ve no way of manipulating that image through AS at all. To do that, you need to store a reference to the embedded bitmap in a variable. To do this, the embedded image&#8217;s id property needs to be set:</p>
<p><code>textfield.htmlText = "&lt;img src='monkey.jpg' id='myImage' /&gt;";</code></p>
<p>Then, you store the reference by refererring to that id:</p>
<p><code>var _image:Bitmap = textfield.getImageReference('myImage') as Bitmap;</code></p>
<p>Now, you get access to all of the properties of the Bitmap class, and can do stuff like tweening the alpha channel, copying the image, change the colors etc. But you still have no way of adding a preloader or any graphics to the image &#8211; to do that, you need to not embed a bitmap file, but a movieclip.</p>
<p>Fortunately, this method works just as well for any kind of DisplayObject. Instead of passing an URL to the text field, you pass the AS identifier (which means the object needs to exist in your library). For example, if I&#8217;ve created a MovieClip with the identifier &#8220;ImageContainer&#8221;:</p>
<p><code>textfield.htmlText = "&lt;img src='ImageContainer' id='myImageContainer' /&gt;";</code></p>
<p>Notice that you still need the id property, and you still need to call the getImageReference method of the TextField to manipulate your embedded MovieClip. For example:</p>
<p><code>var _imageContainer:MovieClip = textfield.getImageReference('</code><code>myImageContainer</code><code>') as MovieClip;</code></p>
<p>Then, you can easily load the bitmap using a regular loader, adding it to the _imageContainer MovieClip upon completion &#8211; which means total control over preloading, error handling etc.</p>
<p>There&#8217;s only one problem. When you embed a DisplayObject in a TextField, Flash automatically pulls the dimensions of the object and uses that to wrap the text. This is fine when you add an image directly, but to use a container MovieClip you obviously need to set the size of the image to be loaded &#8211; and before it actually loads, so that the container will have the correct size. If you&#8217;d set the width and height later, the TextField wouldn&#8217;t change the wrapping &#8211; there&#8217;s (as far as I know!) no way to update this (you could always set the htmlText property again with the correct dimensions after the image has loaded, but this would look weird and make everything jump around).</p>
<p>There are many situations where getting an image&#8217;s dimensions before loading it is desireable, and Flash doesn&#8217;t ship with any built-in methods for this. Thankfully, <a href="http://www.anttikupila.com/">Antti Kupila</a> has written an excellent class for exactly this purpose, called <a href="http://www.anttikupila.com/flash/getting-jpg-dimensions-with-as3-without-loading-the-entire-file/">JPGSizeExtractor</a>.</p>
<p><code>var _extractor:JPGSizeExtractor = new JPGSizeExtractor();<br />
_extractor.addEventListener(JPGSizeExtractor.PARSE_COMPLETE,onJPGSizeExtractComplete);<br />
_extractor.extractSize("monkey.jpg");<br />
function onJPGSizeExtractComplete(e:Event):void {<br />
var _imgW:Number = _extractor.width;<br />
var _imgH:Number = _extractor.height;<br />
}</code></p>
<p>Using the _imgW and _imgH variables, you can set the width and height of the embedded object. This will ensure that the TextField &#8220;reserves&#8221; the appropriate space for the the image.</p>
<p><code>textfield.htmlText = "&lt;img src='ImageContainer' id='myImageContainer' width='"+_imgW+"' height='"+_imgH+"' /&gt;";</code></p>
<p>There&#8217;s still one little problem to work around. Say your MovieClip container is 400&#215;300 px in the library. When it&#8217;s embedded in the text field, its set to the correct dimensions (which is the same dimensions as the image its eventually going to contain). However, this will <em>scale </em>the container, meaning that any content you later add to it (the image, a preloader, text) will also look scaled. The way to solve this is to just reset the container&#8217;s scale properties:</p>
<p><code>imageContainer.scaleX = </code><code>imageContainer.scaleY = 1;<br />
</code></p>
<p>My container contains one child object, which is the frame/background graphics. I&#8217;ve set the instance name of this MovieClip to frame_mc. As I&#8217;ve reset the container&#8217;s scale properties, I need to set the correct dimensions to the frame instead:</p>
<p><code>imageContainer.frame_mc.width = _imgW;<br />
imageContainer.frame_mc.height = _imgH;</code></p>
<p>By keeping the containers scale to 1, anything you add to it will keep its scale and aspect ratio. Load the image and add it to the container&#8217;s DisplayList &#8211; and you&#8217;ve got a beautiful text field with text wrapping around a correctly scaled image, of which you have total AS control.</p>
<p><a href="http://labs.makingwaves.com/wp-content/uploads/2009/10/textwrapping021.jpg"><img class="aligncenter size-medium wp-image-683" title="textwrapping02" src="http://labs.makingwaves.com/wp-content/uploads/2009/10/textwrapping021-502x409.jpg" alt="textwrapping02" width="502" height="409" /></a></p>
<p>In my example, I&#8217;ve got my text in an XML file, adding the &lt;img&gt; tags through Actionscript. Obviously, if the content had been retrieved from a CMS the &lt;img&gt; tags would&#8217;ve probably be embedded in the text, and you would have to write some regular expressions to pull them out, store their position in the string and add them back in using the methods above.</p>
<p>The only thing I&#8217;m struggling with so far is center aligning the image &#8211; I can&#8217;t seem to do it. Nesting an image tag within an &lt;a&gt;tag  is also a no-go, so if your images should function as links you will need to pull those URL&#8217;s out and add them back in using MouseEvents. The third issue is with padding &#8211; using a MovieClip container still doesn&#8217;t <em> </em>enable you to manipulate the left and right, top and bottom paddings individually, and the container doesn&#8217;t seem to respond to x and y manipulation once it&#8217;s embedded. A possible workaround would be to hide the embedded container and add a new one <em>on top </em>of the TextField&#8230; which would be fine, the hidden container doesn&#8217;t need to actually contain <em>anything</em>, it&#8217;s just a way to make the TextField reserve the appropriate space for whatever DisplayObject you want wrapped.</p>
<p>If anybody knows anything about center alignment of embedding TextField media or of an even better way of wrapping text around DisplayObjects (what about non-square DO&#8217;s, for example&#8230;) &#8211; leave a comment!</p>
<p><a href="http://labs.makingwaves.com/wp-content/uploads/2009/10/TextWrapping.zip">Download example source files here</a></p>
<p>The photo used in the example was taken by <a href="http://www.sxc.hu/profile/e-Eva-a">e-Eva-a</a> at <a href="http://www.sxc.hu">stock.exchng</a>.</p>
<p>Kudos to <a href="http://www.anttikupila.com/">Antti Kupila</a> for the JPGSizeExtractor class</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.makingwaves.com/2009/10/29/wrapping-text-around-an-image-or-movieclip-in-flash/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
