<?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>Flash User &#187; Flash Tips &amp; Tricks</title>
	<atom:link href="http://www.flashuser.net/category/flash-tricks/feed" rel="self" type="application/rss+xml" />
	<link>http://www.flashuser.net</link>
	<description>FlashUser.net helps creative Flash developers and designers from all over the world to save time and money for their projects. By following our posts you will easily create more effective Flash designs or add value to your Flash software and applications</description>
	<lastBuildDate>Wed, 23 Jun 2010 11:16:52 +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>Tips &amp; Tricks 12: Change the color of a MovieClip using ColorTransform</title>
		<link>http://www.flashuser.net/flash-tricks/change-the-color-of-a-movieclip-using-colortransform.html</link>
		<comments>http://www.flashuser.net/flash-tricks/change-the-color-of-a-movieclip-using-colortransform.html#comments</comments>
		<pubDate>Sat, 31 Oct 2009 10:24:14 +0000</pubDate>
		<dc:creator>flashuser</dc:creator>
				<category><![CDATA[Flash Tips & Tricks]]></category>
		<category><![CDATA[Flash Tutorials]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[transform]]></category>

		<guid isPermaLink="false">http://www.flashuser.net/?p=2783</guid>
		<description><![CDATA[<p>If you ever wonder how to change the color of a MovieClip in Actionscript 3 here&#8217;s a very useful tip. All you have to do is use the ColorTranform class. There are many methods to be used, one that come in handy is the color property which I&#8217;ll show it to you.</p>
<p><span id="more-2783"></span> This property replace the old fashion Actionscript 2 setRGB() method. Here&#8217;s the code for changing the color of a MovieClip in AS2:</p>
<pre class="brush: as3;">
var myColor:Color = new Color(myMovie);
     myColor.setRGB(0x4455ff);
</pre>
<p>where <strong>myMovie</strong> is an instance of a MovieClip.</p>
<p>For Actionscript 3 the code isn&#8217;t so complicated and here it is:</p>
<pre class="brush: as3;">[/as3]
var newColor:ColorTransform = myMovie.transform.colorTransform;
     newColor.color = 0xFF5522;
     myMovie.transform.colorTransform = newColor;
[as3]</pre>
<p>To see how the code works have a look at the example below:</p>
<div align="center" class="border-media">

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_colorTransform_2018632088"
			class="flashmovie"
			width="550"
			height="150">
	<param name="movie" value="http://www.flashuser.net/flash-files/flash_tips_tricks/colorTransform/colorTransform.swf " />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashuser.net/flash-files/flash_tips_tricks/colorTransform/colorTransform.swf "
			name="fm_colorTransform_2018632088"
			width="550"
			height="150">
	<!--<![endif]-->
		<br />
 <!-- Begin Alternate Content --></p>
<p>
 <a href="http://adobe.com/go/getflashplayer"><br />
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /><br />
</a>
 </p>
<p><!-- End Alternate Content --></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
</div>
<p>The code for the example is here:</p>
<pre class="brush: as3;">
import flash.geom.ColorTransform;

square1.buttonMode = true;
square1.useHandCursor = true;
square1.mouseChildren = false;
square1.addEventListener(&quot;mouseOver&quot;, rollOverHandler);
square1.addEventListener(&quot;mouseOut&quot;, rollOutHandler);

square2.buttonMode = true;
square2.useHandCursor = true;
square2.mouseChildren = false;
square2.addEventListener(&quot;mouseOver&quot;, rollOverHandler);
square2.addEventListener(&quot;mouseOut&quot;, rollOutHandler);

function rollOverHandler(e:MouseEvent) {
	var newColor:ColorTransform = e.target.transform.colorTransform;
	if (e.target.name ==&quot;square1&quot;) {
		newColor.color = 0xFF5522;
	} else {
		newColor.color = 0x0066CC;
	}
	e.target.transform.colorTransform = newColor;

}

function rollOutHandler(e:MouseEvent) {
	var newColor:ColorTransform = e.target.transform.colorTransform;
	if (e.target.name ==&quot;square1&quot;) {
		newColor.color = 0x0066CC;
	} else {
		newColor.color = 0xFF5522;
	}
	e.target.transform.colorTransform = newColor;
}
</pre>
<div id="download-file"><a href="http://www.flashuser.net/flash-files/flash_tips_tricks/colorTransform/colorTransform.zip" color="FF0000" target="_blank"><span>Download the source file</span></a></div>
]]></description>
			<content:encoded><![CDATA[<p>If you ever wonder how to change the color of a MovieClip in Actionscript 3 here&#8217;s a very useful tip. All you have to do is use the ColorTranform class. There are many methods to be used, one that come in handy is the color property which I&#8217;ll show it to you.</p>
<p><span id="more-2783"></span> This property replace the old fashion Actionscript 2 setRGB() method. Here&#8217;s the code for changing the color of a MovieClip in AS2:</p>
<pre class="brush: as3;">
var myColor:Color = new Color(myMovie);
     myColor.setRGB(0x4455ff);
</pre>
<p>where <strong>myMovie</strong> is an instance of a MovieClip.</p>
<p>For Actionscript 3 the code isn&#8217;t so complicated and here it is:</p>
<pre class="brush: as3;">[/as3]
var newColor:ColorTransform = myMovie.transform.colorTransform;
     newColor.color = 0xFF5522;
     myMovie.transform.colorTransform = newColor;
[as3]</pre>
<p>To see how the code works have a look at the example below:</p>
<div align="center" class="border-media">

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_colorTransform_1293421101"
			class="flashmovie"
			width="550"
			height="150">
	<param name="movie" value="http://www.flashuser.net/flash-files/flash_tips_tricks/colorTransform/colorTransform.swf " />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashuser.net/flash-files/flash_tips_tricks/colorTransform/colorTransform.swf "
			name="fm_colorTransform_1293421101"
			width="550"
			height="150">
	<!--<![endif]-->
		<br />
 <!-- Begin Alternate Content --></p>
<p>
 <a href="http://adobe.com/go/getflashplayer"><br />
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /><br />
</a>
 </p>
<p><!-- End Alternate Content --></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
</div>
<p>The code for the example is here:</p>
<pre class="brush: as3;">
import flash.geom.ColorTransform;

square1.buttonMode = true;
square1.useHandCursor = true;
square1.mouseChildren = false;
square1.addEventListener(&quot;mouseOver&quot;, rollOverHandler);
square1.addEventListener(&quot;mouseOut&quot;, rollOutHandler);

square2.buttonMode = true;
square2.useHandCursor = true;
square2.mouseChildren = false;
square2.addEventListener(&quot;mouseOver&quot;, rollOverHandler);
square2.addEventListener(&quot;mouseOut&quot;, rollOutHandler);

function rollOverHandler(e:MouseEvent) {
	var newColor:ColorTransform = e.target.transform.colorTransform;
	if (e.target.name ==&quot;square1&quot;) {
		newColor.color = 0xFF5522;
	} else {
		newColor.color = 0x0066CC;
	}
	e.target.transform.colorTransform = newColor;

}

function rollOutHandler(e:MouseEvent) {
	var newColor:ColorTransform = e.target.transform.colorTransform;
	if (e.target.name ==&quot;square1&quot;) {
		newColor.color = 0x0066CC;
	} else {
		newColor.color = 0xFF5522;
	}
	e.target.transform.colorTransform = newColor;
}
</pre>
<div id="download-file"><a href="http://www.flashuser.net/flash-files/flash_tips_tricks/colorTransform/colorTransform.zip" color="FF0000" target="_blank"><span>Download the source file</span></a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.flashuser.net/flash-tricks/change-the-color-of-a-movieclip-using-colortransform.html/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Tips &amp; Tricks 11: Customizable Flash Analogue Clock AS3</title>
		<link>http://www.flashuser.net/flash-tricks/tips-tricks-11-customizable-flash-analogue-clock-as3.html</link>
		<comments>http://www.flashuser.net/flash-tricks/tips-tricks-11-customizable-flash-analogue-clock-as3.html#comments</comments>
		<pubDate>Fri, 28 Aug 2009 12:46:56 +0000</pubDate>
		<dc:creator>flashuser</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Flash Tips & Tricks]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[clock]]></category>
		<category><![CDATA[time]]></category>

		<guid isPermaLink="false">http://www.flashuser.net/?p=1796</guid>
		<description><![CDATA[<p>In this tutorial I&#8217;ll create a customizable analogue clock in ActionScript 3.0. What is a must know is that the time displayed depends on the users computer time. The code beyond is intuitive so the focus here is on the design. Follow this three simple steps to create your one clock. </p>
<p><span id="more-1796"></span>Take a look at the example below for the final result.</p>
<div align="center" class="border-media">

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_analogue_clock_302270391"
			class="flashmovie"
			width="320"
			height="320">
	<param name="movie" value="http://www.flashuser.net/flash-files/tutorials/analogue_clock_as3/analogue_clock.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashuser.net/flash-files/tutorials/analogue_clock_as3/analogue_clock.swf"
			name="fm_analogue_clock_302270391"
			width="320"
			height="320">
	<!--<![endif]-->
		<br />
 <!-- Begin Alternate Content --></p>
<p>
 <a href="http://adobe.com/go/getflashplayer"><br />
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /><br />
</a>
 </p>
<p><!-- End Alternate Content --></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
</div>
<p><strong>1. </strong>For the first step I created the clock face. I drew 3 circles, and center align them. I used blue and grey colors with gradients for the background clock to look nice. I also made here the lines for the minutes and hours.</p>
<p><strong>2. </strong> Create three new movie clips (Insert->New Symbol->Movie Clip) for seconds, minutes and hours clock hands. Inside each of them drew a coresponding shape. After that drag them on the Stage and center align to the clock. Give each Movie Clip an instance name (<strong>secondHand_</strong>, <strong>minuteHand_</strong>, <strong>hourHand_</strong>).</p>
<p><strong>3. </strong> Final step paste this code in the Actions tab of the first frame. Once you&#8217;ve done that test the movie.</p>
<pre class="brush: as3;">
var timer:Timer = new Timer(1000);
timer.addEventListener(TimerEvent.TIMER, clockHandler);
timer.start();

function clockHandler(event:TimerEvent)
{

	    // set hour
		var time = new Date();
		var hourHand = time.getHours();
		var minuteHand = time.getMinutes();
		var secondHand = time.getSeconds();

		hourHand_.rotation = 30 * hourHand + minuteHand / 2;
		minuteHand_.rotation = 6 * minuteHand;
		secondHand_.rotation = 6 * secondHand;
}
</pre>
<div id="download-file"><a href="http://www.flashuser.net/flash-files/tutorials/analogue_clock_as3/analogue_clock.zip" color="FF0000" target="_blank"><span>Download Source</span></a></div>
]]></description>
			<content:encoded><![CDATA[<p>In this tutorial I&#8217;ll create a customizable analogue clock in ActionScript 3.0. What is a must know is that the time displayed depends on the users computer time. The code beyond is intuitive so the focus here is on the design. Follow this three simple steps to create your one clock. </p>
<p><span id="more-1796"></span>Take a look at the example below for the final result.</p>
<div align="center" class="border-media">

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_analogue_clock_1130061103"
			class="flashmovie"
			width="320"
			height="320">
	<param name="movie" value="http://www.flashuser.net/flash-files/tutorials/analogue_clock_as3/analogue_clock.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashuser.net/flash-files/tutorials/analogue_clock_as3/analogue_clock.swf"
			name="fm_analogue_clock_1130061103"
			width="320"
			height="320">
	<!--<![endif]-->
		<br />
 <!-- Begin Alternate Content --></p>
<p>
 <a href="http://adobe.com/go/getflashplayer"><br />
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /><br />
</a>
 </p>
<p><!-- End Alternate Content --></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
</div>
<p><strong>1. </strong>For the first step I created the clock face. I drew 3 circles, and center align them. I used blue and grey colors with gradients for the background clock to look nice. I also made here the lines for the minutes and hours.</p>
<p><strong>2. </strong> Create three new movie clips (Insert->New Symbol->Movie Clip) for seconds, minutes and hours clock hands. Inside each of them drew a coresponding shape. After that drag them on the Stage and center align to the clock. Give each Movie Clip an instance name (<strong>secondHand_</strong>, <strong>minuteHand_</strong>, <strong>hourHand_</strong>).</p>
<p><strong>3. </strong> Final step paste this code in the Actions tab of the first frame. Once you&#8217;ve done that test the movie.</p>
<pre class="brush: as3;">
var timer:Timer = new Timer(1000);
timer.addEventListener(TimerEvent.TIMER, clockHandler);
timer.start();

function clockHandler(event:TimerEvent)
{

	    // set hour
		var time = new Date();
		var hourHand = time.getHours();
		var minuteHand = time.getMinutes();
		var secondHand = time.getSeconds();

		hourHand_.rotation = 30 * hourHand + minuteHand / 2;
		minuteHand_.rotation = 6 * minuteHand;
		secondHand_.rotation = 6 * secondHand;
}
</pre>
<div id="download-file"><a href="http://www.flashuser.net/flash-files/tutorials/analogue_clock_as3/analogue_clock.zip" color="FF0000" target="_blank"><span>Download Source</span></a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.flashuser.net/flash-tricks/tips-tricks-11-customizable-flash-analogue-clock-as3.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Tips &amp; Tricks 10: Using Drag &amp; Drop in Actionscript 3.0</title>
		<link>http://www.flashuser.net/flash-tricks/tips-tricks-10-using-drag-drop-in-actionscript-3-0.html</link>
		<comments>http://www.flashuser.net/flash-tricks/tips-tricks-10-using-drag-drop-in-actionscript-3-0.html#comments</comments>
		<pubDate>Fri, 07 Aug 2009 18:02:34 +0000</pubDate>
		<dc:creator>flashuser</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Flash Tips & Tricks]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[drag&drop]]></category>
		<category><![CDATA[flash]]></category>

		<guid isPermaLink="false">http://www.flashuser.net/?p=1060</guid>
		<description><![CDATA[<p>A really simple and useful tip. The drag and drop functionality in Actionscript 3.0. You can use it to drag pictures from one spot to other, to put items in a shoping cart, to arrange objects in a specific order etc. I&#8217;ll show you how to match 3 different shapes in their corresponding spots.</p>
<p><span id="more-1060"></span>Here is the final movie:</p>
<div align="center" class="border-media">

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_figures_1634002541"
			class="flashmovie"
			width="560"
			height="300">
	<param name="movie" value="http://www.flashuser.net/flash-files/flash_tips_tricks/drag_drop_as3/figures.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashuser.net/flash-files/flash_tips_tricks/drag_drop_as3/figures.swf"
			name="fm_figures_1634002541"
			width="560"
			height="300">
	<!--<![endif]-->
		<br />
 <!-- Begin Alternate Content --></p>
<p>
 <a href="http://adobe.com/go/getflashplayer"><br />
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /><br />
</a>
 </p>
<p><!-- End Alternate Content --></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
</div>
<p>How is done:</p>
<p><strong>1.</strong> Create the 3 small shapes and put them individually in a Movie Clip. Also give each of them an instance name (I call them <strong>item1</strong>, <strong>item2</strong>, <strong>item3</strong>).</p>
<p><strong>2.</strong> Now for the large shape, create an empty Movie Clip (instance name <strong>bin1</strong>). Draw a circle without stroke and convert it to a Movie Clip. Give it an instance name of <em>&#8220;shape&#8221;</em> and place it at <strong>x=0</strong> and <strong>y=0</strong>. Create a new layer and draw there a circle same width and height like the first one but without fill. Place it at the same coordinates.</p>
<p><strong>3.</strong> For the triangle and rectangle follow the steps from point 2, except the empty Movie Clip instances.( rectangle -<strong> bin2</strong> , triangle &#8211; <strong>bin3</strong> )</p>
<p><strong>4.</strong> Create two Dynamic TextFields (instance name <strong>itemName_txt</strong> and <strong>info_txt</strong>) and place them in a empty Movie Clip (instance name <strong>ilabel</strong>).</p>
<p> <strong>5.</strong> Final step copy the actionscript code bellow and paste it in the <strong>Actions</strong> tab.</p>
<pre class="brush: as3;">
item1.objName = &quot;circle&quot;;
item1.initX = item1.x;
item1.initY = item1.y;
item1.val = 0;

item2.objName = &quot;rectangle&quot;;
item2.initX = item2.x;
item2.initY = item2.y;
item2.val = 0;

item3.objName = &quot;triangle&quot;;
item3.initX = item3.x;
item3.initY = item3.y;
item3.val = 0;

bin1.shape.alpha = 0;
bin2.shape.alpha = 0;
bin3.shape.alpha = 0;

item1.buttonMode = true;
item2.buttonMode = true;
item3.buttonMode = true;

item1.addEventListener(MouseEvent.MOUSE_DOWN, mousePress);
item1.addEventListener(MouseEvent.MOUSE_UP, mouseRelease);
item2.addEventListener(MouseEvent.MOUSE_DOWN, mousePress);
item2.addEventListener(MouseEvent.MOUSE_UP, mouseRelease);
item3.addEventListener(MouseEvent.MOUSE_DOWN, mousePress);
item3.addEventListener(MouseEvent.MOUSE_UP, mouseRelease);

//Mouse Events

function mousePress(event:MouseEvent):void {
	var item:MovieClip = MovieClip(event.target);
	item.startDrag();
	item.scaleX = item.scaleY = .95;
	var topPos:uint = this.numChildren - 1;
	this.setChildIndex(item, topPos);
	ilabel.itemName_txt.text = item.objName;
}

function mouseRelease(event:MouseEvent):void {
	var item:MovieClip = MovieClip(event.target);
	item.stopDrag();

	switch (item.objName) {
		case &quot;circle&quot; :
			if (bin1.hitTestObject(item)) {
				updateShape(item, bin1);

			} else {
				ilabel.info_txt.text =&quot;WRONG!&quot;;
				item.scaleX = item.scaleY = 1;
			}
			break;
		case &quot;rectangle&quot; :
			if (bin2.hitTestObject(item)) {
				updateShape(item, bin2);

			} else {
				ilabel.info_txt.text =&quot;WRONG!&quot;;
				item.scaleX = item.scaleY = 1;
			}
			break;
		case &quot;triangle&quot; :
			if (bin3.hitTestObject(item)) {
				updateShape(item, bin3);
			} else {
				ilabel.info_txt.text =&quot;WRONG!&quot;;
				item.scaleX = item.scaleY = 1;
			}
			break;
		default :
			; ;
	}
}
function updateShape(item:MovieClip, bin:MovieClip):void {
	ilabel.itemName_txt.text = &quot;&quot;;
	item.scaleX = item.scaleY = 1;
	item.visible = false;
	ilabel.info_txt.text =&quot;CORRECT!&quot;;
	bin.shape.alpha = 1;
	item.val = 1;
	resetShapes();
}

function resetShapes() {
	if ((item1.val == 1)&amp;&amp; (item2.val == 1) &amp;&amp; (item3.val == 1)) {

		item1.x = item1.initX;
		item1.y = item1.initY;
		item2.x = item2.initX;
		item2.y = item2.initY;
		item3.x = item3.initX;
		item3.y = item3.initY;

		bin1.shape.alpha = 0;
		bin2.shape.alpha = 0;
		bin3.shape.alpha = 0;

		item1.visible = true;
		item2.visible = true;
		item3.visible = true;

		item1.val = 0;
		item2.val = 0;
		item3.val = 0;

	}
}
</pre>
<div id="download-file"><a href="http://www.flashuser.net/flash-files/flash_tips_tricks/drag_drop_as3/drag_drop_as3.zip" target="_blank"><span>Download Source</span></a></div>
]]></description>
			<content:encoded><![CDATA[<p>A really simple and useful tip. The drag and drop functionality in Actionscript 3.0. You can use it to drag pictures from one spot to other, to put items in a shoping cart, to arrange objects in a specific order etc. I&#8217;ll show you how to match 3 different shapes in their corresponding spots.</p>
<p><span id="more-1060"></span>Here is the final movie:</p>
<div align="center" class="border-media">

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_figures_815258222"
			class="flashmovie"
			width="560"
			height="300">
	<param name="movie" value="http://www.flashuser.net/flash-files/flash_tips_tricks/drag_drop_as3/figures.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashuser.net/flash-files/flash_tips_tricks/drag_drop_as3/figures.swf"
			name="fm_figures_815258222"
			width="560"
			height="300">
	<!--<![endif]-->
		<br />
 <!-- Begin Alternate Content --></p>
<p>
 <a href="http://adobe.com/go/getflashplayer"><br />
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /><br />
</a>
 </p>
<p><!-- End Alternate Content --></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
</div>
<p>How is done:</p>
<p><strong>1.</strong> Create the 3 small shapes and put them individually in a Movie Clip. Also give each of them an instance name (I call them <strong>item1</strong>, <strong>item2</strong>, <strong>item3</strong>).</p>
<p><strong>2.</strong> Now for the large shape, create an empty Movie Clip (instance name <strong>bin1</strong>). Draw a circle without stroke and convert it to a Movie Clip. Give it an instance name of <em>&#8220;shape&#8221;</em> and place it at <strong>x=0</strong> and <strong>y=0</strong>. Create a new layer and draw there a circle same width and height like the first one but without fill. Place it at the same coordinates.</p>
<p><strong>3.</strong> For the triangle and rectangle follow the steps from point 2, except the empty Movie Clip instances.( rectangle -<strong> bin2</strong> , triangle &#8211; <strong>bin3</strong> )</p>
<p><strong>4.</strong> Create two Dynamic TextFields (instance name <strong>itemName_txt</strong> and <strong>info_txt</strong>) and place them in a empty Movie Clip (instance name <strong>ilabel</strong>).</p>
<p> <strong>5.</strong> Final step copy the actionscript code bellow and paste it in the <strong>Actions</strong> tab.</p>
<pre class="brush: as3;">
item1.objName = &quot;circle&quot;;
item1.initX = item1.x;
item1.initY = item1.y;
item1.val = 0;

item2.objName = &quot;rectangle&quot;;
item2.initX = item2.x;
item2.initY = item2.y;
item2.val = 0;

item3.objName = &quot;triangle&quot;;
item3.initX = item3.x;
item3.initY = item3.y;
item3.val = 0;

bin1.shape.alpha = 0;
bin2.shape.alpha = 0;
bin3.shape.alpha = 0;

item1.buttonMode = true;
item2.buttonMode = true;
item3.buttonMode = true;

item1.addEventListener(MouseEvent.MOUSE_DOWN, mousePress);
item1.addEventListener(MouseEvent.MOUSE_UP, mouseRelease);
item2.addEventListener(MouseEvent.MOUSE_DOWN, mousePress);
item2.addEventListener(MouseEvent.MOUSE_UP, mouseRelease);
item3.addEventListener(MouseEvent.MOUSE_DOWN, mousePress);
item3.addEventListener(MouseEvent.MOUSE_UP, mouseRelease);

//Mouse Events

function mousePress(event:MouseEvent):void {
	var item:MovieClip = MovieClip(event.target);
	item.startDrag();
	item.scaleX = item.scaleY = .95;
	var topPos:uint = this.numChildren - 1;
	this.setChildIndex(item, topPos);
	ilabel.itemName_txt.text = item.objName;
}

function mouseRelease(event:MouseEvent):void {
	var item:MovieClip = MovieClip(event.target);
	item.stopDrag();

	switch (item.objName) {
		case &quot;circle&quot; :
			if (bin1.hitTestObject(item)) {
				updateShape(item, bin1);

			} else {
				ilabel.info_txt.text =&quot;WRONG!&quot;;
				item.scaleX = item.scaleY = 1;
			}
			break;
		case &quot;rectangle&quot; :
			if (bin2.hitTestObject(item)) {
				updateShape(item, bin2);

			} else {
				ilabel.info_txt.text =&quot;WRONG!&quot;;
				item.scaleX = item.scaleY = 1;
			}
			break;
		case &quot;triangle&quot; :
			if (bin3.hitTestObject(item)) {
				updateShape(item, bin3);
			} else {
				ilabel.info_txt.text =&quot;WRONG!&quot;;
				item.scaleX = item.scaleY = 1;
			}
			break;
		default :
			; ;
	}
}
function updateShape(item:MovieClip, bin:MovieClip):void {
	ilabel.itemName_txt.text = &quot;&quot;;
	item.scaleX = item.scaleY = 1;
	item.visible = false;
	ilabel.info_txt.text =&quot;CORRECT!&quot;;
	bin.shape.alpha = 1;
	item.val = 1;
	resetShapes();
}

function resetShapes() {
	if ((item1.val == 1)&amp;&amp; (item2.val == 1) &amp;&amp; (item3.val == 1)) {

		item1.x = item1.initX;
		item1.y = item1.initY;
		item2.x = item2.initX;
		item2.y = item2.initY;
		item3.x = item3.initX;
		item3.y = item3.initY;

		bin1.shape.alpha = 0;
		bin2.shape.alpha = 0;
		bin3.shape.alpha = 0;

		item1.visible = true;
		item2.visible = true;
		item3.visible = true;

		item1.val = 0;
		item2.val = 0;
		item3.val = 0;

	}
}
</pre>
<div id="download-file"><a href="http://www.flashuser.net/flash-files/flash_tips_tricks/drag_drop_as3/drag_drop_as3.zip" target="_blank"><span>Download Source</span></a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.flashuser.net/flash-tricks/tips-tricks-10-using-drag-drop-in-actionscript-3-0.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Tips &amp; Tricks 9: Using MouseWheel on Mac OS X &#8211; AS3</title>
		<link>http://www.flashuser.net/flash-tricks/tips-tricks-9-using-mousewheel-on-mac-os-x-as3.html</link>
		<comments>http://www.flashuser.net/flash-tricks/tips-tricks-9-using-mousewheel-on-mac-os-x-as3.html#comments</comments>
		<pubDate>Fri, 31 Jul 2009 18:40:54 +0000</pubDate>
		<dc:creator>flashuser</dc:creator>
				<category><![CDATA[Flash Tips & Tricks]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[mousewheel]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://www.flashuser.net/?p=892</guid>
		<description><![CDATA[<p>A couple of days ago I was reading some articles about what clients demand on a project and the features they are interested in. One of them is using the MouseWheel for different actions like scrolling text, zoom in and out etc. </p>
<p><span id="more-892"></span>So I came across <span id="writer-content"><a href="http://blog.pixelbreaker.com/flash/as30-mousewheel-on-mac-os-x/" color="FF0000" target="_blank">this blog</a></span> and found a useful tip for using the MouseWheel on Mac OS X, things being a little bit different here. This is done for ActionScript 3.0.</p>
<p>And since I was concerned myself on the matter I thought why not share it with you. It starts from SWFAddress add-on for deconcept&#8217;s SWFObject embedding system. We are going to add MouseWheel functionality to SWFObject. </p>
<p>In your main application class write the following code:</p>
<pre class="brush: as3;">
import com.pixelbreaker.ui.osx.MacMouseWheel;
MacMouseWheel.setup( stage );
</pre>
<p>After that you can add listeners to MovieClips, Sprites etc.</p>
<p>For downloading the source code take a visit to <span id="writer-content"><a href="http://blog.pixelbreaker.com/flash/as30-mousewheel-on-mac-os-x/" color="FF0000" target="_blank">PixelBreaker</a></span>. Also there is a JavaScript example to be used with dynamic embed method.</p>
<p>For those who want to know how you can use the MouseWheel for ActionScript 2.0 have a look at <span id="writer-content"><a href="http://blog.pixelbreaker.com/flash/swfmacmousewheel/" color="FF0000" target="_blank">this post</a></span>.</p>
<p>You may find some differences between browsers display of this MouseWheel effect on Mac but that’s because each browser has different fonts, size and display characteristics.</p>
]]></description>
			<content:encoded><![CDATA[<p>A couple of days ago I was reading some articles about what clients demand on a project and the features they are interested in. One of them is using the MouseWheel for different actions like scrolling text, zoom in and out etc. </p>
<p><span id="more-892"></span>So I came across <span id="writer-content"><a href="http://blog.pixelbreaker.com/flash/as30-mousewheel-on-mac-os-x/" color="FF0000" target="_blank">this blog</a></span> and found a useful tip for using the MouseWheel on Mac OS X, things being a little bit different here. This is done for ActionScript 3.0.</p>
<p>And since I was concerned myself on the matter I thought why not share it with you. It starts from SWFAddress add-on for deconcept&#8217;s SWFObject embedding system. We are going to add MouseWheel functionality to SWFObject. </p>
<p>In your main application class write the following code:</p>
<pre class="brush: as3;">
import com.pixelbreaker.ui.osx.MacMouseWheel;
MacMouseWheel.setup( stage );
</pre>
<p>After that you can add listeners to MovieClips, Sprites etc.</p>
<p>For downloading the source code take a visit to <span id="writer-content"><a href="http://blog.pixelbreaker.com/flash/as30-mousewheel-on-mac-os-x/" color="FF0000" target="_blank">PixelBreaker</a></span>. Also there is a JavaScript example to be used with dynamic embed method.</p>
<p>For those who want to know how you can use the MouseWheel for ActionScript 2.0 have a look at <span id="writer-content"><a href="http://blog.pixelbreaker.com/flash/swfmacmousewheel/" color="FF0000" target="_blank">this post</a></span>.</p>
<p>You may find some differences between browsers display of this MouseWheel effect on Mac but that’s because each browser has different fonts, size and display characteristics.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashuser.net/flash-tricks/tips-tricks-9-using-mousewheel-on-mac-os-x-as3.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Achieve a Flash Movie with Transparent Background</title>
		<link>http://www.flashuser.net/flash-tricks/achieve-a-flash-movie-with-transparent-background.html</link>
		<comments>http://www.flashuser.net/flash-tricks/achieve-a-flash-movie-with-transparent-background.html#comments</comments>
		<pubDate>Thu, 23 Jul 2009 07:39:50 +0000</pubDate>
		<dc:creator>flashuser</dc:creator>
				<category><![CDATA[Flash Tips & Tricks]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[layers]]></category>
		<category><![CDATA[movie]]></category>

		<guid isPermaLink="false">http://www.flashuser.net/?p=707</guid>
		<description><![CDATA[<p>When we set out to make a Flash movie in a layer on a DHTML page containing several layers, we usually encounter a problem of displaying. The first layer is above all the other layers no matter what their order is.</p>
<p><span id="more-707"></span><br />
Browsers are the reason for this issue because they place embedded plug-in content, such as a Flash movie or Java applet, on the topmost layer. But newer browsers add the ability to use transparent backgrounds in the Flash content. Using the WMODE parameter we’ll be able to do layering of Flash content with DHTML layers. The WMODE parameter can be &#8216;window&#8217; (default), &#8216;opaque&#8217;, or &#8216;transparent&#8217;.</p>
<p>So, for today&#8217;s tip we are going to learn how to make Flash movie with a transparent background.</p>
<p>It is important to know that the background of a Flash movie can be set to transparent which enables the background image or text to show through and allows the layering of Flash content with DHTML content.</p>
<p><strong>Setting options to make the Flash movie transparent</strong></p>
<p>We&#8217;re going to explain how it&#8217;s done in two ways.The first one in which we are going to use Flash for creating the HTML page and the movie. The second one contains HTML code that we can edit.</p>
<p><strong>A. Using Flash</strong></p>
<p>	We’ll create the HTML for a Flash movie using the Publish Settings feature. This dialog box provides an option to affect the WMODE setting. The options selected will be added to the HTML source code automatically. Follow the steps and see for yourself the result.</p>
<p>1.	Select the File menu -> Publish Settings</p>
<p>2.	In the dialog box there is a Format tab: select the HTML (.html) option</p>
<p>3.	Click the new HTML tab -> select the Window Mode menu</p>
<p>4.	Select the Transparent Windowless option</p>
<p>5.	Click Publish after finishing</p>
<p>That’s it. You can view the after effect.</p>
<p><strong>B. Editing HTML manually</strong></p>
<p>In order to edit an existing HTML file, we must add the WMODE parameters to the HTML code.</p>
<p>1.	Add the following parameter to the OBJECT tag: </p>
<pre class="brush: xml;"> &lt;param name=&quot;wmode&quot; value=&quot;transparent&quot;&gt; </pre>
<p>2.	Add the following parameter to the EMBED tag:</p>
<pre class="brush: xml;"> wmode=&quot;transparent&quot; </pre>
<p>That pretty much covers the basic idea for setting the WMODE so that you can obtain a Flash movie with a transparent background.</p>
]]></description>
			<content:encoded><![CDATA[<p>When we set out to make a Flash movie in a layer on a DHTML page containing several layers, we usually encounter a problem of displaying. The first layer is above all the other layers no matter what their order is.</p>
<p><span id="more-707"></span><br />
Browsers are the reason for this issue because they place embedded plug-in content, such as a Flash movie or Java applet, on the topmost layer. But newer browsers add the ability to use transparent backgrounds in the Flash content. Using the WMODE parameter we’ll be able to do layering of Flash content with DHTML layers. The WMODE parameter can be &#8216;window&#8217; (default), &#8216;opaque&#8217;, or &#8216;transparent&#8217;.</p>
<p>So, for today&#8217;s tip we are going to learn how to make Flash movie with a transparent background.</p>
<p>It is important to know that the background of a Flash movie can be set to transparent which enables the background image or text to show through and allows the layering of Flash content with DHTML content.</p>
<p><strong>Setting options to make the Flash movie transparent</strong></p>
<p>We&#8217;re going to explain how it&#8217;s done in two ways.The first one in which we are going to use Flash for creating the HTML page and the movie. The second one contains HTML code that we can edit.</p>
<p><strong>A. Using Flash</strong></p>
<p>	We’ll create the HTML for a Flash movie using the Publish Settings feature. This dialog box provides an option to affect the WMODE setting. The options selected will be added to the HTML source code automatically. Follow the steps and see for yourself the result.</p>
<p>1.	Select the File menu -> Publish Settings</p>
<p>2.	In the dialog box there is a Format tab: select the HTML (.html) option</p>
<p>3.	Click the new HTML tab -> select the Window Mode menu</p>
<p>4.	Select the Transparent Windowless option</p>
<p>5.	Click Publish after finishing</p>
<p>That’s it. You can view the after effect.</p>
<p><strong>B. Editing HTML manually</strong></p>
<p>In order to edit an existing HTML file, we must add the WMODE parameters to the HTML code.</p>
<p>1.	Add the following parameter to the OBJECT tag: </p>
<pre class="brush: xml;"> &lt;param name=&quot;wmode&quot; value=&quot;transparent&quot;&gt; </pre>
<p>2.	Add the following parameter to the EMBED tag:</p>
<pre class="brush: xml;"> wmode=&quot;transparent&quot; </pre>
<p>That pretty much covers the basic idea for setting the WMODE so that you can obtain a Flash movie with a transparent background.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashuser.net/flash-tricks/achieve-a-flash-movie-with-transparent-background.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Tips &amp; Tricks 8: Actionscript 3.0 &#8211; Easy Made Tooltip</title>
		<link>http://www.flashuser.net/flash-tricks/tips-tricks-8-actionscript-30-easy-made-tooltip.html</link>
		<comments>http://www.flashuser.net/flash-tricks/tips-tricks-8-actionscript-30-easy-made-tooltip.html#comments</comments>
		<pubDate>Sat, 18 Jul 2009 19:38:31 +0000</pubDate>
		<dc:creator>flashuser</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Flash Tips & Tricks]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[tooltip]]></category>

		<guid isPermaLink="false">http://www.flashuser.net/?p=588</guid>
		<description><![CDATA[<p>A tooltip is a brief, descriptive message that appears when you hover the mouse over an object. It is very useful and simple to create. I will create a basic one for you in Actionscript 3.0 with an &#8220;alpha&#8221; effect when you point the mouse over a movieclip.</p>
<p><span id="more-588"></span><br />
1. Open Flash and create a new AS 3 file. (200&#215;150)</p>
<p>2. Draw a rectangle(this will be our target object) and convert it to a movieclip. Give it an instance name of <strong>&#8220;mc&#8221;</strong></p>
<p>3. Now we&#8217;ll create the tooltip movieclip. Draw a stroke and create a dynamic TextField. Name it <strong>&#8220;txt&#8221;</strong>. Select both and covert them to a movieclip &#8220;Tooltip&#8221;. For this one check the <strong>&#8220;Export for Actionscript&#8221;</strong> box. Delete the movieclip you just created from the stage because we&#8217;ll build an instance of it from Actionscript.</p>
<p>4. On the first frame of the stage, open up Actions tab and write this code:</p>
<pre class="brush: as3;">
import fl.transitions.easing.*;
import fl.transitions.*;

mc.addEventListener(&quot;mouseOver&quot;, mouseRollOver);
mc.addEventListener(&quot;mouseOut&quot;, mouseRollOut);
mc.addEventListener(&quot;mouseMove&quot;, mouseMove1);

var tooltip:Tooltip = new Tooltip();
tooltip.txt.text = &quot;This is a tooltip&quot;;
tooltip.x = stage.mouseX;
tooltip.y = stage.mouseY - mc.height;

function mouseRollOver(e:MouseEvent):void {
	addChild(tooltip);
	var myTween:Tween = new Tween(tooltip, &quot;alpha&quot;, Regular.easeIn, 0, 1, 0.5, true);

}

function mouseRollOut(e:MouseEvent):void {
	removeChild(tooltip);
}

function mouseMove1(e:MouseEvent):void {
	tooltip.x = stage.mouseX;
	tooltip.y = stage.mouseY - mc.height;
}
</pre>
<p>5. This is how your tooltip should look like, roll over the red rectangle to see the effect. <span id="writer-content"><a href="http://www.flashuser.net/flash-files/flash_tips_tricks/08/tooltip.zip" color="FF0000" target="_blank"> Download the file<br />
 </a></span></p>
<div align="center" class="border-media">

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_tooltip_1016167520"
			class="flashmovie"
			width="200"
			height="150">
	<param name="movie" value="http://www.flashuser.net/flash-files/flash_tips_tricks/08/tooltip.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashuser.net/flash-files/flash_tips_tricks/08/tooltip.swf"
			name="fm_tooltip_1016167520"
			width="200"
			height="150">
	<!--<![endif]-->
		<br />
 <!-- Begin Alternate Content --></p>
<p>
 <a href="http://adobe.com/go/getflashplayer"><br />
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /><br />
</a>
 </p>
<p><!-- End Alternate Content --></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
</div>
]]></description>
			<content:encoded><![CDATA[<p>A tooltip is a brief, descriptive message that appears when you hover the mouse over an object. It is very useful and simple to create. I will create a basic one for you in Actionscript 3.0 with an &#8220;alpha&#8221; effect when you point the mouse over a movieclip.</p>
<p><span id="more-588"></span><br />
1. Open Flash and create a new AS 3 file. (200&#215;150)</p>
<p>2. Draw a rectangle(this will be our target object) and convert it to a movieclip. Give it an instance name of <strong>&#8220;mc&#8221;</strong></p>
<p>3. Now we&#8217;ll create the tooltip movieclip. Draw a stroke and create a dynamic TextField. Name it <strong>&#8220;txt&#8221;</strong>. Select both and covert them to a movieclip &#8220;Tooltip&#8221;. For this one check the <strong>&#8220;Export for Actionscript&#8221;</strong> box. Delete the movieclip you just created from the stage because we&#8217;ll build an instance of it from Actionscript.</p>
<p>4. On the first frame of the stage, open up Actions tab and write this code:</p>
<pre class="brush: as3;">
import fl.transitions.easing.*;
import fl.transitions.*;

mc.addEventListener(&quot;mouseOver&quot;, mouseRollOver);
mc.addEventListener(&quot;mouseOut&quot;, mouseRollOut);
mc.addEventListener(&quot;mouseMove&quot;, mouseMove1);

var tooltip:Tooltip = new Tooltip();
tooltip.txt.text = &quot;This is a tooltip&quot;;
tooltip.x = stage.mouseX;
tooltip.y = stage.mouseY - mc.height;

function mouseRollOver(e:MouseEvent):void {
	addChild(tooltip);
	var myTween:Tween = new Tween(tooltip, &quot;alpha&quot;, Regular.easeIn, 0, 1, 0.5, true);

}

function mouseRollOut(e:MouseEvent):void {
	removeChild(tooltip);
}

function mouseMove1(e:MouseEvent):void {
	tooltip.x = stage.mouseX;
	tooltip.y = stage.mouseY - mc.height;
}
</pre>
<p>5. This is how your tooltip should look like, roll over the red rectangle to see the effect. <span id="writer-content"><a href="http://www.flashuser.net/flash-files/flash_tips_tricks/08/tooltip.zip" color="FF0000" target="_blank"> Download the file<br />
 </a></span></p>
<div align="center" class="border-media">

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_tooltip_1311704260"
			class="flashmovie"
			width="200"
			height="150">
	<param name="movie" value="http://www.flashuser.net/flash-files/flash_tips_tricks/08/tooltip.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashuser.net/flash-files/flash_tips_tricks/08/tooltip.swf"
			name="fm_tooltip_1311704260"
			width="200"
			height="150">
	<!--<![endif]-->
		<br />
 <!-- Begin Alternate Content --></p>
<p>
 <a href="http://adobe.com/go/getflashplayer"><br />
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /><br />
</a>
 </p>
<p><!-- End Alternate Content --></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.flashuser.net/flash-tricks/tips-tricks-8-actionscript-30-easy-made-tooltip.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tips &amp; Tricks 7: Create Popup Windows in Flash &#8211; ActionScript 3.0</title>
		<link>http://www.flashuser.net/flash-tricks/daily-trick-7-create-popup-windows-in-actionscript-30.html</link>
		<comments>http://www.flashuser.net/flash-tricks/daily-trick-7-create-popup-windows-in-actionscript-30.html#comments</comments>
		<pubDate>Tue, 14 Jul 2009 12:58:14 +0000</pubDate>
		<dc:creator>flashuser</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Flash Tips & Tricks]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[popup]]></category>

		<guid isPermaLink="false">http://www.flashuser.net/?p=474</guid>
		<description><![CDATA[<p>A couple of days ago a fellow asked me how can he makes a popup window in Flash for his website. I showed him how and I was thinking why not to share with you also. It&#8217;s an easy and very powerfull trick. </p>
<p>Here we go (this example is for Actionscript 3.0):<br />
<span id="more-474"></span><br />
1. Create a MovieClip and give an instance name (e.g: myMovie)</p>
<p>2. Add an event listener to the movie you created:</p>
<pre class="brush: as3;">
myMovie.addEventListener(&quot;mouseDown&quot;,mousePress);
</pre>
<p>3. Create the mousePress function like so:</p>
<pre class="brush: as3;">
function mousePress(e:MouseEvent){

var url =&quot;javascript:window.open('http://www.yoursite.com','title',
'width=800,height=600,toolbar=no,resizable=no,menubar=no,
status=no,scrollbars=no');void(0);&quot;;

var request1:URLRequest = new URLRequest(url);

	try {
  navigateToURL(request1);
         }
      catch (e:Error) {
  trace(&quot;Error occurred!&quot;);
}
}
</pre>
<p>4. Publish the movie and preview it in your browser.</p>
]]></description>
			<content:encoded><![CDATA[<p>A couple of days ago a fellow asked me how can he makes a popup window in Flash for his website. I showed him how and I was thinking why not to share with you also. It&#8217;s an easy and very powerfull trick. </p>
<p>Here we go (this example is for Actionscript 3.0):<br />
<span id="more-474"></span><br />
1. Create a MovieClip and give an instance name (e.g: myMovie)</p>
<p>2. Add an event listener to the movie you created:</p>
<pre class="brush: as3;">
myMovie.addEventListener(&quot;mouseDown&quot;,mousePress);
</pre>
<p>3. Create the mousePress function like so:</p>
<pre class="brush: as3;">
function mousePress(e:MouseEvent){

var url =&quot;javascript:window.open('http://www.yoursite.com','title',
'width=800,height=600,toolbar=no,resizable=no,menubar=no,
status=no,scrollbars=no');void(0);&quot;;

var request1:URLRequest = new URLRequest(url);

	try {
  navigateToURL(request1);
         }
      catch (e:Error) {
  trace(&quot;Error occurred!&quot;);
}
}
</pre>
<p>4. Publish the movie and preview it in your browser.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashuser.net/flash-tricks/daily-trick-7-create-popup-windows-in-actionscript-30.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Tips &amp; Tricks 6: How to Create a Countdown Timer in Actionscript 3.0</title>
		<link>http://www.flashuser.net/flash-tricks/how-to-create-a-countdown-timer-in-actionscript-30.html</link>
		<comments>http://www.flashuser.net/flash-tricks/how-to-create-a-countdown-timer-in-actionscript-30.html#comments</comments>
		<pubDate>Thu, 09 Jul 2009 14:06:56 +0000</pubDate>
		<dc:creator>flashuser</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Flash Tips & Tricks]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[timer]]></category>

		<guid isPermaLink="false">http://www.flashuser.net/?p=376</guid>
		<description><![CDATA[<p>I will show you how to create a simple yet effective countdown timer in ActionScript 3.0. It counts from days to seconds and it&#8217;s useful when you schedule anniversaries, appointments, holidays.</p>
<p>1. Create a dynamic TextField and aligned to the right.<br />
<span id="more-376"></span><br />
2. Give it an instance name, I call it <em>countdown_txt</em>.</p>
<p>3. In the first frame of the scene open the Actions tab and paste this code:</p>
<pre class="brush: as3;">
this.addEventListener(&quot;enterFrame&quot;,startMovie);

function startMovie(e:Event) {

	var today:Date = new Date();
	var curTime = today.getTime();

	var myRetirement:Date = new Date(2050, 7, 9);// 2050 August 9 -- months are from 0 to 11

	var myRetirementTime = myRetirement.getTime();// get the time in miliseconds of myRetirement
	var timeLeft = myRetirementTime-curTime;

	var seconds = Math.floor(timeLeft/1000);
	var minutes = Math.floor(seconds/60);
	var hours = Math.floor(minutes/60);
	var days = Math.floor(hours/24);
	var years = Math.floor(days/365);

	seconds = String(seconds%60);

	if (seconds.length&lt;2) {
		seconds = &quot;0&quot;+seconds;
	}
	minutes = String(minutes%60);

	if (minutes.length&lt;2) {
		minutes = &quot;0&quot;+minutes;
	}
	hours = String(hours%24);

	if (hours.length&lt;2) {
		hours = &quot;0&quot;+hours;
	}
	days = String(days%365);

	if (days.length&lt;2) {
		days = &quot;0&quot;+days;
	}
	years = String(years);

	var count:String = years+&quot;:&quot;+days+&quot;:&quot;+hours+&quot;:&quot;+minutes+&quot;:&quot;+seconds;
	countdown_txt.text = count;
}
</pre>
<p><strong>Example:</strong></p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_retirement_as3_1402358738"
			class="flashmovie"
			width="200"
			height="100">
	<param name="movie" value="http://www.flashuser.net/flash-files/flash_tips_tricks/6/retirement_as3.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashuser.net/flash-files/flash_tips_tricks/6/retirement_as3.swf"
			name="fm_retirement_as3_1402358738"
			width="200"
			height="100">
	<!--<![endif]-->
		<br />
 <!-- Begin Alternate Content --></p>
<p>
 <a href="http://adobe.com/go/getflashplayer"><br />
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /><br />
</a>
 </p>
<p><!-- End Alternate Content --></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
]]></description>
			<content:encoded><![CDATA[<p>I will show you how to create a simple yet effective countdown timer in ActionScript 3.0. It counts from days to seconds and it&#8217;s useful when you schedule anniversaries, appointments, holidays.</p>
<p>1. Create a dynamic TextField and aligned to the right.<br />
<span id="more-376"></span><br />
2. Give it an instance name, I call it <em>countdown_txt</em>.</p>
<p>3. In the first frame of the scene open the Actions tab and paste this code:</p>
<pre class="brush: as3;">
this.addEventListener(&quot;enterFrame&quot;,startMovie);

function startMovie(e:Event) {

	var today:Date = new Date();
	var curTime = today.getTime();

	var myRetirement:Date = new Date(2050, 7, 9);// 2050 August 9 -- months are from 0 to 11

	var myRetirementTime = myRetirement.getTime();// get the time in miliseconds of myRetirement
	var timeLeft = myRetirementTime-curTime;

	var seconds = Math.floor(timeLeft/1000);
	var minutes = Math.floor(seconds/60);
	var hours = Math.floor(minutes/60);
	var days = Math.floor(hours/24);
	var years = Math.floor(days/365);

	seconds = String(seconds%60);

	if (seconds.length&lt;2) {
		seconds = &quot;0&quot;+seconds;
	}
	minutes = String(minutes%60);

	if (minutes.length&lt;2) {
		minutes = &quot;0&quot;+minutes;
	}
	hours = String(hours%24);

	if (hours.length&lt;2) {
		hours = &quot;0&quot;+hours;
	}
	days = String(days%365);

	if (days.length&lt;2) {
		days = &quot;0&quot;+days;
	}
	years = String(years);

	var count:String = years+&quot;:&quot;+days+&quot;:&quot;+hours+&quot;:&quot;+minutes+&quot;:&quot;+seconds;
	countdown_txt.text = count;
}
</pre>
<p><strong>Example:</strong></p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_retirement_as3_1231467951"
			class="flashmovie"
			width="200"
			height="100">
	<param name="movie" value="http://www.flashuser.net/flash-files/flash_tips_tricks/6/retirement_as3.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashuser.net/flash-files/flash_tips_tricks/6/retirement_as3.swf"
			name="fm_retirement_as3_1231467951"
			width="200"
			height="100">
	<!--<![endif]-->
		<br />
 <!-- Begin Alternate Content --></p>
<p>
 <a href="http://adobe.com/go/getflashplayer"><br />
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /><br />
</a>
 </p>
<p><!-- End Alternate Content --></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
]]></content:encoded>
			<wfw:commentRss>http://www.flashuser.net/flash-tricks/how-to-create-a-countdown-timer-in-actionscript-30.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Tips &amp; Tricks 5: Display digital time</title>
		<link>http://www.flashuser.net/flash-tricks/daily-trick-5-digital-time-display.html</link>
		<comments>http://www.flashuser.net/flash-tricks/daily-trick-5-digital-time-display.html#comments</comments>
		<pubDate>Sun, 28 Jun 2009 20:42:29 +0000</pubDate>
		<dc:creator>flashuser</dc:creator>
				<category><![CDATA[Actionscript 2.0]]></category>
		<category><![CDATA[Flash Tips & Tricks]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[digital]]></category>
		<category><![CDATA[time]]></category>

		<guid isPermaLink="false">http://www.flashuser.net/?p=252</guid>
		<description><![CDATA[<p>For today&#8217;s trick I will show how you can display digital time in Flash.</p>
<p>1. Using the Text Tool(T) create 3 Textboxes(hours, minutes, seconds).</p>
<p>2. Give each one a name in the Var field of the Properties Panel.(for this example I use h &#8211; hours, m &#8211; minutes, s &#8211; seconds).</p>
<p><span id="more-252"></span></p>
<p>3. Write the following Actionscript code:</p>
<pre class="brush: as3;">
var dt
var timeint;

date = new Date();
h = date.getHours();
m = date.getMinutes();
s = date.getSeconds();
timeint = setInterval(displayZ, 1000);

function displayZ() {
   date = new Date();
   h = date.getHours();
   m = date.getMinutes();
   s = date.getSeconds();
   if (h&lt;10) {
      h = &quot;0&quot;+h;
   }
   if (m&lt;10) {
      m = &quot;0&quot;+m;
   }
   if (s&lt;10) {
      s = &quot;0&quot;+s;
   }
}
</pre>
<p>4. If you want to display GMT Time(the example above uses Local Time) replace getHours() with getUTCHours, getMinutes() with getUTCMinutes() and getSeconds() with getUTCSeconds().</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_timer2_16867003"
			class="flashmovie"
			width="100"
			height="40">
	<param name="movie" value="http://www.flashuser.net/flash-files/flash_tips_tricks/5/timer2.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashuser.net/flash-files/flash_tips_tricks/5/timer2.swf"
			name="fm_timer2_16867003"
			width="100"
			height="40">
	<!--<![endif]-->
		<br />
 <!-- Begin Alternate Content --></p>
<p>
 <a href="http://adobe.com/go/getflashplayer"><br />
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /><br />
</a>
 </p>
<p><!-- End Alternate Content --></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
]]></description>
			<content:encoded><![CDATA[<p>For today&#8217;s trick I will show how you can display digital time in Flash.</p>
<p>1. Using the Text Tool(T) create 3 Textboxes(hours, minutes, seconds).</p>
<p>2. Give each one a name in the Var field of the Properties Panel.(for this example I use h &#8211; hours, m &#8211; minutes, s &#8211; seconds).</p>
<p><span id="more-252"></span></p>
<p>3. Write the following Actionscript code:</p>
<pre class="brush: as3;">
var dt
var timeint;

date = new Date();
h = date.getHours();
m = date.getMinutes();
s = date.getSeconds();
timeint = setInterval(displayZ, 1000);

function displayZ() {
   date = new Date();
   h = date.getHours();
   m = date.getMinutes();
   s = date.getSeconds();
   if (h&lt;10) {
      h = &quot;0&quot;+h;
   }
   if (m&lt;10) {
      m = &quot;0&quot;+m;
   }
   if (s&lt;10) {
      s = &quot;0&quot;+s;
   }
}
</pre>
<p>4. If you want to display GMT Time(the example above uses Local Time) replace getHours() with getUTCHours, getMinutes() with getUTCMinutes() and getSeconds() with getUTCSeconds().</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_timer2_1864667484"
			class="flashmovie"
			width="100"
			height="40">
	<param name="movie" value="http://www.flashuser.net/flash-files/flash_tips_tricks/5/timer2.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashuser.net/flash-files/flash_tips_tricks/5/timer2.swf"
			name="fm_timer2_1864667484"
			width="100"
			height="40">
	<!--<![endif]-->
		<br />
 <!-- Begin Alternate Content --></p>
<p>
 <a href="http://adobe.com/go/getflashplayer"><br />
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /><br />
</a>
 </p>
<p><!-- End Alternate Content --></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
]]></content:encoded>
			<wfw:commentRss>http://www.flashuser.net/flash-tricks/daily-trick-5-digital-time-display.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tips &amp; Tricks 4: Loading data from XML file in Actionscript 3.0</title>
		<link>http://www.flashuser.net/flash-tricks/daily-trick-4-loading-data-from-xml-file-in-actionscript-30.html</link>
		<comments>http://www.flashuser.net/flash-tricks/daily-trick-4-loading-data-from-xml-file-in-actionscript-30.html#comments</comments>
		<pubDate>Mon, 22 Jun 2009 20:44:51 +0000</pubDate>
		<dc:creator>flashuser</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Flash Tips & Tricks]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[daily trick]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.flashuser.net/?p=176</guid>
		<description><![CDATA[<p>In a previews post I wrote about how can you <span id="writer-content"><a href="http://www.flashuser.net/flash-tricks/daily-trick-2-loading-data-from-xml-file-in-actionscript-20.html" color="FF0000">load data from an xml file in Actionscript 2.0</a></span>. For today&#8217;s trick I will show you how can you do that using Actionscript 3.0.</p>
<p><span id="more-176"></span></p>
<p><strong>1. </strong>Prepare your xml file, here is the sample I will use:</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; standalone=&quot;yes&quot;?&gt;
&lt;images&gt;

    &lt;img image=&quot;photos/pic1.jpg&quot; description=&quot;This is the first image&quot; /&gt;

    &lt;img image=&quot;photos/pic2.jpg&quot; description=&quot;This is the second image&quot; /&gt;

    &lt;img image=&quot;photos/pic3.jpg&quot;  description=&quot;This is the third image&quot; /&gt;

&lt;/images&gt;
</pre>
<p><strong>2. </strong>The actionscript 3.0 code for extracting the xml file data:</p>
<pre class="brush: as3;">
var xmlData = &quot;images.xml&quot;;//set xml data file

var xmlObj: XMLDocument;

init();//init call -&gt; load config XML and create objects

function init() {
	xmlObj = new XMLDocument();
	xmlObj.ignoreWhite = true;

	var loader:URLLoader = new URLLoader();
	var request:URLRequest = new URLRequest(xmlData);
	loader.load(request);

	loader.addEventListener(&quot;complete&quot;, onComplete);
	loader.addEventListener(&quot;ioError&quot;, onIOError);
}

function onIOError(event:Event):void {
	trace(&quot;IOERROR (maybe XML file does not exit or have an incorrect name)&quot;);
}

function onComplete(event:Event):void {
	var loader:URLLoader = event.target as URLLoader;
	if (loader != null) {
		xmlObj.parseXML(loader.data);
		xmlHandler();
	} else {
		trace(&quot;Loader is not a URLLoader!&quot;);
	}
}

function xmlHandler() {
	addObjects();
}

var numItems;
var objects;

var image:Array = new Array();
var description:Array = new Array();

function addObjects() {//add objects in the scene

	objects = xmlObj.firstChild.childNodes;
	numItems = objects.length;

	for (var i=0; i&lt;numItems; i++) {
		var attr = objects[i].attributes;
		//Set the images
		image[i] = attr.image;
		description[i] = attr.description;
		trace(&quot;Path image: &quot;+image[i]+&quot; ------description: &quot;+description[i]);

	}
}
</pre>
<p>For any questions related to this method leave a comment and I will answer as soon as possible.</p>
<p><span id="writer-content"><a href="http://www.flashuser.net/flash-files/flash_tips_tricks/daily_trick4.zip" color="FF0000">Here</a></span> you can download the sample file.</p>
]]></description>
			<content:encoded><![CDATA[<p>In a previews post I wrote about how can you <span id="writer-content"><a href="http://www.flashuser.net/flash-tricks/daily-trick-2-loading-data-from-xml-file-in-actionscript-20.html" color="FF0000">load data from an xml file in Actionscript 2.0</a></span>. For today&#8217;s trick I will show you how can you do that using Actionscript 3.0.</p>
<p><span id="more-176"></span></p>
<p><strong>1. </strong>Prepare your xml file, here is the sample I will use:</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; standalone=&quot;yes&quot;?&gt;
&lt;images&gt;

    &lt;img image=&quot;photos/pic1.jpg&quot; description=&quot;This is the first image&quot; /&gt;

    &lt;img image=&quot;photos/pic2.jpg&quot; description=&quot;This is the second image&quot; /&gt;

    &lt;img image=&quot;photos/pic3.jpg&quot;  description=&quot;This is the third image&quot; /&gt;

&lt;/images&gt;
</pre>
<p><strong>2. </strong>The actionscript 3.0 code for extracting the xml file data:</p>
<pre class="brush: as3;">
var xmlData = &quot;images.xml&quot;;//set xml data file

var xmlObj: XMLDocument;

init();//init call -&gt; load config XML and create objects

function init() {
	xmlObj = new XMLDocument();
	xmlObj.ignoreWhite = true;

	var loader:URLLoader = new URLLoader();
	var request:URLRequest = new URLRequest(xmlData);
	loader.load(request);

	loader.addEventListener(&quot;complete&quot;, onComplete);
	loader.addEventListener(&quot;ioError&quot;, onIOError);
}

function onIOError(event:Event):void {
	trace(&quot;IOERROR (maybe XML file does not exit or have an incorrect name)&quot;);
}

function onComplete(event:Event):void {
	var loader:URLLoader = event.target as URLLoader;
	if (loader != null) {
		xmlObj.parseXML(loader.data);
		xmlHandler();
	} else {
		trace(&quot;Loader is not a URLLoader!&quot;);
	}
}

function xmlHandler() {
	addObjects();
}

var numItems;
var objects;

var image:Array = new Array();
var description:Array = new Array();

function addObjects() {//add objects in the scene

	objects = xmlObj.firstChild.childNodes;
	numItems = objects.length;

	for (var i=0; i&lt;numItems; i++) {
		var attr = objects[i].attributes;
		//Set the images
		image[i] = attr.image;
		description[i] = attr.description;
		trace(&quot;Path image: &quot;+image[i]+&quot; ------description: &quot;+description[i]);

	}
}
</pre>
<p>For any questions related to this method leave a comment and I will answer as soon as possible.</p>
<p><span id="writer-content"><a href="http://www.flashuser.net/flash-files/flash_tips_tricks/daily_trick4.zip" color="FF0000">Here</a></span> you can download the sample file.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashuser.net/flash-tricks/daily-trick-4-loading-data-from-xml-file-in-actionscript-30.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
