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

<channel>
	<title>devBlog</title>
	<atom:link href="http://devblog.projector.se/index.php?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://devblog.projector.se</link>
	<description>Projector development blog. A place to document your experiences.</description>
	<pubDate>Mon, 23 Jun 2008 15:39:48 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
	<language>en</language>
			<item>
		<title>Loader.close(), a slippery little basted!</title>
		<link>http://devblog.projector.se/?p=36</link>
		<comments>http://devblog.projector.se/?p=36#comments</comments>
		<pubDate>Mon, 23 Jun 2008 15:39:48 +0000</pubDate>
		<dc:creator>Jörgen</dc:creator>
		
		<category><![CDATA[AS3]]></category>

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

		<guid isPermaLink="false">http://devblog.projector.se/?p=36</guid>
		<description><![CDATA[I was working with the Loader class and thought that a good practice to avoid a lot of unnecessary bandwidth loadings is to clear any loading progress before I start a new one. Just to explain.. I used a array to store pages (Loaders) in the application. If the user click at the navigation nr [...]]]></description>
			<content:encoded><![CDATA[<p><span lang="EN-US"><font face="Calibri">I was working with the Loader class and thought that a good practice to avoid a lot of unnecessary bandwidth loadings is to clear any loading progress before I start a new one. <o:p></o:p></font></span><span lang="EN-US"><font face="Calibri">Just to explain.. I used a array to store pages (Loaders) in the application. If the user click at the navigation nr 2 the loader in the position nr 2 in the array where told to load the new url. But if the user clicked on another link and starting to load another swf the loading of the old swf (nr 2) should stop right away. <o:p></o:p></font></span><span lang="EN-US"><o:p><font face="Calibri"> </font></o:p></span></p>
<p style="margin: 0cm 0cm 0pt" class="MsoNormal"><span lang="EN-US"><font face="Calibri">The method to use in the Loader class is the close() function. And the BIG problem in this is that when I tried in the flash ide the loader didn’t stop the stream… I tried everything… cleared every event listener, but in the flash “bandwidth profiler” I could see that the swf where still loading… so when I clicked at the navigation buttons as a maniac the “bandwidth profiler” showed me a bunch of loading swf simultaneously. <span> </span>After a lot of tryes end error I found out the the only problem is the falsh ide and the “bandwidth profiler”. If I do the same on a web server the connection cuts of the I get a sweet “Client closed connection before receiving entire response”. So much headache for nothing…<br />
Thank god for Charels! The best debugging tool ever! if you don&#8217;t got it, go and get it <a href="http://www.charlesproxy.com/" title="get Charels!">here»</a>!</font></span></p>
]]></content:encoded>
			<wfw:commentRss>http://devblog.projector.se/?feed=rss2&amp;p=36</wfw:commentRss>
		</item>
		<item>
		<title>New Flash Player new issues…</title>
		<link>http://devblog.projector.se/?p=35</link>
		<comments>http://devblog.projector.se/?p=35#comments</comments>
		<pubDate>Thu, 12 Jun 2008 11:09:21 +0000</pubDate>
		<dc:creator>Jörgen</dc:creator>
		
		<category><![CDATA[AS3]]></category>

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

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

		<guid isPermaLink="false">http://devblog.projector.se/?p=35</guid>
		<description><![CDATA[In the new Flash Player 9,0,124,0 there is a lot of new security changes…
If you are (like me) used webService and the server is in a other domain then you will get a sweet secure error:
Server Error: [RPC Fault faultString="Security error accessing url" faultCode="Channel.Security.Error" faultDetail="Destination: DefaultHTTP"]
What I did was adding this line in the crossdimain.xml file [...]]]></description>
			<content:encoded><![CDATA[<p>In the new Flash Player 9,0,124,0 there is a lot of new security changes…<br />
If you are (like me) used webService and the server is in a other domain then you will get a sweet secure error:<br />
<font color="#ff0000">Server Error: [RPC Fault faultString="Security error accessing url" faultCode="Channel.Security.Error" faultDetail="Destination: DefaultHTTP"]</font></p>
<p>What I did was adding this line in the crossdimain.xml file and the error went away!<br />
<font color="#ff0000">&lt;allow-http-request-headers-from domain=&#8221;*&#8221; headers=&#8221;*&#8221;/&gt;</font></p>
<p>So here is the complete crossdomain file:<br />
<font color="#999999">&lt;cross-domain-policy&gt;<br />
&lt;allow-http-request-headers-from domain=&#8221;*&#8221; headers=&#8221;*&#8221;/&gt;<br />
 &lt;allow-access-from domain=&#8221;*&#8221; /&gt;<br />
&lt;/cross-domain-policy&gt;</font></p>
<p>If you are usingSocket connection in flash the problem is not this easy to fix. Read this article about the new socket security rules:<br />
<a href="http://www.adobe.com/devnet/flashplayer/articles/socket_policy_files.html">http://www.adobe.com/devnet/flashplayer/articles/socket_policy_files.html</a></p>
<p>Here you can read about the new security rules for flash player 9,0,124,0<br />
<a href="http://www.adobe.com/devnet/flashplayer/articles/flash_player9_security_update.html">http://www.adobe.com/devnet/flashplayer/articles/flash_player9_security_update.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://devblog.projector.se/?feed=rss2&amp;p=35</wfw:commentRss>
		</item>
		<item>
		<title>Basic Flash-tips #3: Improve your Align skills</title>
		<link>http://devblog.projector.se/?p=32</link>
		<comments>http://devblog.projector.se/?p=32#comments</comments>
		<pubDate>Thu, 17 Apr 2008 08:15:58 +0000</pubDate>
		<dc:creator>inEar</dc:creator>
		
		<category><![CDATA[Flash Tips]]></category>

		<guid isPermaLink="false">http://devblog.projector.se/?p=32</guid>
		<description><![CDATA[Here are some very useful shortcuts to position things faster on stage (PC):
Turn on/off scale &#8220;To stage&#8221;: ctrl+alt+8
Horizontal align: ctr+alt+(1-3)
Vertical align: ctr+alt+(4-6)
And another feature in the align toolbar is &#8220;Match size&#8221; wich I never used until recently. Useful when resize a background-shape to stage size.
And the shortcuts for that with &#8220;To Stage&#8221; on:
 ctrl+alt+shift+7 &#8211;&#62; ctrl+alt+shift+9
]]></description>
			<content:encoded><![CDATA[<p>Here are some very useful shortcuts to position things faster on stage (PC):</p>
<p>Turn on/off scale &#8220;To stage&#8221;: ctrl+alt+8</p>
<p>Horizontal align: ctr+alt+(1-3)</p>
<p>Vertical align: ctr+alt+(4-6)</p>
<p>And another feature in the align toolbar is &#8220;Match size&#8221; wich I never used until recently. Useful when resize a background-shape to stage size.</p>
<p>And the shortcuts for that with &#8220;To Stage&#8221; on:</p>
<p> ctrl+alt+shift+7 &#8211;&gt; ctrl+alt+shift+9</p>
]]></content:encoded>
			<wfw:commentRss>http://devblog.projector.se/?feed=rss2&amp;p=32</wfw:commentRss>
		</item>
		<item>
		<title>Basic Flash-tips #2: Runtime-errors with row-numbers</title>
		<link>http://devblog.projector.se/?p=31</link>
		<comments>http://devblog.projector.se/?p=31#comments</comments>
		<pubDate>Thu, 17 Apr 2008 08:15:42 +0000</pubDate>
		<dc:creator>inEar</dc:creator>
		
		<category><![CDATA[Flash Tips]]></category>

		<guid isPermaLink="false">http://devblog.projector.se/?p=31</guid>
		<description><![CDATA[Have you ever been missing the row-number for an error thrown at runtime in Flash CS3, for example when working with loaded content such as XML? Just activate &#8220;permit debugging&#8221; in Publish settings and there it is.
]]></description>
			<content:encoded><![CDATA[<p>Have you ever been missing the row-number for an error thrown at runtime in Flash CS3, for example when working with loaded content such as XML? Just activate &#8220;permit debugging&#8221; in Publish settings and there it is.</p>
]]></content:encoded>
			<wfw:commentRss>http://devblog.projector.se/?feed=rss2&amp;p=31</wfw:commentRss>
		</item>
		<item>
		<title>Basic Flash-tips #1: Potapenko Extensions</title>
		<link>http://devblog.projector.se/?p=33</link>
		<comments>http://devblog.projector.se/?p=33#comments</comments>
		<pubDate>Thu, 17 Apr 2008 08:14:43 +0000</pubDate>
		<dc:creator>inEar</dc:creator>
		
		<category><![CDATA[Flash Tips]]></category>

		<guid isPermaLink="false">http://devblog.projector.se/?p=33</guid>
		<description><![CDATA[I found this flash-extension really useful. Specially the &#8220;multi edit library&#8221; feature. Select multiple images in the library and change smoothing and compression all at once.
http://potapenko.com/eng/extensions.htm
]]></description>
			<content:encoded><![CDATA[<p>I found this flash-extension really useful. Specially the &#8220;multi edit library&#8221; feature. Select multiple images in the library and change smoothing and compression all at once.</p>
<p><a href="http://potapenko.com/eng/extensions.htm">http://potapenko.com/eng/extensions.htm</a></p>
]]></content:encoded>
			<wfw:commentRss>http://devblog.projector.se/?feed=rss2&amp;p=33</wfw:commentRss>
		</item>
		<item>
		<title>TextField gets cut</title>
		<link>http://devblog.projector.se/?p=30</link>
		<comments>http://devblog.projector.se/?p=30#comments</comments>
		<pubDate>Mon, 14 Apr 2008 16:25:42 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
		
		<category><![CDATA[Flash Tips]]></category>

		<category><![CDATA[Font related]]></category>

		<guid isPermaLink="false">http://devblog.projector.se/?p=30</guid>
		<description><![CDATA[Annoying inssue with a centered textfield paragrah randomly get&#8217;s cut off at the right end.
Only solution for now seems to be to keep the the textfield paragraph left aligned and then center the textfield it self by measuring width and position.
]]></description>
			<content:encoded><![CDATA[<p>Annoying inssue with a centered textfield paragrah randomly get&#8217;s cut off at the right end.<br />
Only solution for now seems to be to keep the the textfield paragraph left aligned and then center the textfield it self by measuring width and position.</p>
]]></content:encoded>
			<wfw:commentRss>http://devblog.projector.se/?feed=rss2&amp;p=30</wfw:commentRss>
		</item>
		<item>
		<title>The smallest things can take the longest time</title>
		<link>http://devblog.projector.se/?p=29</link>
		<comments>http://devblog.projector.se/?p=29#comments</comments>
		<pubDate>Thu, 10 Apr 2008 14:55:06 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
		
		<category><![CDATA[AS3]]></category>

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

		<guid isPermaLink="false">http://devblog.projector.se/?p=29</guid>
		<description><![CDATA[Recently pulled my hair over something that probably is quite logical.
To get around crossdomain issues I placed a shell-swf on a remote server that in turn loads the main-swf. Have done it like that a thousand times before but this time I just couldn&#8217;t get it to work.
It turns out that i tried to set stage.scaleMode in the [...]]]></description>
			<content:encoded><![CDATA[<p>Recently pulled my hair over something that probably is quite logical.</p>
<p>To get around crossdomain issues I placed a shell-swf on a remote server that in turn loads the main-swf. Have done it like that a thousand times before but this time I just couldn&#8217;t get it to work.</p>
<p>It turns out that i tried to set stage.scaleMode in the main.swf which of course isn&#8217;t allowed to write that property. Only the shell has that privelige.  So the swf just failed silently and it took wuite some time to figure out the problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://devblog.projector.se/?feed=rss2&amp;p=29</wfw:commentRss>
		</item>
		<item>
		<title>Resolution of textures</title>
		<link>http://devblog.projector.se/?p=28</link>
		<comments>http://devblog.projector.se/?p=28#comments</comments>
		<pubDate>Wed, 09 Apr 2008 16:04:45 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
		
		<category><![CDATA[3D Studio Max]]></category>

		<guid isPermaLink="false">http://devblog.projector.se/?p=28</guid>
		<description><![CDATA[It&#8217;s probably due to my lack of understanding of the program and it&#8217;s principles, but how do you get it to use bitmap textures with a higher resolution? It seems as if you can&#8217;t have larger images than about 4000 pixels in height without it generating memory error, but maybe that is just my system [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s probably due to my lack of understanding of the program and it&#8217;s principles, but how do you get it to use bitmap textures with a higher resolution? It seems as if you can&#8217;t have larger images than about 4000 pixels in height without it generating memory error, but maybe that is just my system that is inadequate.<br />
Solved it for now by splitting the texure (for my globe) into smaller images.</p>
]]></content:encoded>
			<wfw:commentRss>http://devblog.projector.se/?feed=rss2&amp;p=28</wfw:commentRss>
		</item>
		<item>
		<title>Mouse-position outside flash tutorial</title>
		<link>http://devblog.projector.se/?p=27</link>
		<comments>http://devblog.projector.se/?p=27#comments</comments>
		<pubDate>Mon, 17 Mar 2008 17:38:06 +0000</pubDate>
		<dc:creator>inEar</dc:creator>
		
		<category><![CDATA[Flash Hacks]]></category>

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

		<guid isPermaLink="false">http://devblog.projector.se/?p=27</guid>
		<description><![CDATA[ To use javascript with banners can be a true headache. I wan&#8217;t to share my exerience of the obstacles I found so far.
Before you start, make sure you have the permission to use javascript on the sites. Sometimes you can sneak in your javascript in the embed-code generated by the media agencies, the siteowner does&#8217;nt even have [...]]]></description>
			<content:encoded><![CDATA[<p> To use javascript with banners can be a true headache. I wan&#8217;t to share my exerience of the obstacles I found so far.</p>
<p>Before you start, make sure you have the permission to use javascript on the sites. Sometimes you can sneak in your javascript in the embed-code generated by the media agencies, the siteowner does&#8217;nt even have to know about it. But sometimes, when you need to fire some code on the onInit-event, you have to get access to the document header. However, with some workarounds you don&#8217;t really need that. In the following example you can put the script after the swfobject-embedding.</p>
<p id="flashcontent">nbsp;</p>
<p><script type="text/javascript" src="/filesswfobject.js"></script><br />
<script type="text/javascript" src="/files/code.js"></script></p>
<p>Javascript source:</p>
<div class="codecolorer-container javascript" style="height:560px;"><div class="codecolorer" style="font-family: monospace;"><span class="kw2">var</span> mouseX = <span class="nu0">0</span>;<br />
<span class="kw2">var</span> mouseY = <span class="nu0">0</span>;<br />
<span class="kw2">var</span> bannerX = <span class="nu0">0</span>;<br />
<span class="kw2">var</span> bannerY = <span class="nu0">0</span>;<br />
<br />
document.<span class="me1">onmousemove</span> = updateMousePos;<br />
<br />
<span class="kw2">function</span> updateMousePos<span class="br0">&#40;</span>e<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<br />
&nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span> !e <span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span> window.<span class="me1">event</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//IE</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e = window.<span class="me1">event</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//Fails</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<br />
&nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span> <span class="kw1">typeof</span><span class="br0">&#40;</span> e.<span class="me1">pageX</span> <span class="br0">&#41;</span> == <span class="st0">'number'</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//most browsers</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> xcoord = e.<span class="me1">pageX</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> ycoord = e.<span class="me1">pageY</span>;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span> <br />
&nbsp; &nbsp; <span class="kw1">else</span> <span class="kw1">if</span><span class="br0">&#40;</span> <span class="kw1">typeof</span><span class="br0">&#40;</span> e.<span class="me1">clientX</span> <span class="br0">&#41;</span> == <span class="st0">'number'</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//Internet Explorer and older browsers</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//other browsers provide this, but follow the pageX/Y branch</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> xcoord = e.<span class="me1">clientX</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> ycoord = e.<span class="me1">clientY</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> badOldBrowser = <span class="br0">&#40;</span> window.<span class="me1">navigator</span>.<span class="me1">userAgent</span>.<span class="me1">indexOf</span><span class="br0">&#40;</span> <span class="st0">'Opera'</span> <span class="br0">&#41;</span> + <span class="nu0">1</span> <span class="br0">&#41;</span> || <span class="br0">&#40;</span> window.<span class="me1">ScriptEngine</span> &amp;amp;&amp;amp; ScriptEngine<span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">indexOf</span><span class="br0">&#40;</span> <span class="st0">'InScript'</span> <span class="br0">&#41;</span> + <span class="nu0">1</span> <span class="br0">&#41;</span> || <span class="br0">&#40;</span> navigator.<span class="me1">vendor</span> == <span class="st0">'KDE'</span> <span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span> !badOldBrowser <span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span> document.<span class="me1">body</span> &amp;amp;&amp;amp; <span class="br0">&#40;</span> document.<span class="me1">body</span>.<span class="me1">scrollLeft</span> || document.<span class="me1">body</span>.<span class="me1">scrollTop</span> <span class="br0">&#41;</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//IE 4, 5 &amp;amp; 6 (in non-standards compliant mode)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xcoord += document.<span class="me1">body</span>.<span class="me1">scrollLeft</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ycoord += document.<span class="me1">body</span>.<span class="me1">scrollTop</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="kw1">if</span><span class="br0">&#40;</span> document.<span class="me1">documentElement</span> &amp;amp;&amp;amp; <span class="br0">&#40;</span> document.<span class="me1">documentElement</span>.<span class="me1">scrollLeft</span> || document.<span class="me1">documentElement</span>.<span class="me1">scrollTop</span> <span class="br0">&#41;</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//IE 6 (in standards compliant mode)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xcoord += document.<span class="me1">documentElement</span>.<span class="me1">scrollLeft</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ycoord += document.<span class="me1">documentElement</span>.<span class="me1">scrollTop</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">///Fails</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; mouseX = xcoord<br />
&nbsp; &nbsp; mouseY = ycoord<br />
<span class="br0">&#125;</span><br />
<br />
<span class="co1">//called from flash</span><br />
<span class="kw2">function</span> getParameters<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="co1">//if not bannerpos is set, try to get it</span><br />
&nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span> bannerX == <span class="nu0">0</span> &amp;amp;&amp;amp; bannerY == <span class="nu0">0</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; getBannerPos<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<br />
&nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span> <span class="br0">&#40;</span>bannerX == <span class="nu0">0</span> &amp;amp;&amp;amp; bannerY == <span class="nu0">0</span><span class="br0">&#41;</span> || <span class="br0">&#40;</span>mouseX == <span class="nu0">0</span> &amp;amp;&amp;amp; mouseY == <span class="nu0">0</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="st0">&quot;error&quot;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="kw1">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> bannerX+<span class="st0">&quot;:&quot;</span>+bannerY+<span class="st0">&quot;:&quot;</span>+mouseX+<span class="st0">&quot;:&quot;</span>+mouseY ;<br />
<span class="br0">&#125;</span><br />
<br />
<span class="kw2">function</span> getBannerPos<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<span class="kw2">var</span> flashMovie = document.<span class="me1">getElementById</span><span class="br0">&#40;</span><span class="st0">&quot;projectorBanner&quot;</span><span class="br0">&#41;</span>;<br />
<br />
&nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span> flashMovie <span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span> flashMovie.<span class="me1">offsetParent</span> <span class="br0">&#41;</span> flashMovie = flashMovie.<span class="me1">offsetParent</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>flashMovie.<span class="me1">offsetParent</span> &amp;amp;&amp;amp; flashMovie.<span class="me1">tagName</span>.<span class="me1">toLowerCase</span><span class="br0">&#40;</span><span class="br0">&#41;</span> != <span class="st0">'body'</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">do</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bannerX += flashMovie.<span class="me1">offsetLeft</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bannerY += flashMovie.<span class="me1">offsetTop</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">while</span> <span class="br0">&#40;</span>flashMovie = flashMovie.<span class="me1">offsetParent</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div></div>
<p>Okey, we gonna follow the mouse, so here we go&#8230;</p>
<p>Begin by adding the onmousemove-event. This event is firing quite fast, so you don&#8217;t want to send data to the flash every time. Instead I pull the data from inside the flash via ExternalInterface.call().</p>
<p>The key to follow the mouse is to know where the banners top-left-position is. There aint no crossbrowser-property for this, so you recursive checks the positions via offsetTop and offsetLeft to the parent element. See getBannerPos-function. I noticed that firefox added the same offsetHeight twice for the embed-tag and the parentElement. This row fixed the problem:</p>
<p>if( flashMovie.offsetParent ) flashMovie = flashMovie.offsetParent</p>
<p>It&#8217;s a safe fix, because the offset to the object/embed-parent is zero in all other cases. We only need to check the position once. So we keep checking until we get a result. The onmousemove-event may be fired many times before the position can be measured. So while bannerX/bannerY is 0, keep checking. Be careful with Explorer, if we check the position to soon, we can get the left position before the top position is available (especially with floating css-divs), so wait for both parameters to be non-zero. Put the &#8220;getBannerPos()&#8221; in the method called from flash, and your home safe.</p>
<p>Next thing is to get the scroll position. Because this changes over time, I do that every time onmousemove fires. To get the scrollposition is a little more tricky due to all browsers different implemention, I just used a script I found at google.</p>
<p>So now we got the four variables with what we needed. MouseX, mouseY, bannerX, bannerY. Time for flash to do some magic.</p>
<p>actionscript source:</p>
<div class="codecolorer-container javascript"><div class="codecolorer" style="font-family: monospace;"><span class="kw2">var</span> arrPositions:Array; <br />
<br />
<span class="kw1">if</span><span class="br0">&#40;</span> bMouseOver <span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; <br />
&nbsp; <span class="co1">//internal position</span><br />
&nbsp; bannerX = <span class="nu0">0</span>;<br />
&nbsp; bannerY = <span class="nu0">0</span>;<br />
&nbsp; <br />
&nbsp; <span class="co1">//relative to browser</span><br />
&nbsp; browserMouseX = <span class="kw1">this</span>._xmouse + bannerX<br />
&nbsp; browserMouseY = <span class="kw1">this</span>._ymouse + bannerY<br />
&nbsp; <br />
<span class="br0">&#125;</span><br />
<span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; <br />
&nbsp; <span class="co1">//get from Javascript</span><br />
&nbsp; <span class="kw2">var</span> strParameters = ExternalInterface.<span class="me1">call</span><span class="br0">&#40;</span><span class="st0">&quot;getParameters&quot;</span><span class="br0">&#41;</span>;<br />
&nbsp; arrPositions = strParameters.<span class="me1">split</span><span class="br0">&#40;</span><span class="st0">&quot;:&quot;</span><span class="br0">&#41;</span>;<br />
<br />
&nbsp; <span class="kw1">if</span><span class="br0">&#40;</span> strParameters != <span class="st0">&quot;error&quot;</span> &amp;&amp; strParameters != undefined<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; bannerX = Number<span class="br0">&#40;</span>arrPositions<span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; bannerY = Number<span class="br0">&#40;</span>arrPositions<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; browserMouseX =&nbsp; Number<span class="br0">&#40;</span>arrPositions<span class="br0">&#91;</span><span class="nu0">2</span><span class="br0">&#93;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; browserMouseY =&nbsp; Number<span class="br0">&#40;</span>arrPositions<span class="br0">&#91;</span><span class="nu0">3</span><span class="br0">&#93;</span><span class="br0">&#41;</span>;<br />
&nbsp; <span class="br0">&#125;</span><br />
<br />
<span class="br0">&#125;</span><br />
<br />
<span class="co1">//do what ever you want with it</span><br />
updatePositions<span class="br0">&#40;</span> bannerX,bannerY,browserMouseX,browserMouseY<span class="br0">&#41;</span>;</div></div>
<p>In order to have a smooth gap when rolling over and out the banner you have to setup a mouse-listener here as well. Otherwise, it will get jumpy or not working at all. Some browsers don&#8217;t fire mousemove-events when over a flash. There is a known problem to register a mouse leave from the stage. I checks if the mouseX and mouseY changes. If not, wait a few frames and then assume we don&#8217;t have the users attention anymore. This can certainly be made better by checking mouse position in javascript, but this worked good enough this time. So, when the flash mouse-position stops, we will listen to the javascript-position.</p>
<p>What to do with the knowledge of mouseposition is up to you. In my example I render a paralax-effect based on the values.</p>
]]></content:encoded>
			<wfw:commentRss>http://devblog.projector.se/?feed=rss2&amp;p=27</wfw:commentRss>
		</item>
		<item>
		<title>3D effect with filters</title>
		<link>http://devblog.projector.se/?p=26</link>
		<comments>http://devblog.projector.se/?p=26#comments</comments>
		<pubDate>Fri, 14 Mar 2008 11:30:54 +0000</pubDate>
		<dc:creator>inEar</dc:creator>
		
		<category><![CDATA[Flash Tips]]></category>

		<guid isPermaLink="false">http://devblog.projector.se/?p=26</guid>
		<description><![CDATA[By mixing multiple layers of filtereffects you can make this nice little 3d-effect.
Flashcontent
                            var so = new SWFObject("files/filterDemo.swf", "filterDemo", "470", "200", "8", "#ffffff");      [...]]]></description>
			<content:encoded><![CDATA[<p>By mixing multiple layers of filtereffects you can make this nice little 3d-effect.</p>
<p id="filterEffectDiv">Flashcontent</p>
<p><script language="javascript">                            var so = new SWFObject("files/filterDemo.swf", "filterDemo", "470", "200", "8", "#ffffff");       so.addParam("scale", "noscale");       so.write("filterEffectDiv"); </script></p>
<p>Here is the recepy:</p>
<p>Create these filters:</p>
<p>var filter1 = new flash.filters.DropShadowFilter();<br />
filter1.angle = 90;<br />
filter1.distance = 1;<br />
filter1.blurX = 0;<br />
filter1.blurY = 0;<br />
filter1.color = 0xf3d22f<br />
filter1.strength = 1;</p>
<p>var filter2 = new flash.filters.DropShadowFilter();<br />
filter2.angle = 90;<br />
filter2.distance = 2;<br />
filter2.blurX = 10;<br />
filter2.blurY = 10;<br />
filter2.color = 0&#215;000000<br />
filter2.strength = 0.5;</p>
<p>var bevelFilter = new BevelFilter(2,90,0xfedc74,10,0&#215;929292,10,2,2,0.42);</p>
<p>Add &#8220;filter1&#8243; 12 times or what you prefer (myMC.filters[filter1,filter1,...]).<br />
Add a regular drop shadow ( &#8220;filter2&#8243;) at the end.</p>
<p>In this example a have added a beveleffect (&#8221;bevelFilter&#8221;) to each slice. To get the correct z-rendering of  the blue slice I scripted a mask, based on the angle of that slice.</p>
<p> The downside is the lack of antialiasing on the edges.</p>
]]></content:encoded>
			<wfw:commentRss>http://devblog.projector.se/?feed=rss2&amp;p=26</wfw:commentRss>
		</item>
	</channel>
</rss>
