<?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, Flex and ActionScript tutorials - flashadvanced &#187; actionscript 3</title>
	<atom:link href="http://flashadvanced.com/tag/actionscript-3/feed/" rel="self" type="application/rss+xml" />
	<link>http://flashadvanced.com</link>
	<description>Become an advanced actionscript developer</description>
	<lastBuildDate>Sun, 30 Jan 2011 21:10:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Gradient background color changer</title>
		<link>http://flashadvanced.com/gradient-background-color-changer/</link>
		<comments>http://flashadvanced.com/gradient-background-color-changer/#comments</comments>
		<pubDate>Sat, 08 Aug 2009 18:07:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ActionScript 3.0 Basics]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[ColorPicker]]></category>
		<category><![CDATA[components]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[gradient background]]></category>

		<guid isPermaLink="false">http://flashadvanced.com/?p=420</guid>
		<description><![CDATA[In this tutorial you will learn how to use the AS3 Color Picker component to change the color of your gradient background. I will show you the technique of creating a nice gradient background Note: In order to complete this tutorial you need to download TweenMax library. Do it by clicking here. Unzip the downloaded [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://flashadvanced.com/?p=420"><br />
<img src="http://flashadvanced.com/wp-content/upload/cpicker/cpicker.jpg" /><br />
</a></p>
<p>In this tutorial you will learn how to use the <strong>AS3 Color Picker</strong> component to change the color of your gradient background. I will show you the technique of creating a <strong>nice gradient background</strong></p>
<p><span id="more-420"></span></p>
<h4>Note: In order to complete this tutorial you need to download TweenMax library. Do it by clicking <a href="http://blog.greensock.com/tweenmaxas3/">here</a>. Unzip the downloaded file in the same directory as the Flash files!</h4>
<p><span style="color: #ff0000;">1.</span> Open a new Flash document and save it under &#8220;ColorPicker.fla&#8221;. Set the size to 450 x 200 pixels.</p>
<p><span style="color: #ff0000;">2.</span> Take the rectangle tool, disable the stroke color, for fill color choose #999999 and then draw a rectangle with the same size as the document size. Convert the rectangle to movie clip and give it an instance name &#8220;bg&#8221;. Align the movie clip so it covers the stage.</p>
<p><span style="color: #ff0000;">3.</span> Create a new layer called &#8220;color picker&#8221;. Go to <strong>Window -> Components</strong> and drag a <strong>ColorPicker</strong> component to the stage. Give it instance name &#8220;cp&#8221;.</p>
<p><span style="color: #ff0000;">3.</span> Create a new layer called &#8220;gradient&#8221; and take the rectangle tool again. Disable the stroke color and draw a rectangle with size 450px by 200px. Position it so it covers the stage. Select the rectangle and go to the Color Panel by clicking Window -> Color. Under &#8220;type&#8221; choose &#8220;Radial&#8221;. For left color choose #E1E1E1 and set its alpha value to 25%. For right color choose #555555 and set its alpha value to 35%:</p>
<p><img src="http://flashadvanced.com/wp-content/upload/cpicker/gradient.jpg" /></p>
<p>This is how you make <strong>gradient backgrounds</strong> in flash.</p>
<p><span style="color: #ff0000;">4.</span> Create a new layer called &#8220;actions&#8221; and open the Actions Panel.</p>
<pre><code>
//importing classes
import fl.events.ColorPickerEvent;
import flash.geom.ColorTransform;
import gs.*;

//getting the color info
var colorInfo:ColorTransform = bg.transform.colorTransform;

//adding an event listener for color change
cp.addEventListener (ColorPickerEvent.CHANGE, colorChanged);

function colorChanged (e:ColorPickerEvent):void {

	//setting the color of the ColorTransform object
	colorInfo.color = cp.selectedColor;

	//applying the color change animation with TweenMax
	TweenMax.to(bg, 1, {tint:cp.selectedColor});
}
</code></pre>
<p>This is the easiest way to create a nice gradient background color changer using Color Picker component and TweenMax. </p>
<h4>Here is the final result:</h4>
<p><object width="450" height="200"><param name="movie" value="http://flashadvanced.com/wp-content/upload/cpicker/ColorPicker.swf"><embed src="http://flashadvanced.com/wp-content/upload/cpicker/ColorPicker.swf" width="450" height="200"></embed></object></p>
<p style="text-align: left; margin: 40px 40px 40px 0;"><a href="http://www.flashadvanced.com/wp-content/upload/cpicker/ColorPicker.zip"><img src="http://flashadvanced.com/wp-content/upload/other/download.jpg" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://flashadvanced.com/gradient-background-color-changer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>AS3 Currency Converter</title>
		<link>http://flashadvanced.com/as3-currency-converter/</link>
		<comments>http://flashadvanced.com/as3-currency-converter/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 14:16:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Advanced ActionScript 3]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[components]]></category>
		<category><![CDATA[currency converter]]></category>
		<category><![CDATA[DataProvider]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[list component]]></category>
		<category><![CDATA[TextInput]]></category>

		<guid isPermaLink="false">http://flashadvanced.com/?p=410</guid>
		<description><![CDATA[In this tutorial I will show you how to create a Currency Converter using ActionScript 3 and Flash Components. The calculations are made in runtime, no button clicks needed! 1. Open a new Flash document and save it under &#8220;CurrencyConverter.fla&#8221;. Set the document size to 400 x 250 pixels and for color choose #CCCCCC. 2. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://flashadvanced.com/?p=410"><br />
<img src="http://flashadvanced.com/wp-content/upload/converter/converter.jpg" /><br />
</a></p>
<p>In this tutorial I will show you how to create a Currency Converter using ActionScript 3 and Flash Components. The calculations are made in runtime, <strong>no button clicks needed</strong>!</p>
<p><span id="more-410"></span></p>
<p><span style="color: #ff0000;">1.</span> Open a new Flash document and save it under &#8220;CurrencyConverter.fla&#8221;. Set the document size to 400 x 250 pixels and for color choose #CCCCCC.</p>
<p><span style="color: #ff0000;">2.</span> Open the Components Panel by clicking Window -> Copmponents and drag two <strong>List Components</strong>. Make them 145px wide by 100px high. Give the first List component instance name &#8220;fromList&#8221; and the second &#8220;toList&#8221;.</p>
<p><span style="color: #ff0000;">3.</span> Go to the Components Panel again and drag a <strong>TextInput</strong> component. For instance name type &#8220;input_txt&#8221;. Position the TextInput somewhere over the first List component.</p>
<p><span style="color: #ff0000;">4.</span> Take the <strong>Text Tool</strong> and create a dynamic text field somewhere over the second List component. Give the text field instance name &#8220;result_txt&#8221;. Set its properties like this:</p>
<p><img src="http://flashadvanced.com/wp-content/upload/converter/text.jpg" /></p>
<p>I think you got the idea. The user types the amount in the TextInput and selects the currency that he would like to convert from. The result appears in the &#8220;result_txt&#8221; text field.</p>
<p><img src="http://flashadvanced.com/wp-content/upload/converter/structure.jpg" /></p>
<p><span style="color: #ff0000;">5.</span> We are now ready and have to go to ActionScript. Create a new layer called &#8220;actions&#8221; and open the Actions Panel.</p>
<pre><code>
//importing DataProvider class
import fl.data.DataProvider;

//creating a new data provider object
var dp:DataProvider = new DataProvider();
//first we create a variable to store the first value
var fromVal:Number;
//then we create a variable for the second value
var toVal:Number;
//here we store what the user inputs
var inputVal:Number
//the result value
var calculatedVal:Number;
//the user can enter only numbers in the TextInput
input_txt.restrict = "0-9";

//adding items to the Data Provider. The user sees the "label" property.
//For data we set the currency weight. US dollar has weight 1.
//The others are in proportion to US Dollar
dp.addItem( { label: "U.S. Dollars", data:1 });
dp.addItem( { label: "Australian Dollars", data: 0.832114 });
dp.addItem( { label: "Canada Dollars", data: 0.926215 } );
dp.addItem( { label: "Euro", data:1.42643 });
dp.addItem( { label: "United Kingdom Pounds", data:1.65151 });
dp.addItem( { label: "India Rupees", data:0.0207573 });
dp.addItem( { label: "Poland Zlotych", data:0.341955 });
dp.addItem( { label: "Russia Rubles", data:0.0325614 });
dp.addItem( { label: "Philippines Pesos", data:0.02079 });
dp.addItem( { label: "Bulgarian Leva", data:0.729733 });
dp.addItem( { label: "Brazil Reais", data:0.531719 });

//populating the lists
fromList.dataProvider = dp;
toList.dataProvider = dp;

//adding Event Change listeners to all of the components
fromList.addEventListener(Event.CHANGE, calculateResult);
toList.addEventListener(Event.CHANGE, calculateResult);
input_txt.addEventListener(Event.CHANGE, calculateResult);
//we set items that are set by default
fromList.selectedIndex = 0;
toList.selectedIndex = 3;

//initializing "fromVal" and "toVal"
fromVal = fromList.selectedItem.data;
toVal = toList.selectedItem.data;

function calculateResult(e:Event):void{
	fromVal = fromList.selectedItem.data;
	toVal = toList.selectedItem.data;
	//casting String to Number
	inputVal = Number(input_txt.text);
	//calculating the result
	calculatedVal = inputVal * (fromVal / toVal);
	//adding the result to the text field
	result_txt.text = calculatedVal.toString();
}
</pre>
<p></code></p>
<h4>Here is the final result:</h4>
<p><object width="400" height="250"><param name="movie" value="http://flashadvanced.com/wp-content/upload/converter/CurrencyConverter.swf"><embed src="http://flashadvanced.com/wp-content/upload/converter/CurrencyConverter.swf" width="400" height="250"></embed></object></p>
<p style="text-align: left; margin: 40px 40px 40px 0;"><a href="http://www.flashadvanced.com/wp-content/upload/converter/converter.zip"><img src="http://flashadvanced.com/wp-content/upload/other/download.jpg" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://flashadvanced.com/as3-currency-converter/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Creating a small shooting game in AS3</title>
		<link>http://flashadvanced.com/creating-small-shooting-game-as3/</link>
		<comments>http://flashadvanced.com/creating-small-shooting-game-as3/#comments</comments>
		<pubDate>Sun, 26 Jul 2009 13:04:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Advanced ActionScript 3]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[random]]></category>

		<guid isPermaLink="false">http://flashadvanced.com/?p=371</guid>
		<description><![CDATA[In this tutorial you will learn how to create a small &#8220;shooting stars&#8221; game using Flash and ActionScript 3. Let&#8217;s get started! 1. Open a new Flash document and save it under &#8220;ShootingGame.fla&#8221;. Set its size to 500 x 300 pixels. 2. First of all we need to draw the sight of our weapon. So [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://flashadvanced.com/?p=371"><br />
<img src="http://flashadvanced.com/wp-content/upload/shooting/shooting.jpg" /><br />
</a></p>
<p>In this tutorial you will learn how to create a small <strong>&#8220;shooting stars&#8221;</strong> game using Flash and ActionScript 3. Let&#8217;s get started!</p>
<p><span id="more-371"></span></p>
<p><span style="color: #ff0000;">1.</span> Open a new Flash document and save it under &#8220;ShootingGame.fla&#8221;. Set its size to 500 x 300 pixels.</p>
<p><span style="color: #ff0000;">2.</span> First of all we need to draw the sight of our weapon. So rename the first layer to &#8220;sight&#8221;. Take the <strong>Oval Tool</strong> and from the properties panel set its properties to Solid, Disabled Fill, Stroke height should be set to 3.<br />
Then take the Selection tool, select a part of the circle and cut it like this:</p>
<p><img src="http://flashadvanced.com/wp-content/upload/shooting/steps.jpg" /></p>
<p>The final step is to take the Line tool and to draw a cross. Just change the Stroke height value to 1.5. Select the whole sight and convert it to Movie Clip with instance name &#8220;sight&#8221; and <strong>registration point center</strong>.</p>
<p><span style="color: #ff0000;">3.</span> Now our sight is ready and we need to draw a star. Take the <strong>PolyStar Tool</strong> and set it properties like this:</p>
<p><img src="http://flashadvanced.com/wp-content/upload/shooting/properties.jpg" /></p>
<p>If your star is ready, select it and convert it to Movie Clip with <strong>registration point center</strong>. <strong>Linkage</strong> the star to class Star by going to the Library panel (Ctrl + L), right-clicking the Star movie clip and then setting the class name. Remove the star from the stage.</p>
<p><img src="http://flashadvanced.com/wp-content/upload/shooting/linkage.jpg" /></p>
<p><span style="color: #ff0000;">4.</span> Take the text tool and first create a Static text field and type &#8220;Score:&#8221;. Then create a <strong>dynamic</strong> text field with instance name &#8220;points_txt&#8221; and position it next to the static text field. Embed the Numeral values for the font and for color choose #FF0000. Align the text fields to the bottom right part of the stage.</p>
<p><span style="color: #ff0000;">5.</span> Create a new layer called &#8220;actions&#8221;, open Actions Panel and type this:</p>
<pre><code>
//importing tween classes
import fl.transitions.easing.*;
import fl.transitions.Tween;

//hiding the cursor
Mouse.hide();

//creating a new Star instance
var star:Star = new Star();
//creating the timer
var timer:Timer = new Timer(1000);
//we create variables for random X and Y positions
var randomX:Number;
var randomY:Number;
//variable for the alpha tween effect
var tween:Tween;
//we check if a star instance is already added to the stage
var starAdded:Boolean = false;
//we count the points
var points:int = 0;

//adding event handler on mouse move
stage.addEventListener(MouseEvent.MOUSE_MOVE, cursorMoveHandler);
//adding event handler to the timer
timer.addEventListener(TimerEvent.TIMER, timerHandler);
//starting the timer
timer.start();

function cursorMoveHandler(e:Event):void{
	//sight position matches the mouse position
	sight.x = mouseX;
	sight.y = mouseY;
}

function timerHandler(e:TimerEvent):void{
	//first we need to remove the star from the stage if already added
	if(starAdded){
		removeChild(star);
	}

	//positioning the star on a random position
	randomX = Math.random()*500;
	randomY = Math.random()*300;
	star.x = randomX;
	star.y = randomY;
	//adding the star to the stage
	addChild(star);
	//changing our boolean value to true
	starAdded = true;
	//adding a mouse click handler to the star
	star.addEventListener(MouseEvent.CLICK, clickHandler);
	//animating the star's appearance
	tween = new Tween(star, "alpha", Strong.easeOut, 0, 1, 3, true);
}

function clickHandler(e:Event):void{
	//when we click/shoot a star we increment the points
	points ++;
	//showing the result in the text field
	points_txt.text = points.toString();
}
</code></pre>
<h4>Here is the final result:</h4>
<p><object width="500" height="300"><param name="movie" value="http://flashadvanced.com/wp-content/upload/shooting/ShootingGame.swf"><embed src="http://flashadvanced.com/wp-content/upload/shooting/ShootingGame.swf" width="500" height="300"></embed></object></p>
<p style="text-align: left; margin: 40px 40px 40px 0;"><a href="http://www.flashadvanced.com/wp-content/upload/shooting/shooting.zip"><img src="http://flashadvanced.com/wp-content/upload/other/download.jpg" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://flashadvanced.com/creating-small-shooting-game-as3/feed/</wfw:commentRss>
		<slash:comments>81</slash:comments>
		</item>
		<item>
		<title>Using Flash CS3 components, Part 2</title>
		<link>http://flashadvanced.com/using-flash-cs3-components-part-2/</link>
		<comments>http://flashadvanced.com/using-flash-cs3-components-part-2/#comments</comments>
		<pubDate>Sun, 19 Jul 2009 15:04:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ActionScript 3.0 Basics]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[components]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[rotate]]></category>
		<category><![CDATA[scale]]></category>
		<category><![CDATA[slider]]></category>

		<guid isPermaLink="false">http://flashadvanced.com/?p=334</guid>
		<description><![CDATA[Today I will show you how to create a nice flash application using the Slider component. This slider will be used to rotate and scale objects on the stage. 1. Open a new Flash document and save it under &#8220;slidercomponent.fla&#8221;. 2. Rename the first layer to &#8220;figures&#8221; and draw a rectangle and a pentagon. 3. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://flashadvanced.com/?p=334"><br />
<img src="http://flashadvanced.com/wp-content/upload/components/comp2.jpg" /><br />
</a></p>
<p>Today I will show you how to create a nice flash <strong>application</strong> using the <strong>Slider</strong> component. This slider will be used to rotate and scale objects on the stage.</p>
<p><span id="more-334"></span></p>
<p><span style="color: #ff0000;">1.</span> Open a new Flash document and save it under &#8220;slidercomponent.fla&#8221;. </p>
<p><span style="color: #ff0000;">2.</span> Rename the first layer to &#8220;figures&#8221; and draw a rectangle and a pentagon.</p>
<p><span style="color: #ff0000;">3.</span> Convert the two figures to Movie Clips with registration points center. Give the rectangle instance name &#8220;rect&#8221; and the pentagon &#8211; &#8220;pent&#8221;.</p>
<p><span style="color: #ff0000;">4.</span> Create a new layer called &#8220;sliders&#8221;. Go to the Components by clicking Window -> Components. Drag two <strong>Slider components</strong> to the stage and position them under the figures. Give the first slider instance name &#8220;sliderrect&#8221; and the second &#8211; &#8220;sliderpent&#8221;.</p>
<p><span style="color: #ff0000;">5.</span> Create a new layer called &#8220;txt fields&#8221; and create two dynamic text fields and place them under the sliders. Give the first text field instance name &#8220;angle_txt&#8221; and the second &#8220;scale_txt&#8221;. Don&#8217;t forget to embed the font you use:</p>
<p><img src="http://flashadvanced.com/wp-content/upload/components/embed.jpg /></p>
<p><span style="color: #ff0000;">6.</span> Now, create a new layer called &#8220;actions&#8221; and open the actions panel.</p>
<pre><code>
//importing SliderEvent class
import fl.events.SliderEvent;

//adding event listener to the first slider
sliderrect.addEventListener(SliderEvent.CHANGE, rotateObject);
//setting slider's maximum value to 100
sliderrect.maximum = 100;
/*boolean value that indicates whether the SliderEvent.CHANGE event
	is dispatched continuously as the user moves the slider thumb*/
sliderrect.liveDragging = true;
//adding event listener to the second slider
sliderpent.addEventListener(SliderEvent.CHANGE, scaleObject);
//setting slider minimum value to 1 because we don't want our object to disappear
sliderpent.minimum = 1;
//setting default slider thumb's position
sliderpent.value = 5;
sliderpent.liveDragging = true;

function rotateObject(e:SliderEvent):void{
	/*we create a variable that stores slider's value (from 0 to 100) multiplied by 3.6
		so that the variable returns values from 0 to 360*/
	var rotVal:int = (sliderrect.value)*3.6;
	//setting rectangle's rotation
	rect.rotation = rotVal;
	//rotation info
	angle_txt.text = rotVal.toString();
}

function scaleObject(e:SliderEvent):void{
	//dividing event target value by 5 because we don't want too big figures
	pent.scaleX = e.target.value / 5;
	pent.scaleY = e.target.value / 5;
	//scale info
	scale_txt.text = (e.target.value / 5).toString();
}
</code></pre>
<p>That was all!</p>
<h4>Here is the final result:</h4>
<p><object width="400" height="220"><param name="movie" value="http://flashadvanced.com/wp-content/upload/components/slidercomponent.swf"><embed src="http://flashadvanced.com/wp-content/upload/components/slidercomponent.swf" width="400" height="220"></embed></object></p>
<p style="text-align: left; margin: 40px 40px 40px 0;"><a href="http://www.flashadvanced.com/wp-content/upload/components/slidercomponent.zip"><img src="http://flashadvanced.com/wp-content/upload/other/download.jpg" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://flashadvanced.com/using-flash-cs3-components-part-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Random color transform with AS3</title>
		<link>http://flashadvanced.com/random-color-transform-with-as3/</link>
		<comments>http://flashadvanced.com/random-color-transform-with-as3/#comments</comments>
		<pubDate>Sat, 18 Jul 2009 01:26:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ActionScript 3.0 Basics]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[colorTransform]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[random color]]></category>

		<guid isPermaLink="false">http://flashadvanced.com/?p=320</guid>
		<description><![CDATA[In this quick tutorial I will show you how to change the color of a Movie Clip using the Color Transform class and Math.random. 1. Open a new Flash CS3 document with size 400 x 100. 2. Create your logo on the stage. I made the Flashadvanced logo. Give it an instance name &#8220;logo_mc&#8221;. 3. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://flashadvanced.com/?p=320"><br />
<img src="http://flashadvanced.com/wp-content/upload/cTransform/cTransform.jpg" /><br />
</a></p>
<p>In this <strong>quick</strong> tutorial I will show you how to change the color of a Movie Clip using the <strong>Color Transform</strong> class and <strong>Math.random</strong>.</p>
<p><span id="more-320"></span></p>
<p><span style="color: #ff0000;">1.</span> Open a new Flash CS3 document with size 400 x 100.<br />
<span style="color: #ff0000;">2.</span> Create your logo on the stage. I made the <strong>Flashadvanced</strong> logo. Give it an instance name &#8220;logo_mc&#8221;.<br />
<span style="color: #ff0000;">3.</span> Create a new layer called &#8220;button&#8221;. Take the rectangle tool and draw a rectangle for your button. Select it and convert it to Button symbol with instance name &#8220;change_btn&#8221;.<br />
<span style="color: #ff0000;">4.</span> Now we move to ActionScript:</p>
<pre><code>
//we import transform classes
import flash.geom.ColorTransform;
import flash.geom.Transform;

//variable for the color value
var col:uint;
//creating a color transform object
var cTransform:ColorTransform = transform.colorTransform;

//when clicking the button we change the color
change_btn.addEventListener(MouseEvent.CLICK, changeColor);

function changeColor(e:MouseEvent):void{
	//random color value
	col = Math.random()*0xffffff;
	cTransform.color = col;
	logo_mc.transform.colorTransform = cTransform;
}
</code></pre>
<p>That was quick and easy, right?</p>
<h4>This is the final result</h4>
<p><object width="400" height="100"><param name="movie" value="http://flashadvanced.com/wp-content/upload/cTransform/randomCol.swf"><embed src="http://flashadvanced.com/wp-content/upload/cTransform/randomCol.swf" width="400" height="100"></embed></object></p>
<p style="text-align: left; margin: 40px 40px 40px 0;"><a href="http://www.flashadvanced.com/wp-content/upload/cTransform/randomCol.zip"><img src="http://flashadvanced.com/wp-content/upload/other/download.jpg" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://flashadvanced.com/random-color-transform-with-as3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ActionScript 3 full browser background</title>
		<link>http://flashadvanced.com/actionscript-3-full-browser-background/</link>
		<comments>http://flashadvanced.com/actionscript-3-full-browser-background/#comments</comments>
		<pubDate>Sun, 12 Jul 2009 12:21:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ActionScript 3.0 Basics]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[centered movie clip]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[full browser]]></category>
		<category><![CDATA[pattern]]></category>
		<category><![CDATA[tiled background]]></category>

		<guid isPermaLink="false">http://flashadvanced.com/?p=261</guid>
		<description><![CDATA[Today I will show you one of the must know techniques in Flash. We will be using ActionScript 3 to fill the whole browser window with a background pattern. Also, I will show you how to center your content on the stage. So, what we want to do is when we resize the browser, the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://flashadvanced.com/?p=261"><br />
<img src="http://flashadvanced.com/wp-content/upload/tilebg/tile.jpg" alt="" /><br />
</a></p>
<p>Today I will show you one of the <strong>must know techniques</strong> in Flash. We will be using ActionScript 3 to <strong>fill the whole browser window</strong> with a background pattern. Also, I will show you how to center your content on the stage. So, what we want to do is when we resize the browser, the content is centered and the background pattern is not scaled. Let&#8217;s get started!</p>
<p><span id="more-261"></span></p>
<p><span style="color: #ff0000;">1.</span> First of all, choose a background pattern from this website: <a href="http://www.squidfingers.com/patterns/" target="_blank">www.squidfingers.com</a>. Download the .zip file. Unzip the file and open a new Flash CS3 document. Save it as tile.fla. Import the pattern GIF by clicking File -&gt; Import -&gt; Import to Library.</p>
<p><span style="color: #ff0000;">2.</span> Go to the Library panel, select the background pattern and linkage it to a class named myBitmapImage:</p>
<p><img src="http://flashadvanced.com/wp-content/upload/tilebg/linkage.jpg" alt="" /></p>
<p><span style="color: #ff0000;">3.</span> Create a Movie Clip that you want to center. Set the registration point to center and give it an instance name &#8220;cont&#8221;.</p>
<p><span style="color: #ff0000;">4.</span> We are ready for ActionScript. Create new layer called &#8220;actions&#8221; and open the Actions panel.</p>
<pre><code>
//centering the content by default
cont.x = stage.stageWidth / 2;
cont.y = stage.stageHeight / 2;

//new pattern instance
var bg:myBitmapImage = new myBitmapImage(0,0);
//bitmap data
var tile:BitmapData = new BitmapData(100, 100, false, 0);
//rectangle which represents the stage
var rectPattern:Sprite;

function initStage():void
{
	//setting the scaling and the alignment of the stage
   stage.scaleMode = StageScaleMode.NO_SCALE;
   stage.align = StageAlign.TOP_LEFT;
   //we call the onStageResize function on a resize event
   stage.addEventListener(Event.RESIZE, onStageResize);

   //function for filling the background
   fillBG();
}
function fillBG():void
{
   //first we have to draw our bitmap image from library
   tile.draw(bg, new Matrix());
   //matrix that is used for beginBitmapFill function
   var matrix:Matrix = new Matrix();
   rectPattern = new Sprite();
   rectPattern.graphics.lineStyle();
   //beginBitmapFill method, fisrst we have to put bitmap data and second is matrix with value 0
   rectPattern.graphics.beginBitmapFill(tile, matrix);
   rectPattern.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
    //displaying rectangle rectDrawing
   addChild(rectPattern);
   //setting the child index to zero so the background is always behind the other objects on stage
   setChildIndex(rectPattern, 0);
}

function onStageResize(e:Event):void
{
   //repeat fill background function to fill resized stage
   fillBG();
   //always aligned at center of the stage
   cont.x = stage.stageWidth / 2;
   cont.y = stage.stageHeight / 2;
}

//init the stage
initStage();
</code></pre>
<p><span style="color: #ff0000;">5.</span> One of the last things to do is to set the publish settings. Go to File -&gt; Publish Settings and choose HTML. Under &#8220;Dimensions&#8221; choose &#8220;Percent&#8221;:</p>
<p><img src="http://flashadvanced.com/wp-content/upload/tilebg/publish.jpg" alt="" /></p>
<p><span style="color: #ff0000;">6.</span> The last thing to do is to publish the movie into a <strong>HTML</strong> page. So, once again go to File -&gt; Publish Preview -&gt; HTML. Your movie is already published in the directory where you saved your movie. Open the HTML file with a text editor and paste these lines of css code just before the  opening tag:</p>
<pre><code>
<!-- body{margin: 0px; padding: 0px} --></code>&lt;style&gt;
body{margin: 0px; padding: 0px}
&lt;/style&gt;</pre>
<p>We are ready. Everything fits perfect now. Enjoy!</p>
<p style="text-align: left; margin: 40px 40px 40px 0;"><a href="http://www.flashadvanced.com/wp-content/upload/tilebg/tile.html" target="_blank"><img src="http://flashadvanced.com/wp-content/upload/other/demo.jpg" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://flashadvanced.com/actionscript-3-full-browser-background/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

