<?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>Karoshi Ethos &#187; transform</title>
	<atom:link href="http://karoshiethos.com/tag/transform/feed/" rel="self" type="application/rss+xml" />
	<link>http://karoshiethos.com</link>
	<description>Navigating the treacherous waters of interactive technology</description>
	<lastBuildDate>Sat, 06 Nov 2010 16:38:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>AS3 scrollRect vs height &amp; getBounds()</title>
		<link>http://karoshiethos.com/2008/10/22/as3-scrollrect-vs-height-getbounds/</link>
		<comments>http://karoshiethos.com/2008/10/22/as3-scrollrect-vs-height-getbounds/#comments</comments>
		<pubDate>Wed, 22 Oct 2008 21:02:51 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[getBounds]]></category>
		<category><![CDATA[height]]></category>
		<category><![CDATA[pixelBounds]]></category>
		<category><![CDATA[scrollRect]]></category>
		<category><![CDATA[transform]]></category>

		<guid isPermaLink="false">http://karoshiethos.com/?p=121</guid>
		<description><![CDATA[The new scrollRect property in AS3 DisplayObjects is pretty cool. If you haven't run into it yet, it's a fairly simple way to set a rectangular window on a larger piece of content without the hassle of drawing a rectangle and using a mask and inverse positioning the content... For the most common masking operations [...]]]></description>
			<content:encoded><![CDATA[<p>The new scrollRect property in AS3 DisplayObjects is pretty cool. If you haven't run into it yet, it's a fairly simple way to set a rectangular window on a larger piece of content without the hassle of drawing a rectangle and using a mask and inverse positioning the content... For the most common masking operations it comes in really handy.</p>
<p>And then reality sets in. You want to check the height of your content so you can set up boundary conditions for the scrolling behavior. But! When you get the height property, it's been modified to reflect the fact that the content is now masked. You don't get the "native" height anymore. What's even worse, this update to the property doesn't take effect until the next frame (following a change to scrollRect -- and you'll need <em>another </em>frame if you're doing this the first frame the asset is on the stage -- YMMV), so you've got to add (and remove) a temporary enterframe event listener ... it's a total mess. Thinking about using getBounds instead? Save yourself the trip. It works (as in "doesn't work") the same way.</p>
<p>Now suppose you suck it up and decide to deal with waiting a frame after your content fires onResize. You can handle a little add/remove listener juggling. No biggie. Alas, you've got no way to get access to your original height once a scrollRect has been set. You could temporarily remove the scrollRect, but that change won't take effect until the next frame. Gah!</p>
<p>So, I went digging through the docs to find an alternative. The only thing that looked even remotely promising was the transform property. I went through my code and replaced references to content.height with content.transform.pixelBounds.height and I was in business. As far as I can tell, this property responds appropriately to scale, rotation, etc while omitting any scaleRect clipping. <em>However</em>, if you were to grab content.<strong>parent</strong>.transform.pixelBounds.height, it <em>would </em>take the clipping into account.</p>
<p>Hopes this helps someone else out there...</p>
<p>-- UPDATE --</p>
<p>You know what's awesome? If the DisplayObject isn't on the stage, pixelBounds values are the "native" x, y, width, and height you'd expect looking at the Flash IDE property inspector. Times 5. Don't look at me like that. Try it. You'll get values five times bigger than you ought to. Maybe it's something to do with <a href="http://www.google.com/search?q=twips" target="_blank">twips</a>...</p>
<p>The whole idea of this exercise was to find a way to grab the height of a DisplayObject without a bunch of if/else hassle. But if you've got to sniff for a stage object, you might as well sniff for the scrollRect object itself -- and the value you read won't be subject to the frame delay. That's only a problem when reading it via the height property. Hope that clears up any confusion.</p>
]]></content:encoded>
			<wfw:commentRss>http://karoshiethos.com/2008/10/22/as3-scrollrect-vs-height-getbounds/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>

