<?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; actionscript 3</title>
	<atom:link href="http://www.flashuser.net/tag/actionscript-3/feed" rel="self" type="application/rss+xml" />
	<link>http://www.flashuser.net</link>
	<description>Useful and daily inspiration resources from web design, css, wordpress, graphic design, photography, illustrator, photoshop.</description>
	<lastBuildDate>Tue, 07 Feb 2012 10:23:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</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[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. This property replace the old fashion Actionscript 2 setRGB() method. Here&#8217;s the code for changing the color of a MovieClip in AS2: where myMovie is an instance of a MovieClip. For Actionscript 3 the code isn&#8217;t so complicated and here it is: var newColor:ColorTransform = myMovie.transform.colorTransform; newColor.color = [...]]]></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></p>
<p>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; title: ; notranslate">
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>
<p>var newColor:ColorTransform = myMovie.transform.colorTransform;<br />
     newColor.color = 0xFF5522;<br />
     myMovie.transform.colorTransform = newColor;</p>
<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_143980271"
			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_143980271"
			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; title: ; notranslate">
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>Using Caurina Tweener Class AS3</title>
		<link>http://www.flashuser.net/flash-actionscript-as3/using-caurina-tweener-class-as3.html</link>
		<comments>http://www.flashuser.net/flash-actionscript-as3/using-caurina-tweener-class-as3.html#comments</comments>
		<pubDate>Mon, 26 Oct 2009 16:52:16 +0000</pubDate>
		<dc:creator>flashuser</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[transitions]]></category>
		<category><![CDATA[tweener]]></category>

		<guid isPermaLink="false">http://www.flashuser.net/?p=2728</guid>
		<description><![CDATA[I enjoy to use in my flash projects the caurina tweener class, because it&#8217;s simple, elegant and flexible. You can use multiple properties in one transition without having problems, create complex animations with a few lines of code. If you&#8217;ll use the caurina tween you&#8217;ll have a better performance on the transitions relative to the built-in Adobe Flash transitions. I&#8217;ll explain to you how the Actionscript 3 Tweener works, illustrating that with examples. Visit the official page of the project if you want to know more. First of all download the latest version of the tweener. The download section (&#8220;Featured [...]]]></description>
			<content:encoded><![CDATA[<p>I enjoy to use in my flash projects the caurina tweener class, because it&#8217;s simple, elegant and flexible. You can use multiple properties in one transition without having problems, create complex animations with a few lines of code. If you&#8217;ll use the caurina tween you&#8217;ll have a better performance on the transitions relative to the built-in Adobe Flash transitions.</p>
<p><span id="more-2728"></span></p>
<p>I&#8217;ll explain to you how the Actionscript 3 Tweener works, illustrating that with examples.</p>
<p>Visit the <span  id="writer-content"><a href="http://code.google.com/p/tweener/" target="_blank">official page</a></span> of the project if you want to know more.</p>
<p>First of all download the latest version of the tweener. The download section (<em>&#8220;Featured downloades&#8221;</em>) is on the right side of the site.</p>
<p><strong>Important:</strong> The <em>caurina</em> folder must be in the same directory as your Flash project.</p>
<p>This line of code will import the caurina tweener class:</p>
<pre class="brush: as3; title: ; notranslate">
import caurina.transitions.Tweener;
</pre>
<p>Lets see how the code for a basic transition look like:</p>
<pre class="brush: as3; title: ; notranslate">
Tweener.addTween(circle, {x:390, time:1, transition:&quot;linear&quot;});
</pre>
<p>where:</p>
<ul id="circle">
<li><strong>circle</strong> &#8211;  is the DisplayObject</li>
<li>first parameter is the circle attribute</li>
<li><strong>time</strong> &#8211;  how long a transition will take in seconds</li>
<li><strong>transition</strong> &#8211; the type of transition to use; to experiment with other transitions have a look at the Transition Cheet Sheets</li>
<li>for other parameters check out the documentation</li>
</ul>
<p><strong>1. Simple Tween:</strong><br />
Move the <em>circle</em> MovieClip instance from the initial position x = 10 to x = 390 in a linear transition.</p>
<pre class="brush: as3; title: ; notranslate">
import caurina.transitions.Tweener;
circle.x = 10;
Tweener.addTween(circle, {x:390, time:1, transition:&quot;linear&quot;});
</pre>
<div align="center" class="border-media">

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_tweener1_25676700"
			class="flashmovie"
			width="450"
			height="200">
	<param name="movie" value="http://www.flashuser.net/flash-files/tutorials/tweener/tweener1.swf" />
	<param name="base" value="http://www.flashuser.net/flash-files/tutorials/tweener/" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashuser.net/flash-files/tutorials/tweener/tweener1.swf"
			name="fm_tweener1_25676700"
			width="450"
			height="200">
		<param name="base" value="http://www.flashuser.net/flash-files/tutorials/tweener/" />
	<!--<![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>2. Multiple MovieClip attributes: </strong><br />
Move the <em>circle</em> MovieClip instance from the initial position x = 10 y = 75 and alpha = 0 to x = 350 y = 150 and alpha = 1 in a linear transition.</p>
<pre class="brush: as3; title: ; notranslate">
import caurina.transitions.Tweener;
circle.x = 10;
circle.y = 75;
circle.alpha = 0;
Tweener.addTween(circle, {x:350, y:150, alpha:1, time:1, transition:&quot;linear&quot;});
</pre>
<div align="center" class="border-media">

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_tweener2_1132254056"
			class="flashmovie"
			width="450"
			height="200">
	<param name="movie" value="http://www.flashuser.net/flash-files/tutorials/tweener/tweener2.swf" />
	<param name="base" value="http://www.flashuser.net/flash-files/tutorials/tweener/" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashuser.net/flash-files/tutorials/tweener/tweener2.swf"
			name="fm_tweener2_1132254056"
			width="450"
			height="200">
		<param name="base" value="http://www.flashuser.net/flash-files/tutorials/tweener/" />
	<!--<![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>3. Two transitions: </strong><br />
The first one will move the circle on the x axis,the second one will change the y axis, different transitions.</p>
<pre class="brush: as3; title: ; notranslate">
import caurina.transitions.Tweener;
circle.x = 10;
circle.y = 75;
Tweener.addTween(circle, {x:350, time:0.5, transition:&quot;easeInQuart&quot;});
Tweener.addTween(circle, {y:150, time:1, transition:&quot;easeOutBounce&quot;});
</pre>
<div align="center" class="border-media">

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_tweener3_2013454700"
			class="flashmovie"
			width="450"
			height="200">
	<param name="movie" value="http://www.flashuser.net/flash-files/tutorials/tweener/tweener3.swf" />
	<param name="base" value="http://www.flashuser.net/flash-files/tutorials/tweener/" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashuser.net/flash-files/tutorials/tweener/tweener3.swf"
			name="fm_tweener3_2013454700"
			width="450"
			height="200">
		<param name="base" value="http://www.flashuser.net/flash-files/tutorials/tweener/" />
	<!--<![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>4. Delay parameter: </strong><br />
After the first transition is finished there will be a 1 seconds delay ( how it&#8217;s calculated: second transition delay &#8211; first transition time ) for the next transition to start.</p>
<pre class="brush: as3; title: ; notranslate">
import caurina.transitions.Tweener;
circle.x = 10;
circle.y = 75;
Tweener.addTween(circle, {x:350, time:0.5, transition:&quot;easeInQuart&quot;});
Tweener.addTween(circle, {y:150, time:1,transition:&quot;easeOutBounce&quot;, delay:1.5});
</pre>
<div align="center" class="border-media">

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_tweener4_1498828613"
			class="flashmovie"
			width="450"
			height="200">
	<param name="movie" value="http://www.flashuser.net/flash-files/tutorials/tweener/tweener4.swf" />
	<param name="base" value="http://www.flashuser.net/flash-files/tutorials/tweener/" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashuser.net/flash-files/tutorials/tweener/tweener4.swf"
			name="fm_tweener4_1498828613"
			width="450"
			height="200">
		<param name="base" value="http://www.flashuser.net/flash-files/tutorials/tweener/" />
	<!--<![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>5. onComplete parameter: </strong><br />
After the transition is finished you can do something else.</p>
<pre class="brush: as3; title: ; notranslate">
import caurina.transitions.Tweener;
tF.alpha = 0;
circle.x = 10;
circle.y = 75;
Tweener.addTween(circle, {x:350, time:0.5, transition:&quot;easeInQuart&quot;, onComplete:func});

function func() {
	tF.alpha = 1;
}
</pre>
<div align="center" class="border-media">

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_tweener5_799521558"
			class="flashmovie"
			width="450"
			height="200">
	<param name="movie" value="http://www.flashuser.net/flash-files/tutorials/tweener/tweener5.swf" />
	<param name="base" value="http://www.flashuser.net/flash-files/tutorials/tweener/" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashuser.net/flash-files/tutorials/tweener/tweener5.swf"
			name="fm_tweener5_799521558"
			width="450"
			height="200">
		<param name="base" value="http://www.flashuser.net/flash-files/tutorials/tweener/" />
	<!--<![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>6. onCompleteParams parameter: </strong><br />
If you want your onComplete function to have parameters you can do that using onCompleteParams.</p>
<pre class="brush: as3; title: ; notranslate">
import caurina.transitions.Tweener;
tF.alpha = 0;
	circle.x = 10;
	circle.y = 75;
	Tweener.addTween(circle, {x:350, time:0.5, transition:&quot;easeInQuart&quot;, onComplete:func, onCompleteParams:[&quot;Using onCompleteParams&quot;]});

function func(t:String) {
	tF.txt.text = t;
	tF.alpha = 1;
}
</pre>
<div align="center" class="border-media">

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_tweener6_1406356499"
			class="flashmovie"
			width="450"
			height="200">
	<param name="movie" value="http://www.flashuser.net/flash-files/tutorials/tweener/tweener6.swf" />
	<param name="base" value="http://www.flashuser.net/flash-files/tutorials/tweener/" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashuser.net/flash-files/tutorials/tweener/tweener6.swf"
			name="fm_tweener6_1406356499"
			width="450"
			height="200">
		<param name="base" value="http://www.flashuser.net/flash-files/tutorials/tweener/" />
	<!--<![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>7. Special Properties &#8211; Color: </strong><br />
This special class helps you to apply easy color transformation to your objects.</p>
<pre class="brush: as3; title: ; notranslate">
import caurina.transitions.Tweener;
import caurina.transitions.properties.ColorShortcuts;
ColorShortcuts.init();

circle.x = 10;
circle.y = 75;
Tweener.addTween(circle, {x:200, _color:0xFF0000, time:1, transition:&quot;easeOutElastic&quot;});
}
</pre>
<div align="center" class="border-media">

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_tweener7_1079289753"
			class="flashmovie"
			width="450"
			height="200">
	<param name="movie" value="http://www.flashuser.net/flash-files/tutorials/tweener/tweener7.swf" />
	<param name="base" value="http://www.flashuser.net/flash-files/tutorials/tweener/" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashuser.net/flash-files/tutorials/tweener/tweener7.swf"
			name="fm_tweener7_1079289753"
			width="450"
			height="200">
		<param name="base" value="http://www.flashuser.net/flash-files/tutorials/tweener/" />
	<!--<![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>Experiment with various parameters and you&#8217;ll create amazing animations with just a few lines of code. You can go deep by  using the Special Properties, see the online documentation for more.</p>
<div id="download-file"><a href="http://www.flashuser.net/flash-files/tutorials/tweener/tweener.zip" color="FF0000" target="_blank"><span>Download the source file</span></a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.flashuser.net/flash-actionscript-as3/using-caurina-tweener-class-as3.html/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Create a Magnifying Glass Effect in ActionScript 3.0</title>
		<link>http://www.flashuser.net/flash-actionscript-as3/create-a-magnifying-glass-in-actionscript-3-0.html</link>
		<comments>http://www.flashuser.net/flash-actionscript-as3/create-a-magnifying-glass-in-actionscript-3-0.html#comments</comments>
		<pubDate>Wed, 29 Jul 2009 15:25:25 +0000</pubDate>
		<dc:creator>flashuser</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[effect]]></category>
		<category><![CDATA[glass]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[magnify]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.flashuser.net/?p=852</guid>
		<description><![CDATA[In this tutorial I’ll explain how to create a magnifying glass effect in AS 3. All you need is a proper height resolution picture (I used a 1200px x 800px image) for a good magnifying effect and a few minutes to read the following guide lines. The picture is loaded from code so you can easily change it. Check the example below for the final effect. 
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_magnify_glass_827132733"
			class="flashmovie"
			width="400"
			height="267">
	<param name="movie" value="http://www.flashuser.net/flash-files/tutorials/magnifying_glass_as3/magnify_glass.swf " />
	<param name="base" value="http://www.flashuser.net/flash-files/tutorials/magnifying_glass_as3/" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashuser.net/flash-files/tutorials/magnifying_glass_as3/magnify_glass.swf "
			name="fm_magnify_glass_827132733"
			width="400"
			height="267">
		<param name="base" value="http://www.flashuser.net/flash-files/tutorials/magnifying_glass_as3/" />
	<!--<![endif]-->
		 
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object> 1. Open Flash and create a new ActionScript 3.0 file. Give the width and height of the Stage 3 times lower than your image (if you want [...]]]></description>
			<content:encoded><![CDATA[<p>In this tutorial I’ll explain how to create a magnifying glass effect in AS 3. All you need is a proper height resolution picture (I used a 1200px x 800px image) for a good magnifying effect and a few minutes to read the following guide lines. The picture is loaded from code so you can easily change it. Check the example below for the final effect.</p>
<p><span id="more-852"></span></p>
<div align="center" class="border-media">

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_magnify_glass_231063148"
			class="flashmovie"
			width="400"
			height="267">
	<param name="movie" value="http://www.flashuser.net/flash-files/tutorials/magnifying_glass_as3/magnify_glass.swf " />
	<param name="base" value="http://www.flashuser.net/flash-files/tutorials/magnifying_glass_as3/" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashuser.net/flash-files/tutorials/magnifying_glass_as3/magnify_glass.swf "
			name="fm_magnify_glass_231063148"
			width="400"
			height="267">
		<param name="base" value="http://www.flashuser.net/flash-files/tutorials/magnifying_glass_as3/" />
	<!--<![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> Open Flash and create a new ActionScript 3.0 file. Give the width and height of the Stage 3 times lower than your image (if you want to magnify the image by 3 times, e.g: my image is 1200×800 so the Stage must be 400×267)</p>
<p><strong>2.</strong> Create 4 layers as you can see in the image below. The stack order is important so the layer for the small image must be under the big image layer.</p>
<div align="center" class="border-media"><img src="http://www.flashuser.net/wp-content/uploads/2009/07/magnify_glass_1.jpg" alt="magnify_glass_1" title="magnify_glass_1" width="206" height="74" class="alignnone size-full wp-image-857" /></div>
<p><strong>3.</strong> Create 2 empty movie clips for the small and big image and drag them on the Stage. Put them in the corresponding layer, give an instance name for each one (<strong>smallImg</strong> and <strong>bigImg</strong>) then position them at x=0 and y=0.</p>
<p><strong>4.</strong>  Select the Oval Tool(O) and draw a circle. This will be our mask. Convert it to a movie clip and give it an instance name of <strong>circle</strong>.</p>
<p><strong>5.</strong> Select the scripts layer and open up <strong>Actions</strong> tab. In the code below we’ll add some variables that we’ll use, make a request for the image to be loaded and hide the mask.</p>
<pre class="brush: as3; title: ; notranslate">
import flash.display.BitmapData;

var loader:Loader;

var loading:TextField = new TextField();

var image:Bitmap;

init();

function init():void {

	circle.visible = false;

	loader=new Loader();
	loader.load(new URLRequest(&quot;street.jpg&quot;));

	loader.contentLoaderInfo.addEventListener(&quot;progress&quot;,progressLoad);
	loader.contentLoaderInfo.addEventListener(&quot;complete&quot;,completeLoad);

}
</pre>
<p><strong>6.</strong> Until the image is loaded we&#8217;ll display a text saying &#8220;Loading&#8230;&#8221;.</p>
<pre class="brush: as3; title: ; notranslate">

function progressLoad(e:Event):void {

	loading.x=100;
	loading.y=100;
	stage.addChild(loading);
	loading.text=&quot;Loading: &quot;;

	var tFormat:TextFormat=new TextFormat();

	tFormat.size = 20;
	tFormat.color = 0xFF0000;
	loading.setTextFormat(tFormat);

}
</pre>
<p><strong>7.</strong> After the loading is complete, we’ll add the image to the <strong>bigImg</strong> movie clip. Then duplicate, scale it down 3 times and put it in the <strong>smallImg</strong> movie clip. After that will mask the <strong>bigImg</strong> with the <strong>circle</strong> movie clip.</p>
<pre class="brush: as3; title: ; notranslate">
function completeLoad(e:Event):void {

	image=Bitmap(loader.content);

	bigImg.addChild(image);

	//create the small image from the big image
	var bmp:BitmapData = new BitmapData(bigImg.width, bigImg.height);
	bmp.draw(bigImg);

	var bitmap2:Bitmap = new Bitmap(bmp);

	bitmap2.scaleX /=3;
	bitmap2.scaleY /=3;

	smallImg.addChild(bitmap2);

	loader.contentLoaderInfo.removeEventListener(&quot;progress&quot;,progressLoad);
	loader.contentLoaderInfo.removeEventListener(&quot;complete&quot;,completeLoad);

	loader=null;

	loading.text=&quot;&quot;;
	loading.visible=false;

	circle.visible = true;
	bigImg.mask = circle;//add the circle mask to the big image
	stage.addEventListener(&quot;enterFrame&quot;,mGlass);

}
</pre>
<p><strong>8.</strong> Move the big image according to the position of the mask and hide the mouse.</p>
<pre class="brush: as3; title: ; notranslate">
function mGlass(e:Event) {

	bigImg.x = (mouseX * -2);
	bigImg.y = (mouseY * -2);

	circle.x = (mouseX);
	circle.y = (mouseY);

	Mouse.hide();
}
</pre>
<div id="download-file"><a href="http://www.flashuser.net/flash-files/tutorials/magnifying_glass_as3/magnify_glass_as3.zip" color="FF0000" target="_blank"><span>Download Source</span></a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.flashuser.net/flash-actionscript-as3/create-a-magnifying-glass-in-actionscript-3-0.html/feed</wfw:commentRss>
		<slash:comments>7</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[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. 1. Open Flash and create a new AS 3 file. (200&#215;150) 2. Draw a rectangle(this will be our target object) and convert it to a movieclip. Give it an instance name of &#8220;mc&#8221; 3. Now we&#8217;ll create the tooltip movieclip. Draw a stroke and create a dynamic TextField. Name it &#8220;txt&#8221;. Select [...]]]></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; title: ; notranslate">
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_212841685"
			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_212841685"
			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>1</slash:comments>
		</item>
		<item>
		<title>Tutorial: Simple Transition Menu &#8211; ActionScript 3.0</title>
		<link>http://www.flashuser.net/flash-menus/tutorial-simple-transition-menu-actionscript-30.html</link>
		<comments>http://www.flashuser.net/flash-menus/tutorial-simple-transition-menu-actionscript-30.html#comments</comments>
		<pubDate>Fri, 17 Jul 2009 07:30:50 +0000</pubDate>
		<dc:creator>flashuser</dc:creator>
				<category><![CDATA[Flash Menus]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[effects]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[menu]]></category>
		<category><![CDATA[transition]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.flashuser.net/?p=514</guid>
		<description><![CDATA[This tutorial is addressed to those flash beginners who want to find out how tweens works in ActionScript 3. I&#8217;ll create a simple and useful menu from scratch. I&#8217;ll try to be as clear as i can but for those who get lost on the way i&#8217;ll gladly answer your questions/comments. Here is what we&#8217;ll end up with: 
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_tutorial_simple_menu_as3_2104149781"
			class="flashmovie"
			width="350"
			height="80">
	<param name="movie" value="http://www.flashuser.net/flash-files/tutorials/simple_menu_as3/tutorial_simple_menu_as3.swf " />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashuser.net/flash-files/tutorials/simple_menu_as3/tutorial_simple_menu_as3.swf "
			name="fm_tutorial_simple_menu_as3_2104149781"
			width="350"
			height="80">
	<!--<![endif]-->
		 
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object> 1. Open up Flash and create a new ActionScript 3.0 file. 2. Create a new MovieClip (Insert->New Symbol). I named it &#8220;mainButton&#8221;. Check the &#8220;Export for Actionscript&#8221; box. We will use this generic button to create [...]]]></description>
			<content:encoded><![CDATA[<p>This tutorial is addressed to those flash beginners who want to find out how tweens works in ActionScript 3. I&#8217;ll create a simple and useful menu from scratch. I&#8217;ll try to be as clear as i can but for those who get lost on the way i&#8217;ll gladly answer your questions/comments.</p>
<p>Here is what we&#8217;ll end up with:</p>
<div align="center" class="border-media">

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_tutorial_simple_menu_as3_1245175459"
			class="flashmovie"
			width="350"
			height="80">
	<param name="movie" value="http://www.flashuser.net/flash-files/tutorials/simple_menu_as3/tutorial_simple_menu_as3.swf " />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashuser.net/flash-files/tutorials/simple_menu_as3/tutorial_simple_menu_as3.swf "
			name="fm_tutorial_simple_menu_as3_1245175459"
			width="350"
			height="80">
	<!--<![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>Open up Flash and create a new ActionScript 3.0 file.</p>
<p><strong>2. </strong>Create a new MovieClip (Insert->New Symbol). I named it <strong>&#8220;mainButton&#8221;</strong>. Check the &#8220;<strong>Export for Actionscript&#8221;</strong> box. We will use this generic button to create the other buttons using Actionscript.</p>
<div align="center" class="border-media">
<img src="http://www.flashuser.net/wp-content/uploads/2009/07/01_mainbutton_properties.jpg" alt="01_mainbutton_properties" title="01_mainbutton_properties" width="409" height="357" class="alignnone size-full wp-image-518" />
</div>
<p><strong>3.a </strong>Now inside the MovieClip we will create the button elements. Select the Text Tool and type <em>&#8220;Home&#8221;</em>. You can change it to whatever you like. Give it an instance name &#8211; <strong>&#8220;txt1&#8243;</strong>. Also don&#8217;t forget to embed the font because we will use it for animation. See the image below for other properties.</p>
<div align="center" class="border-media">
<img src="http://www.flashuser.net/wp-content/uploads/2009/07/02_txt1_properties.jpg" alt="02_txt1_properties" title="02_txt1_properties" width="564" height="100" class="alignnone size-full wp-image-521" />
</div>
<p><strong>3.b </strong>Create a new layer and draw a rectangle. I gave it a radial gradient and here are the other values: <strong>width</strong>: 100 ; <strong>height</strong>: 1.8 ; <strong>x</strong>: -50; <strong>y</strong>: 10;</p>
<div align="center" class="border-media">
<img src="http://www.flashuser.net/wp-content/uploads/2009/07/03_step.jpg" alt="03_step" title="03_step" width="212" height="67" class="alignnone size-full wp-image-522" />
</div>
<p><strong>3.c </strong>Create another layer. Draw another rectangle and copy the <strong>&#8220;Home&#8221;</strong> TextField and paste it in this layer you created. Change the instance name with <strong>&#8220;txt2&#8243;</strong>. Select both the rectangle and the TextField and press F8 to create another MovieClip with them. Name it <strong>&#8220;txtButtom&#8221;</strong>. Also give it an instance name <strong>&#8220;txtButtom&#8221;</strong>. See the images below for reference.  </p>
<div align="center" class="border-media">
<img src="http://www.flashuser.net/wp-content/uploads/2009/07/04_part1.jpg" alt="04_part1" title="04_part1" width="216" height="138" class="alignnone size-full wp-image-527" />
</div>
<div align="center" class="border-media">
<img src="http://www.flashuser.net/wp-content/uploads/2009/07/04_part2.jpg" alt="04_part2" title="04_part2" width="289" height="115" class="alignnone size-full wp-image-528" />
</div>
<p><strong>3.d </strong>Now we will create a layer mask. Make a new layer and move it to the top. Here you will draw a rectangle(see the images below for reference, the red rectangle is the mask) and after that right click on the layer and select <strong>&#8220;Mask&#8221;</strong>. Move the other layers according to the image below. The last layer is the hit area, copy the rectangle from the mask layer and paste it here and set the Alpha property for the rectangle to 0.</p>
<div align="center" class="border-media">
<img src="http://www.flashuser.net/wp-content/uploads/2009/07/05_part1.jpg" alt="05_part1" title="05_part1" width="200" height="139" class="alignnone size-full wp-image-532" />
</div>
<div align="center" class="border-media">
<img src="http://www.flashuser.net/wp-content/uploads/2009/07/05_part2.jpg" alt="05_part2" title="05_part2" width="231" height="93" class="alignnone size-full wp-image-533" />
</div>
<p><strong>4.a</strong> Now we&#8217;ll move to the Actionscript. Get out from the &#8220;mainButton&#8221;. In the first layer of the scene, open up the <strong>Actions</strong> tab. We&#8217;ll import the transitions libraries and create instances of the <strong>&#8220;mainButton&#8221;</strong>.</p>
<pre class="brush: as3; title: ; notranslate">
import fl.transitions.easing.*;
import fl.transitions.*;

var home = new mainButton();
this.addChild(home);

home.x= 80;
home.y=40;

var portfolio = new mainButton();
this.addChild(portfolio);

portfolio.txt1.text = &quot;PORTFOLIO&quot;;
portfolio.txtButtom.txt2.text = &quot;PORTFOLIO&quot;;
portfolio.x= home.x + home.width;
portfolio.y=home.y;

var contact = new mainButton();
this.addChild(contact);

contact.txt1.text = &quot;CONTACT&quot;;
contact.txtButtom.txt2.text = &quot;CONTACT&quot;;
contact.x= portfolio.x + portfolio.width;
contact.y=home.y;
</pre>
<p><strong>4.b </strong>We&#8217;ll add button properties and listenes to the instances for <strong>RollOver</strong> and<strong> RollOut</strong>.</p>
<pre class="brush: as3; title: ; notranslate">
home.buttonMode = true;
home.useHandCursor = true;
home.mouseChildren = false;

portfolio.buttonMode = true;
portfolio.useHandCursor = true;
portfolio.mouseChildren = false;

contact.buttonMode = true;
contact.useHandCursor = true;
contact.mouseChildren = false;

home.addEventListener(&quot;mouseOver&quot;, mouseRollOver);
portfolio.addEventListener(&quot;mouseOver&quot;, mouseRollOver);
contact.addEventListener(&quot;mouseOver&quot;, mouseRollOver);

home.addEventListener(&quot;mouseOut&quot;, mouseRollOut);
portfolio.addEventListener(&quot;mouseOut&quot;, mouseRollOut);
contact.addEventListener(&quot;mouseOut&quot;, mouseRollOut);
</pre>
<p><strong>4.c </strong>And finally create the <strong>mouseRollOver</strong> and <strong>mouseRollOut</strong> functions.</p>
<pre class="brush: as3; title: ; notranslate">
function mouseRollOver(e:MouseEvent) {

	var easingFunc = Back.easeOut;
	var xsa = 30;
	var xfa =-5;
	var duration =0.5;
	var myTween:Tween = new Tween(e.target.txtButtom, &quot;y&quot;, easingFunc, xsa, xfa, duration, true);

	var easingFunc2 = Regular.easeOut;
	var xsa2 = -16.3;
	var xfa2 = -46;
	var duration2 =0.5;
	var myTween2:Tween = new Tween(e.target.txt1, &quot;y&quot;, easingFunc2, xsa2, xfa2, duration2, true);

}

function mouseRollOut(e:MouseEvent) {

	var easingFunc3 = Regular.easeOut;
	var xsa3 = -5;
	var xfa3 =30;
	var duration3 = 0.5;
	new Tween(e.target.txtButtom, &quot;y&quot;, easingFunc3, xsa3, xfa3, duration3, true);

	var easingFunc4 = Regular.easeOut;
	var xsa4 = -46;
	var xfa4 = -16.3;
	var duration4 = 0.5;
	new Tween(e.target.txt1, &quot;y&quot;, easingFunc4, xsa4, xfa4, duration4, true);
}
</pre>
<p><strong>5. </strong>Enjoy and experiment with other tweening effects. <span id="writer-content"><a href="http://www.flashuser.net/flash-files/tutorials/simple_menu_as3/simple_transition_menu_as3.zip" color="FF0000" target="_blank">Download the source file</a></span>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashuser.net/flash-menus/tutorial-simple-transition-menu-actionscript-30.html/feed</wfw:commentRss>
		<slash:comments>8</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[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. Here we go (this example is for Actionscript 3.0): 1. Create a MovieClip and give an instance name (e.g: myMovie) 2. Add an event listener to the movie you created: 3. Create the mousePress function like so: 4. Publish the movie and preview it in your browser.]]></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; title: ; notranslate">
myMovie.addEventListener(&quot;mouseDown&quot;,mousePress);
</pre>
<p>3. Create the mousePress function like so:</p>
<pre class="brush: as3; title: ; notranslate">
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 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[In a previews post I wrote about how can you load data from an xml file in Actionscript 2.0. For today&#8217;s trick I will show you how can you do that using Actionscript 3.0. 1. Prepare your xml file, here is the sample I will use: 2. The actionscript 3.0 code for extracting the xml file data: For any questions related to this method leave a comment and I will answer as soon as possible. Here you can download the sample file.]]></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; title: ; notranslate">
&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; title: ; notranslate">
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>
		<item>
		<title>Tips &amp; Tricks 3: Loading of external resources such as images or SWFs using ActionScript 3.0</title>
		<link>http://www.flashuser.net/flash-tricks/loading-external-images-swfs-as3.html</link>
		<comments>http://www.flashuser.net/flash-tricks/loading-external-images-swfs-as3.html#comments</comments>
		<pubDate>Fri, 12 Jun 2009 09:22:30 +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[as3]]></category>
		<category><![CDATA[load swf]]></category>

		<guid isPermaLink="false">http://www.flashuser.net/?p=118</guid>
		<description><![CDATA[Maybe you have tried many different ways loading an external resource such as images or SWFs inside an empty movie clip from the stage and no matter what you have tried when loading another image / SWF again you saw two or three versions of it playing and hogging resources. Not good. You first need to understand that this loading problem of an external image or SWF is a bug in how the removing a child / garbage collector / display list mechanisms are working in AS3 / Flash player and not an issue with the SWF of your product(s). [...]]]></description>
			<content:encoded><![CDATA[<p>Maybe you have tried many different ways loading an external resource such as images or SWFs inside an empty movie clip from the stage and no matter what you have tried when loading another image / SWF again you saw two or three versions of it playing and hogging resources. Not good.</p>
<p><span id="more-118"></span></p>
<p>You first need to understand that this loading problem of an external image or SWF is a bug in how the removing a child / garbage collector / display list mechanisms are working in AS3 / Flash player and not an issue with the SWF of your product(s).</p>
<p>That&#8217;s because when you remove a child in Flash AS3, the reference to that child is still there in parent although you believed it was entirely removed. Here is a simple function that you can use in the future when you load images or SWFs inside an empty movie clip:</p>
<pre class="brush: as3; title: ; notranslate">function loadResource(resURL) {

var url = resURL;
var request1 = new URLRequest(url);
var loader1 = new Loader();

var mc1 = this.getChildByName(“mc”);
var nc = mc1.numChildren;

if (nc) { var l1 = mc1.getChildAt(0); mc1.removeChild(l1); l1 = null; }

loader1.load(request1); //start loading img/swf
mc1.addChild(loader1);

loader1.contentLoaderInfo.addEventListener(“complete”, this.finished_loading);

}

function finished_loading(e:Event) { trace(“Loading completed.” }</pre>
<p>, where mc is the instance name of an empty movie clip from the stage. You can simply call this function with the path string to your external SWFs and images avoiding references duplicates.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashuser.net/flash-tricks/loading-external-images-swfs-as3.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced

Served from: www.flashuser.net @ 2012-02-07 06:12:40 -->
