<?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>RiaCodes &#187; Flash</title>
	<atom:link href="http://www.riacodes.com/category/flash/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.riacodes.com</link>
	<description>Resources, tutorials , tips &#38; tricks for RIA : Flex, Flash, Air, AS3</description>
	<lastBuildDate>Tue, 31 May 2011 17:41:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Quick Tip : Launch prettyPhoto from Flash</title>
		<link>http://www.riacodes.com/flash/quick-tip-launch-prettyphoto-from-flash/</link>
		<comments>http://www.riacodes.com/flash/quick-tip-launch-prettyphoto-from-flash/#comments</comments>
		<pubDate>Mon, 30 May 2011 07:05:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://www.riacodes.com/?p=1828</guid>
		<description><![CDATA[<img src="http://www.files.riacodes.com/flash_prettyphoto-from-flash/preview.jpg" alt="Launch prettyPhoto from Flash"/>]]></description>
			<content:encoded><![CDATA[<p>In this Quick Tip, see how to launch prettyPhoto from a Flash movie by using the ExternalInterface class and the prettyPhoto API. In this example, we demonstrate how to open from a Flash movie a single image, a youtube video and a vimeo video with the prettyPhoto lightbox.<br />
<span id="more-1828"></span></p>
<div class="demosource"><a href="http://www.files.riacodes.com/flash_prettyphoto-from-flash/" target="_blank"><img src="http://www.riacodes.com/wp-content/themes/riacodes/images/icons/demo.png" alt="View Demo" /></a><a href="http://www.files.riacodes.com/flash_prettyphoto-from-flash/src.zip"><img src="http://www.riacodes.com/wp-content/themes/riacodes/images/icons/download.png" alt="Download Source" /></a></div>
<p><em>1.</em> First download prettyPhoto files at <a href="http://www.no-margin-for-errors.com/projects/prettyphoto-jquery-lightbox-clone/" target="_blank">http://www.no-margin-for-errors.com/projects/prettyphoto-jquery-lightbox-clone/</a> inside the Download Section.<br />
Open the zip file and open the index.html file.</p>
<p><em>2.</em> Modify it like beneath in order to begin with a fresh functional file. </p>
<pre class="brush: xml;">
&lt;!DOCTYPE html&gt;
&lt;html&gt;
	&lt;head&gt;
		&lt;title&gt;Launch prettyPhoto from Flash&lt;/title&gt;
		&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
		&lt;script src=&quot;js/jquery-1.4.4.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
		&lt;link rel=&quot;stylesheet&quot; href=&quot;css/prettyPhoto.css&quot; type=&quot;text/css&quot; media=&quot;screen&quot; title=&quot;prettyPhoto main stylesheet&quot; charset=&quot;utf-8&quot; /&gt;
		&lt;script src=&quot;js/jquery.prettyPhoto.js&quot; type=&quot;text/javascript&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;

		&lt;style type=&quot;text/css&quot; media=&quot;screen&quot;&gt;
			#main {	margin: 0 auto;	padding: 30px;	width: 500px;}
		&lt;/style&gt;

		&lt;script type=&quot;text/javascript&quot; charset=&quot;utf-8&quot;&gt;
				 $(document).ready(function(){
                 $(&quot;a[rel^='prettyPhoto']&quot;).prettyPhoto();
			});
		&lt;/script&gt;
	&lt;/head&gt;

	&lt;body&gt;
		&lt;div id=&quot;main&quot;&gt;

		&lt;/div&gt;
	&lt;/body&gt;
&lt;/html&gt;
</pre>
<p><em>3.</em> Create a new function that calls the open() function available in the prettyPhoto API. </p>
<pre class="brush: xml;">
function launchPrettyPhoto(urlContent, titleContent) {
	$.prettyPhoto.open(urlContent,titleContent);
}
</pre>
<p><em>4.</em> Now create a Flash file (AS3). Create 3 movieclips with instance name of &#8220;image_mc&#8221;, &#8220;youtube_mc&#8221; and &#8220;vimeo_mc&#8221;.</p>
<p><em>5.</em> Create an &#8220;actions&#8221; layer and open the actions panel.<br />
For each movie clip, set buttonMode to true and add a click event listener.</p>
<pre class="brush: jscript;">
image_mc.buttonMode = true;
youtube_mc.buttonMode = true;
vimeo_mc.buttonMode = true;

image_mc.addEventListener(MouseEvent.CLICK, onClickImage)
youtube_mc.addEventListener(MouseEvent.CLICK, onClickYoutube)
vimeo_mc.addEventListener(MouseEvent.CLICK, onClickVimeo)
</pre>
<p><em>6.</em> To set a Flash-Javascript communication, we use the ExternalInterface class. It allows us to invoke the JavaScript function that we&#8217;ve created earlier inside actionscript. </p>
<pre class="brush: jscript;">
function callPrettyPhoto(url:String,title:String):void{
	ExternalInterface.call(&quot;launchPrettyPhoto&quot;,url,title);
}
</pre>
<p><em>7.</em> Finally create the following functions that handle the click event for each movie clip:</p>
<pre class="brush: xml;">
function onClickImage(e:MouseEvent):void {
	callPrettyPhoto(&quot;http://www.files.riacodes.com/flash_prettyphoto-from-flash/images/6.jpg&quot;,&quot;Image demo&quot;);
}

function onClickYoutube(e:MouseEvent):void {
	callPrettyPhoto(&quot;http://www.youtube.com/watch?v=YdaMGcOyfjM&quot;,&quot;Youtube Demo&quot;);
}

function onClickVimeo(e:MouseEvent):void {
	callPrettyPhoto(&quot;http://vimeo.com/24315423&quot;,&quot;Vimeo Demo&quot;);
}
</pre>
<p><em>8.</em> We&#8217;ve finished the Flash part, here&#8217;s the final code. Publish your flash movie.</p>
<pre class="brush: xml;">
import flash.external.*;
import flash.events.MouseEvent;

image_mc.buttonMode = true;
youtube_mc.buttonMode = true;
vimeo_mc.buttonMode = true;

image_mc.addEventListener(MouseEvent.CLICK, onClickImage)
youtube_mc.addEventListener(MouseEvent.CLICK, onClickYoutube)
vimeo_mc.addEventListener(MouseEvent.CLICK, onClickVimeo)

function callPrettyPhoto(url:String,title:String):void{
	ExternalInterface.call(&quot;launchPrettyPhoto&quot;,url,title);
}

function onClickImage(e:MouseEvent):void {
	callPrettyPhoto(&quot;http://www.files.riacodes.com/flash_prettyphoto-from-flash/images/6.jpg&quot;,&quot;Image demo&quot;);
}

function onClickYoutube(e:MouseEvent):void {
	callPrettyPhoto(&quot;http://www.youtube.com/watch?v=YdaMGcOyfjM&quot;,&quot;Youtube Demo&quot;);
}

function onClickVimeo(e:MouseEvent):void {
	callPrettyPhoto(&quot;http://vimeo.com/24315423&quot;,&quot;Vimeo Demo&quot;);
}
</pre>
<p><em>9.</em> Return to you index.html file to embed the swf file. Inside the &#8220;main&#8221; div, insert the following code: (set the wmode parameter to transparent so that flash doesn&#8217;t display on top of prettyPhoto.)</p>
<pre class="brush: xml;">
&lt;object width=&quot;500&quot; height=&quot;200&quot; data=&quot;prettyphoto.swf&quot; type=&quot;application/x-shockwave-flash&quot;&gt;
		&lt;param name=&quot;src&quot; value=&quot;prettyphoto.swf&quot; /&gt;
		&lt;param name=&quot;quality&quot; value=&quot;high&quot;/&gt;
		&lt;param name=&quot;allowScriptAccess&quot; value=&quot;always&quot; /&gt;
		&lt;param name=&quot;wmode&quot; value=&quot;transparent&quot;/&gt;
&lt;/object&gt;
</pre>
<p><em>10.</em> Here&#8217;s the final html file:</p>
<pre class="brush: xml;">
&lt;!DOCTYPE html&gt;
&lt;html&gt;
	&lt;head&gt;
		&lt;title&gt; Launch prettyPhoto from Flash&lt;/title&gt;
		&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
		&lt;script src=&quot;js/jquery-1.4.4.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
		&lt;link rel=&quot;stylesheet&quot; href=&quot;css/prettyPhoto.css&quot; type=&quot;text/css&quot; media=&quot;screen&quot; title=&quot;prettyPhoto main stylesheet&quot; charset=&quot;utf-8&quot; /&gt;
		&lt;script src=&quot;js/jquery.prettyPhoto.js&quot; type=&quot;text/javascript&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;

		&lt;style type=&quot;text/css&quot; media=&quot;screen&quot;&gt;
			#main {	margin: 0 auto;	padding: 30px;	width: 500px;}
		&lt;/style&gt;

		&lt;script type=&quot;text/javascript&quot; charset=&quot;utf-8&quot;&gt;
			$(document).ready(function(){
                 $(&quot;a[rel^='prettyPhoto']&quot;).prettyPhoto();
			});

			function launchPrettyPhoto(urlContent, titleContent) {
				$.prettyPhoto.open(urlContent,titleContent);
			}
		&lt;/script&gt;

	&lt;/head&gt;

	&lt;body&gt;
		&lt;div id=&quot;main&quot;&gt;
			&lt;object width=&quot;500&quot; height=&quot;200&quot; data=&quot;prettyphoto.swf&quot; type=&quot;application/x-shockwave-flash&quot;&gt;
				&lt;param name=&quot;src&quot; value=&quot;prettyphoto.swf&quot; /&gt;
				&lt;param name=&quot;quality&quot; value=&quot;high&quot;/&gt;
				&lt;param name=&quot;allowScriptAccess&quot; value=&quot;always&quot; /&gt;
				&lt;param name=&quot;wmode&quot; value=&quot;transparent&quot;/&gt;
			&lt;/object&gt;
		&lt;/div&gt;
	&lt;/body&gt;
&lt;/html&gt;
</pre>
<p><em>11.</em> That&#8217;s it, hope you find this tip useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.riacodes.com/flash/quick-tip-launch-prettyphoto-from-flash/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Create a Before &amp; After Image Viewer</title>
		<link>http://www.riacodes.com/flash/create-a-before-after-image-viewer/</link>
		<comments>http://www.riacodes.com/flash/create-a-before-after-image-viewer/#comments</comments>
		<pubDate>Sun, 03 Apr 2011 06:27:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://www.riacodes.com/?p=1806</guid>
		<description><![CDATA[<img src="http://www.files.riacodes.com/flash_before-after-viewer/preview.jpg" alt=" Before After Image Viewer"/>]]></description>
			<content:encoded><![CDATA[<p>See how to create a Before &#038; After Image Viewer that allows you to compare two images with a draggable slider. The viewer can hide and reveal each image. It is useful for highlighting a before/after makeover or untouched/photoshopped image.<br />
<span id="more-1806"></span></p>
<div class="demosource"><a href="http://www.files.riacodes.com/flash_before-after-viewer/" target="_blank"><img src="http://www.riacodes.com/wp-content/themes/riacodes/images/icons/demo.png" alt="View Demo" /></a><a href="http://www.files.riacodes.com/flash_before-after-viewer/src.zip"><img src="http://www.riacodes.com/wp-content/themes/riacodes/images/icons/download.png" alt="Download Source" /></a></div>
<p><em>1.</em> Create a new flash file (Actionscript 3.0) and save it as before-after.fla. </p>
<p><em>2. </em> First, resize your &#8220;before&#8221; and &#8220;after&#8221; images to the same dimensions so that they are stackable. Set the stage&#8217;s dimensions to the images&#8217; dimensions.</p>
<p><em>3.</em> Create a layer named &#8220;before&#8221;, import the &#8220;before&#8221; image and convert it to a Movie Clip.<br />
Above the &#8220;before&#8221; layer create an &#8220;after &#8220;layer, import the &#8220;after&#8221; image and convert it to a Movie Clip with registration point at the top left. Give it an instance name of &#8220;after_mc&#8221;.</p>
<p><em>4.</em> Create a new layer named &#8220;mask&#8221;. With the Rectangle tool, draw a rectangle the same dimensions of the images. Convert it to a Movie Clip with registration point at the top left and give it an instance name of &#8220;mask_mc&#8221;.</p>
<p><em>5.</em> Create a new layer named &#8220;slider&#8221;. With the Line Tool, draw a vertical line the same height of the images with a stroke of 4px. Convert it to a Movie Clip and give it an instance name of &#8220;sliderbar_mc&#8221;. Position it to the left of the stage.</p>
<p><em>6.</em> Finally create an &#8220;actions&#8221; layer and add the following code:</p>
<pre class="brush: jscript;">
import com.greensock.*;
import com.greensock.easing.*;

function init() : void  {
	sliderbar_mc.buttonMode = true;
	sliderbar_mc.addEventListener(MouseEvent.MOUSE_DOWN,moveSliderbar);
	stage.addEventListener(MouseEvent.MOUSE_UP,stopSliderbar);
	mask_mc.alpha = 0;
	after_mc.mask = mask_mc;
	TweenLite.to(sliderbar_mc,4,{x:stage.stageWidth/2,ease:Elastic.easeOut});
	TweenLite.to(mask_mc,4,{x:stage.stageWidth/2,ease:Elastic.easeOut});
}  

function moveSliderbar(event:MouseEvent):void {
	stage.addEventListener(MouseEvent.MOUSE_MOVE,mouseMoveHandler);
}  

function stopSliderbar(event:MouseEvent):void{
	stage.removeEventListener(MouseEvent.MOUSE_MOVE,mouseMoveHandler);
}

function mouseMoveHandler(event:MouseEvent):void{
	sliderbar_mc.x = mouseX;
	if (sliderbar_mc.x &gt; stage.stageWidth){
		sliderbar_mc.x = stage.stageWidth;
	}
	else if(sliderbar_mc.x &lt; 0){
		sliderbar_mc.x = 0;
	}
	mask_mc.x = sliderbar_mc.x;
}

init();
</pre>
<p><em>7.</em> That&#8217;s it, test your movie to see it in action.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.riacodes.com/flash/create-a-before-after-image-viewer/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Win a &#8220;SlideCake, Powerful Flash Slider&#8221; component &#8211; Winners Announced</title>
		<link>http://www.riacodes.com/flash/win-a-slidecake-powerful-flash-slider-component/</link>
		<comments>http://www.riacodes.com/flash/win-a-slidecake-powerful-flash-slider-component/#comments</comments>
		<pubDate>Tue, 15 Feb 2011 17:38:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[slider]]></category>

		<guid isPermaLink="false">http://www.riacodes.com/?p=1671</guid>
		<description><![CDATA[<img src="http://www.files.riacodes.com/flash_giveaway-slidecake/preview.jpg" alt="Giveaway Contest - Slide Cake"/>]]></description>
			<content:encoded><![CDATA[<p>Giveaway Contest : Win a &#8220;SlideCake&#8221; component, a Powerful Flash Slider.<span id="more-1671"></span></p>
<p><strong>Congrats</strong><br />
Congratulations to FOXRIVER, MO7AMEDELALFY and PAWEL who are the 3 lucky winners of a Slidecake component.</p>
<p><strong>SlideCake</strong><br />
Flepstudio.org has just launched SlideCake, a Powerful Flash Slider component made for Flash designers and webmasters. With SlideCake, you can organize any type of web content into a beautiful and user-friendly slider.<br />
Click on the following link to see examples of usage of this really great component : <a href="http://slidecake.com/examples.php" target="_blank">www.slidecake.com/examples.php</a></p>
<p><strong>Giveaway Contest</strong><br />
<del datetime="2011-02-21T13:57:00+00:00">This week, we’re giving away to three lucky Riacodes readers a Slidecake&#8217;s free licence.</del></p>
<p><strong>What Do I Have To Do to Win?</strong><br />
<del datetime="2011-02-21T13:58:34+00:00">Just leave us a comment. Too easy&#8230; but hurry as we just let you until this sunday to leave one.<br />
The three winners will be announced on Monday 21st February.<br />
Good luck!</del></p>
]]></content:encoded>
			<wfw:commentRss>http://www.riacodes.com/flash/win-a-slidecake-powerful-flash-slider-component/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Create a 3D Flipping Youtube Player</title>
		<link>http://www.riacodes.com/flash/create-a-3d-flipping-youtube-player/</link>
		<comments>http://www.riacodes.com/flash/create-a-3d-flipping-youtube-player/#comments</comments>
		<pubDate>Thu, 10 Feb 2011 14:56:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[3D]]></category>
		<category><![CDATA[flip]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[youtube]]></category>

		<guid isPermaLink="false">http://www.riacodes.com/?p=1649</guid>
		<description><![CDATA[<img src="http://www.files.riacodes.com/flash_youtube-flip/preview.jpg" alt="Preview"/>]]></description>
			<content:encoded><![CDATA[<p>In this new AS3 tutorial, learn how to create a 3D flipping Youtube Player consisting of a youtube player that you can flip 180 degrees to show a description of the video.<br />
<span id="more-1649"></span></p>
<div class="demosource"><a href="http://www.files.riacodes.com/flash_youtube-flip/" target="_blank"><img src="http://www.riacodes.com/wp-content/themes/riacodes/images/icons/demo.png" alt="View Demo" /></a><a href="http://www.files.riacodes.com/flash_youtube-flip/src.zip"><img src="http://www.riacodes.com/wp-content/themes/riacodes/images/icons/download.png" alt="Download Source" /></a></div>
<p><em>1.</em> Create a new flash file (Actionscript 3.0) and save it as youtube.fla. </p>
<p><em>2.</em> First we are going to create the back side that contains the video&#8217;s description.<br />
To do so draw a rectangle 560&#215;340 (dimensions of your youtube player) with the color of your choice. With the Text tool write your description on it. Select both text and rectangle and convert it to a movie clip with an instance name of back.<br />
Once this movie clip is created, reselect it and convert it to a movie clip, set its registration point to the center and give it an instance name of container.<br />
At this point you shoud have on the stage the &#8220;container&#8221; movie clip that contains the &#8220;back&#8221; movie clip.</p>
<p><em>3.</em> Now create the button that will use to flip the container, convert it to a movie clip and give it an instance name of &#8220;flipBtn&#8221;.</p>
<p><em>4.</em> All is set on the stage, now let&#8217;s add some actionscript code. Open the actions panel.<br />
We&#8217;ll use the Tweenlite Engine and the Youtube AS3 API. If you are new to this, please visit our previous <a href="http://www.riacodes.com/flash/develop-with-the-official-youtube-chromeless-player-as3-api/">tutorial on the Youtube API</a>.<br />
First write the following statements in order to use the Tweenlite engine and communicate with www.youtube.com.</p>
<pre class="brush: jscript;">
import flash.system.Security;
import com.greensock.*;

Security.allowInsecureDomain(&quot;*&quot;);
Security.allowDomain(&quot;*&quot;);
</pre>
<p><em>5.</em> Then declare the following variables.  Set the videoUrl variable to the id of your youtube video.</p>
<pre class="brush: jscript;">
var videoUrl:String = &quot;owGykVbfgUE&quot;;
var player:Object;
var loader:Loader = new Loader();
var flipped:Boolean = false;
</pre>
<p><em>6.</em> Also set the back side&#8217;s rotationY property to -180 degrees and its visibility to false. </p>
<pre class="brush: jscript;">
container.back.rotationY = -180;
container.back.visible = false;

flipBtn.buttonMode = true;
</pre>
<p><em>7.</em> Next load the youtube video. Once the player is ready to play, we set the visibility of the back side to true and add a click event listener to the button.</p>
<pre class="brush: jscript;">
loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);
loader.load(new URLRequest(&quot;http://www.youtube.com/v/&quot;+videoUrl+&quot;?version=3&quot;));

function onLoaderInit(event:Event):void {
	container.addChild(loader);
	loader.x = -container.width /2;
	loader.y = -container.height /2;
	loader.content.addEventListener(&quot;onReady&quot;, onPlayerReady);
}

function onPlayerReady(event:Event):void {
  	player = loader.content;
   	player.loadVideoById(videoUrl);
   	player.setSize(560,340);
   	container.back.visible =true;
   	flipBtn.addEventListener(MouseEvent.CLICK,turn);
}
</pre>
<p><em>8.</em> Inside the turn() function we checked the value of the flipped boolean variable. If it&#8217;s false, we use Tweenlite to rotate the container 180° vertically so that we can see the back side with the description and pause the video.<br />
If it&#8217;s true, we use Tweenlite to rotate the container back to 0° so that we can see the youtube video and play it.<br />
We also add to the Tweenlite.to method an onUpdate event listener that calls the setVisibility() function in which we set which side of the container is on top.</p>
<pre class="brush: jscript;">
function turn(e:MouseEvent):void{
	if(!flipped){
		TweenLite.to(container,1,{rotationY:180,onUpdate:setVisibility});
		flipped =  true;
		player.pauseVideo();
	}
	else {
		TweenLite.to(container,1,{rotationY:0,onUpdate:setVisibility});
		flipped =  false;
		player.playVideo();
	}
}

function setVisibility():void{
	if(container.rotationY &gt;= 90){
		container.addChild(container.back);
	}else if(container.rotationY &lt; 90){
		container.addChild(loader);
	}
}
</pre>
<p><em>9.</em> Here&#8217;s the final code : </p>
<pre class="brush: jscript;">
import flash.system.Security;
import com.greensock.*;

Security.allowInsecureDomain(&quot;*&quot;);
Security.allowDomain(&quot;*&quot;);

var videoUrl:String = &quot;owGykVbfgUE&quot;;
var player:Object;
var loader:Loader = new Loader();
var flipped:Boolean = false;

container.back.rotationY = -180;
container.back.visible = false;
flipBtn.buttonMode = true;

loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);
loader.load(new URLRequest(&quot;http://www.youtube.com/v/&quot;+videoUrl+&quot;?version=3&quot;));

function onLoaderInit(event:Event):void {
	container.addChild(loader);
	loader.x = -container.width /2;
	loader.y = -container.height /2;
	loader.content.addEventListener(&quot;onReady&quot;, onPlayerReady);
}

function onPlayerReady(event:Event):void {
  	player = loader.content;
   	player.loadVideoById(videoUrl);
   	player.setSize(560,340);
   	container.back.visible =true;
   	flipBtn.addEventListener(MouseEvent.CLICK,turn);
}

function turn(e:MouseEvent):void{
	if(!flipped){
		TweenLite.to(container,1,{rotationY:180,onUpdate:setVisibility});
		flipped =  true;
		player.pauseVideo();
	}
	else {
		TweenLite.to(container,1,{rotationY:0,onUpdate:setVisibility});
		flipped =  false;
		player.playVideo();
	}
}

function setVisibility():void{
	if(container.rotationY &gt;= 90){
		container.addChild(container.back);
	}else if(container.rotationY &lt; 90){
		container.addChild(loader);
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.riacodes.com/flash/create-a-3d-flipping-youtube-player/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>XML Horizontal Accordion Photos Gallery</title>
		<link>http://www.riacodes.com/flash/xml-horizontal-accordion-photos-gallery/</link>
		<comments>http://www.riacodes.com/flash/xml-horizontal-accordion-photos-gallery/#comments</comments>
		<pubDate>Tue, 25 Jan 2011 18:31:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[accordion]]></category>
		<category><![CDATA[photos gallery]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.riacodes.com/?p=1617</guid>
		<description><![CDATA[<img src="http://www.files.riacodes.com/flash_horizontal-accordion-gallery/preview.jpg" alt="XML Horizontal Accordion Photos Gallery"/>]]></description>
			<content:encoded><![CDATA[<p>In this AS3 tutorial, learn how to create an XML driven Horizontal Accordion that displays a list of Photos.<br />
<span id="more-1617"></span>If you have the right <a href="http://www.webhostingsearch.com">webhosting</a> for your website that supports XML, this tutorial would work perfectly once you&#8217;ve decided to display the integration of these codes on your site.</p>
<div class="demosource"><a href="http://www.files.riacodes.com/flash_horizontal-accordion-gallery/" target="_blank"><img src="http://www.riacodes.com/wp-content/themes/riacodes/images/icons/demo.png" alt="View Demo" /></a><a href="http://www.files.riacodes.com/flash_horizontal-accordion-gallery/src.zip"><img src="http://www.riacodes.com/wp-content/themes/riacodes/images/icons/download.png" alt="Download Source" /></a></div>
<p><em>1.</em> Create a new flash file (Actionscript 3.0) and save it as accordion.fla. </p>
<p><em>2.</em> Create an XML file to store the photos&#8217; datas and save it as datas.xml. </p>
<pre class="brush: xml;">
&lt;photos&gt;
	&lt;photo&gt;1.jpg&lt;/photo&gt;
	&lt;photo&gt;2.jpg&lt;/photo&gt;
	&lt;photo&gt;3.jpg&lt;/photo&gt;
	&lt;photo&gt;4.jpg&lt;/photo&gt;
	&lt;photo&gt;5.jpg&lt;/photo&gt;
&lt;/photos&gt;
</pre>
<p>(Photos credits :<a href="http://www.freedigitalphotos.net/images/view_photog.php?photogid=587" target="_blank">Sunset</a>, <a href="http://www.freedigitalphotos.net/images/view_photog.php?photogid=902" target="_blank">Seabirds In Flight</a>, <a href="http://www.freedigitalphotos.net/images/view_photog.php?photogid=587" target="_blank">Apple Tree</a>, <a href="http://www.freedigitalphotos.net/images/view_photog.php?photogid=1058" target="_blank">Daffodils</a>, <a href="http://www.freedigitalphotos.net/images/view_photog.php?photogid=1556" target="_blank">White Cloud And Blue Sky</a>)</p>
<p><em>3.</em> Create an &#8220;actions&#8221; layer. Open the actions panel. We’ll use the Tweenlite engine so first write the following statements in order to use it and its easing properties.</p>
<pre class="brush: jscript;">
import com.greensock.TweenLite;
import com.greensock.easing.*;
</pre>
<p><em>4.</em> Next declare the following variables.</p>
<pre class="brush: jscript;">
var xml:XML;
var folder =&quot;photos/&quot;;
var totalPhotos:Number;
var photos:Array = new Array();
var photosLoaded:int = 0;
var current:Number = -1;
var accordion:Sprite
var photoWidth:uint;
var barWidth:Number;
</pre>
<p><em>5.</em>  Load the XML file :</p>
<pre class="brush: jscript;">
function loadXML( file:String ):void{
	var xmlLoader:URLLoader = new URLLoader();
	xmlLoader.load(new URLRequest(file));
	xmlLoader.addEventListener(Event.COMPLETE,parseXML);
}
</pre>
<p><em>6.</em>  Then parse the XML :</p>
<pre class="brush: jscript;">
function parseXML(e:Event):void {
	xml = new XML( e.target.data );
	totalPhotos =xml.photo.length();
	loadPhotos();
}
</pre>
<p><em>7. </em> Inside the loadPhotos() function, we loop through the xml datas to create a Loader for each photo. The onComplete() function checks whether all photos are loaded. If so, it calls the createPanels() function.</p>
<pre class="brush: jscript;">
function loadPhotos():void{
	for(var i:int = 0; i&lt;totalPhotos; i++){
		var loader:Loader = new Loader();
		loader.load(new URLRequest(folder+ xml.photo[i]));
		photos.push(loader);
		loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onComplete);
	}
}

function onComplete(e:Event):void{
	photosLoaded++;
	if(photosLoaded == totalPhotos)
		createPanels();
}
</pre>
<p><em>8.</em> Inside the createPanels() function, loop through the photos array in order to create the accordion&#8217;s panels that contain the photos. Position each panel according to the stage&#8217;s width divided by the total number of photos.</p>
<pre class="brush: jscript;">
function createPanels():void{
	accordion = new Sprite();
	addChild(accordion);

	for(var i:int = 0; i &lt; photos.length; i++){

		var panel:Sprite = new Sprite();
		barWidth = Math.ceil( stage.stageWidth / totalPhotos );
		panel.x = i  * barWidth;

		var bm:Bitmap = new Bitmap();
		bm = Bitmap(photos[i].content);
		bm.smoothing = true;
		panel.addChild(bm);
		accordion.addChild(panel);

		if (i==0) photoWidth=panel.width;

		if (i==photos.length-1)
			addListeners();
	}
}
</pre>
<p><em>9.</em> Once all the panels are created, we add our event listeners:</p>
<pre class="brush: jscript;">
function addListeners():void{
	for( var i:int = 0; i &lt; accordion.numChildren; i++ ){
		var sp:Sprite = accordion.getChildAt(i) as Sprite;
		sp.addEventListener(MouseEvent.ROLL_OVER, onPanelOver);
	}
	accordion.addEventListener(MouseEvent.ROLL_OUT,closePanels);
}
</pre>
<p><em>10.</em> Inside the onPanelOver() function we set each panel x coordinate so that the current one is entirely visible.</p>
<pre class="brush: jscript;">
function onPanelOver(e:MouseEvent):void{
	var panel:Sprite = Sprite(e.target);
	current = accordion.getChildIndex(panel);

	barWidth = Math.ceil((stage.stageWidth-photoWidth) / (totalPhotos-1));

	for( var i :int = 0; i &lt;accordion.numChildren; i++ ){
		var sp:Sprite = Sprite(accordion.getChildAt(i));
		var newX:Number;

		if( i &lt;= current )
			newX = i * barWidth;
		else
			newX = photoWidth + ( i - 1 ) * barWidth;

		TweenLite.to( sp, 1,{ x: newX,ease:Expo.easeOut} );
	}
}
</pre>
<p><em>11.</em> Inside the closePanels() function, we reposition each panel so that their visible part are of the same size.</p>
<pre class="brush: jscript;">
function closePanels(e:MouseEvent):void{
	var sp:Sprite;
	barWidth = Math.ceil(stage.stageWidth/totalPhotos);
	for( var i:int = 0; i &lt; accordion.numChildren; i++ ){
		sp = Sprite(accordion.getChildAt(i) );
		TweenLite.to( sp, .5, { x: i * barWidth } );
	}
}
</pre>
<p><em>12.</em> Finally don&#8217;t forget to call the loadXML() function to make it work.<br />
Here&#8217;s the final code.</p>
<pre class="brush: jscript;">
import com.greensock.TweenLite;
import com.greensock.easing.*;

var xml:XML;
var folder =&quot;photos/&quot;;
var totalPhotos:Number;
var photos:Array = new Array();
var photosLoaded:int = 0;
var current:Number = -1;
var accordion:Sprite
var photoWidth:uint;
var barWidth:Number;

loadXML( &quot;datas.xml&quot; );

function loadXML( file:String ):void{
	var xmlLoader:URLLoader = new URLLoader();
	xmlLoader.load(new URLRequest(file));
	xmlLoader.addEventListener(Event.COMPLETE,parseXML);
}

function parseXML(e:Event):void {
	xml = new XML( e.target.data );
	totalPhotos =xml.photo.length();
	loadPhotos();
}

function loadPhotos():void{
	for(var i:int = 0; i&lt;totalPhotos; i++){
		var loader:Loader = new Loader();
		loader.load(new URLRequest(folder+ xml.photo[i]));
		photos.push(loader);
		loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onComplete);
	}
}

function onComplete(e:Event):void{
	photosLoaded++;
	if(photosLoaded == totalPhotos)
		createPanels();
}

function createPanels():void{
	accordion = new Sprite();
	addChild(accordion);

	for(var i:int = 0; i &lt; photos.length; i++){

		var panel:Sprite = new Sprite();
		barWidth = Math.ceil(stage.stageWidth/totalPhotos);
		panel.x = i  * barWidth;

		var bm:Bitmap = new Bitmap();
		bm = Bitmap(photos[i].content);
		bm.smoothing = true;
		panel.addChild(bm);
		accordion.addChild(panel);

		if (i==0) photoWidth=panel.width;

		if (i==photos.length-1)
			addListeners();
	}
}

function addListeners():void{
	for(var i:int = 0; i &lt; accordion.numChildren; i++){
		var sp:Sprite = accordion.getChildAt(i) as Sprite;
		sp.addEventListener(MouseEvent.ROLL_OVER, onPanelOver);
	}
	accordion.addEventListener(MouseEvent.ROLL_OUT,closePanels);
}

function onPanelOver(e:MouseEvent):void{
	var panel:Sprite = Sprite(e.target);
	current = accordion.getChildIndex(panel);

	barWidth = Math.ceil((stage.stageWidth - photoWidth) / (totalPhotos-1));

	for(var i :int = 0; i &lt;accordion.numChildren; i++){
		var sp:Sprite = Sprite(accordion.getChildAt(i));
		var newX:Number;

		if(i &lt;= current)
			newX = i * barWidth;
		else
			newX = photoWidth + (i-1) * barWidth;

		TweenLite.to(sp,1,{x: newX,ease:Expo.easeOut});
	}
}

function closePanels(e:MouseEvent):void{
	var sp:Sprite;
	barWidth = Math.ceil( stage.stageWidth / totalPhotos );
	for(var i:int = 0; i &lt; accordion.numChildren; i++){
		sp = Sprite(accordion.getChildAt(i));
		TweenLite.to(sp,.5,{ x: i * barWidth});
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.riacodes.com/flash/xml-horizontal-accordion-photos-gallery/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Horizontal Photo Gallery with Hover Zoom Effect</title>
		<link>http://www.riacodes.com/flash/horizontal-photo-gallery-with-hover-zoom-effect/</link>
		<comments>http://www.riacodes.com/flash/horizontal-photo-gallery-with-hover-zoom-effect/#comments</comments>
		<pubDate>Tue, 18 Jan 2011 17:47:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[effect]]></category>
		<category><![CDATA[photos gallery]]></category>
		<category><![CDATA[Tweenlite]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[zoom]]></category>

		<guid isPermaLink="false">http://www.riacodes.com/?p=1599</guid>
		<description><![CDATA[<img src="http://www.files.riacodes.com/flash_image-gallery-hover-zoom-effect/preview.jpg"/>]]></description>
			<content:encoded><![CDATA[<p>In this tutorial, we&#8217;ll see how to build an XML driven Horizontal Photo Gallery with a nice Hover Zoom Effect.<br />
<span id="more-1599"></span></p>
<div class="demosource"><a href="http://www.files.riacodes.com/flash_image-gallery-hover-zoom-effect/" target="_blank"><img src="http://www.riacodes.com/wp-content/themes/riacodes/images/icons/demo.png" alt="View Demo" /></a><a href="http://www.files.riacodes.com/flash_image-gallery-hover-zoom-effect/src.zip"><img src="http://www.riacodes.com/wp-content/themes/riacodes/images/icons/download.png" alt="Download Source" /></a></div>
<p><em>1.</em> Create a new flash file (Actionscript 3.0) and save it as src.fla. </p>
<p><em>2.</em> Draw a rectangle the same size as your photos. Convert it to a movie clip with registration point at the top left and give it an instance name of &#8220;photo&#8221;. Draw an other rectangle a bit larger that will be used as the photo&#8217;s frame. Convert it to a movie clip with intance name of &#8220;bg&#8221;. Place &#8220;bg&#8221; behind &#8220;photo&#8221; and with both selected, convert the selection to a movie clip with registration point at the center. Export it for actionscript with a Class name of &#8220;Thumb&#8221;. Check the src.fla library to see the result.<br />
With the Text tool draw a dynamic Text box and give it an instance name of &#8220;currentPhoto&#8221;. This text will display the title of the hovered photo.</p>
<p><em>3.</em> Create an XML file to store the photos&#8217; datas and save it as gallery.xml. </p>
<pre class="brush: xml;">
&lt;gallery&gt;
   &lt;photo src=&quot;panther.jpg&quot; title=&quot;The Panther&quot;/&gt;
   &lt;photo src=&quot;lion.jpg&quot; title=&quot;The Lion&quot;/&gt;
   &lt;photo src=&quot;giraffe.jpg&quot; title=&quot;The Giraffe&quot;/&gt;
   &lt;photo src=&quot;buffalo.jpg&quot; title=&quot;The Buffalo&quot;/&gt;
   &lt;photo src=&quot;gazelle.jpg&quot; title=&quot;The Gazelle&quot;/&gt;
   &lt;photo src=&quot;elephant.jpg&quot; title=&quot;The Elephant&quot;/&gt;
   &lt;photo src=&quot;zebra.jpg&quot; title=&quot;The Zebra&quot;/&gt;
&lt;/gallery&gt;
</pre>
<p><em>4.</em> Create an &#8220;actions&#8221; layer. Open the actions panel. We’ll use the Tweenlite engine so first write the following statements in order to use it and the TintPlugin.</p>
<pre class="brush: jscript;">
import com.greensock.TweenLite;
import com.greensock.plugins.*;
TweenPlugin.activate([TintPlugin]);
</pre>
<p><em>5.</em> Next declare the following variables.</p>
<pre class="brush: jscript;">
var xml:XML;
var photos:Array;
var totalPhotos:Number;
var folder:String = &quot;photos/&quot;;
var gallery:Sprite;
var photosLoaded:int=0;
</pre>
<p><em>6.</em>  Load the XML file by creating a loadXML() function. When the load is complete, it will call the parseXML() function.</p>
<pre class="brush: jscript;">
function loadXML(file:String):void{
	var xmlLoader:URLLoader = new URLLoader();
	xmlLoader.load(new URLRequest(file));
	xmlLoader.addEventListener(Event.COMPLETE, parseXML);
}
</pre>
<p><em>7.</em>  Then we need to parse the XML. We set our xml variable to the xml data, get the total amount of photos and call the l loadGallery() function.</p>
<pre class="brush: jscript;">
function parseXML(e:Event):void{
	xml = new XML(e.target.data);
	totalPhotos = xml.children().length();
	loadGallery();
}
</pre>
<p><em>8. </em> Inside the loadGallery() function, we create a “for” statement to loop through the xml datas to create a Loader for each photo. We store the Loader inside our photos Array variable, and add the Event.COMPLETE listener.</p>
<pre class="brush: jscript;">
function loadGallery():void{
	photos = new Array();
	for(var i:int = 0; i&lt;totalPhotos; i++){
		var loader:Loader = new Loader();
		loader.load(new URLRequest(folder + xml.photo[i].@src));
		photos.push(loader);
		loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onComplete);
	}
}
</pre>
<p><em>9.</em> The onComplete() function checks whether all photos are loaded. If so, it calls the createThumbs() function.</p>
<pre class="brush: jscript;">
function onComplete(e:Event):void{
	photosLoaded++;
	if(photosLoaded == totalPhotos){
		createThumbs();
	}
}
</pre>
<p><em>10.</em> Inside the createThumbs() function, create a “for” statement to loop through the photos array in order to create the gallery thumbs. For each thumb, scale it down to half size, set its title property, create its bitmap photo and add it to the gallery.<br />
We use Tweenlite to make them appear one after another.<br />
Position the gallery at the center of the stage.</p>
<pre class="brush: jscript;">
function createThumbs():void{
	gallery = new Sprite();
	addChild(gallery);

	for(var i:int = 0; i &lt; photos.length; i++){

		var thumb:Thumb = new Thumb();
		thumb.scaleX = thumb.scaleY = .5;

		thumb.x = (thumb.width + 5) * i;
		thumb.title =  xml.photo[i].@title;

		var bm:Bitmap = new Bitmap();
		bm = Bitmap(photos[i].content);
		bm.smoothing = true;
		thumb.photo.addChild(bm);

		gallery.addChild(thumb);
		TweenLite.from(thumb, .5, {scaleX:0,scaleY:0,alpha:0, delay: i*0.2, onComplete:addThumbListeners,onCompleteParams:[thumb]});

	}
	gallery.x = stage.stageWidth/2 - gallery.width/2;
	gallery.y = stage.stageHeight/2 - gallery.height/2;

}
</pre>
<p><em>11.</em> Once the thumbs are fully created, we add to them &#8220;MouseEvent.ROLL_OVER&#8221; and &#8220;MouseEvent.ROLL_OUT&#8221; listeners.</p>
<pre class="brush: jscript;">
function addThumbListeners(thumb:MovieClip):void{
	thumb.addEventListener(MouseEvent.ROLL_OVER, onThumbOver);
	thumb.addEventListener(MouseEvent.ROLL_OUT, onThumbOut);
}
</pre>
<p><em>12.</em> The onThumbOver() function scales up the hovered thumb. We add an onUpdate listener that calls the arrangeThumb() function when this event is triggered. It also tints the photo&#8217;s frame to black.<br />
Inside the arrangeThumb() function we place the hovered photo above the other when its scale is superior to .6<br />
When its scale is equal to 1, we set the currentPhoto text to the hovered photo title.</p>
<pre class="brush: jscript;">
function onThumbOver(evt:MouseEvent):void {
	var thumb:MovieClip = MovieClip(evt.target);
	TweenLite.to(thumb,.5,{scaleX:1,scaleY:1,onUpdate:arrangeThumb, onUpdateParams:[thumb]});
	TweenLite.to (thumb.bg, .5, {tint: 0x000000});
}

function arrangeThumb(thumb:MovieClip):void{
	if (thumb.scaleX&gt;.6)
		gallery.addChild(thumb);
	if(thumb.scaleX==1)
		currentPhoto.text = thumb.title;
}
</pre>
<p><em>13.</em> The onThumbOut() function scales down the thumb, tints it back to its grey color and set the currentPhoto text to blank.</p>
<pre class="brush: jscript;">
function onThumbOut(evt:MouseEvent):void {
	var thumb:MovieClip = MovieClip(evt.target);
	TweenLite.to(thumb,.5,{scaleX:.5, scaleY:.5});
	TweenLite.to (thumb.bg, .5, {tint: 0x999999});
	currentPhoto.text = &quot;&quot;;
}
</pre>
<p><em></em>Finally don&#8217;t forget to call the loadXML() function to make it work.</p>
<pre class="brush: jscript;">
loadXML(&quot;gallery.xml&quot;);
</pre>
<p><em></em>Here&#8217;s the final code.</p>
<pre class="brush: jscript;">
import com.greensock.TweenLite;
import com.greensock.plugins.*;
TweenPlugin.activate([TintPlugin]);

var xml:XML;
var photos:Array;
var totalPhotos:Number;
var folder:String = &quot;photos/&quot;;
var gallery:Sprite;
var photosLoaded:int=0;

function loadXML(file:String):void{
	var xmlLoader:URLLoader = new URLLoader();
	xmlLoader.load(new URLRequest(file));
	xmlLoader.addEventListener(Event.COMPLETE, parseXML);
}

function parseXML(e:Event):void{
	xml = new XML(e.target.data);
	totalPhotos = xml.children().length();
	loadGallery();
}

function loadGallery():void{
	photos = new Array();
	for(var i:int = 0; i&lt;totalPhotos; i++){
		var loader:Loader = new Loader();
		loader.load(new URLRequest(folder + xml.photo[i].@src));
		photos.push(loader);
		loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onComplete);
	}
}

function onComplete(e:Event):void{
	photosLoaded++;
	if(photosLoaded == totalPhotos){
		createThumbs();
	}
}

function createThumbs():void{
	gallery = new Sprite();
	addChild(gallery);

	for(var i:int = 0; i &lt; photos.length; i++){

		var thumb:Thumb = new Thumb();
		thumb.scaleX = thumb.scaleY = .5;

		thumb.x = (thumb.width + 5) * i;
		thumb.title =  xml.photo[i].@title;

		var bm:Bitmap = new Bitmap();
		bm = Bitmap(photos[i].content);
		bm.smoothing = true;
		thumb.photo.addChild(bm);

		gallery.addChild(thumb);
		TweenLite.from(thumb, .5, {scaleX:0,scaleY:0,alpha:0, delay: i*0.2, onComplete:addThumbListeners,onCompleteParams:[thumb]});

	}
	gallery.x = stage.stageWidth/2 - gallery.width/2;
	gallery.y = stage.stageHeight/2 - gallery.height/2;

}

function addThumbListeners(thumb:MovieClip):void{
	thumb.addEventListener(MouseEvent.ROLL_OVER, onThumbOver);
	thumb.addEventListener(MouseEvent.ROLL_OUT, onThumbOut);
}

function onThumbOver(evt:MouseEvent):void {
	var thumb:MovieClip = MovieClip(evt.target);
	TweenLite.to(thumb,.5,{scaleX:1,scaleY:1,onUpdate:arrangeThumb, onUpdateParams:[thumb]});
	TweenLite.to (thumb.bg, .5, {tint: 0x000000});
}

function arrangeThumb(thumb:MovieClip):void{
	if (thumb.scaleX&gt;.6)
		gallery.addChild(thumb);
	if(thumb.scaleX==1)
		currentPhoto.text = thumb.title;
}

function onThumbOut(evt:MouseEvent):void {
	var thumb:MovieClip = MovieClip(evt.target);
	TweenLite.to(thumb,.5,{scaleX:.5, scaleY:.5});
	TweenLite.to (thumb.bg, .5, {tint: 0x999999});
	currentPhoto.text = &quot;&quot;;
}

loadXML(&quot;gallery.xml&quot;);
</pre>
<p>I hope you liked this tutorial and use this on your website. This codes would work best if you were able to choose the best and the <a href="http://www.webhostingsearch.com/cheap-web-hosting.php">cheapest webhosting</a> service that supports XML coding.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.riacodes.com/flash/horizontal-photo-gallery-with-hover-zoom-effect/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Flash Christmas Card</title>
		<link>http://www.riacodes.com/flash/flash-christmas-card/</link>
		<comments>http://www.riacodes.com/flash/flash-christmas-card/#comments</comments>
		<pubDate>Wed, 22 Dec 2010 11:19:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[Christmas]]></category>
		<category><![CDATA[special effect]]></category>
		<category><![CDATA[Tweenlite]]></category>

		<guid isPermaLink="false">http://www.riacodes.com/?p=1584</guid>
		<description><![CDATA[<img src="http://www.files.riacodes.com/flash_christmas-card/preview.jpg">]]></description>
			<content:encoded><![CDATA[<p>Create very easily a flash Christmas Card that you can open or close like a real one.<br />
<span id="more-1584"></span></p>
<div class="demosource"><a href="http://www.files.riacodes.com/flash_christmas-card/" target="_blank"><img src="http://www.riacodes.com/wp-content/themes/riacodes/images/icons/demo.png" alt="View Demo" /></a><a href="http://www.files.riacodes.com/flash_christmas-card/src.zip"><img src="http://www.riacodes.com/wp-content/themes/riacodes/images/icons/download.png" alt="Download Source" /></a></div>
<p><em>1.</em> Create a new flash file (Actionscript 3.0) and save it as card.fla. </p>
<p><em>2. </em> Our card will consist of 2 pages, the first will be the cover of the card and the 2nd the inner card where you write your wishes.<br />
To create the first page, import the image of your choice on the stage and convert it to a movie clip with registration point at the top left. Give it an instance name of &#8220;page1_mc&#8221;. Inside this movie clip, add a second frame and create a blank rectangle the same size of your image.</p>
<p><img src="http://www.files.riacodes.com/flash_christmas-card/1.jpg" alt="Screenshot"></p>
<p><em>3.</em> For the inner page, create a blank rectangle the same dimensions of your first page and with the Text tool write your wishes over it.<br />
Convert it to a movie clip.</p>
<p><em>4.</em> Place the first page and the inner page at the same x and y coordinates so that the first page covers the inner page. Select both first page and inner page Movie Clips and convert the selection to a movie clip with an instance name of &#8220;card_mc&#8221;.</p>
<p><img src="http://www.files.riacodes.com/flash_christmas-card/2.jpg" alt="Screenshot"></p>
<p><em>5.</em> At this point you shoud have on &#8220;Scene 1&#8243; a movie clip with an instance name of &#8220;card_mc&#8221; that contains the whole card.<br />
Create a new &#8220;actions&#8221; layer and open the actions panel.<br />
We&#8217;ll use Tweenlite so first import it.</p>
<pre class="brush: jscript;">
import com.greensock.*;
import com.greensock.easing.*;
</pre>
<p><em>6.</em> Declare a boolean variable to store whether the card is opened, call the stop() method for &#8220;page1_mc &#8221; and add a Click event listener.</p>
<pre class="brush: jscript;">
var opened :Boolean = false;
card_mc.page1_mc.stop();
card_mc.page1_mc.addEventListener(MouseEvent.CLICK,turnPage);
</pre>
<p><em>7.</em> In the turnPage() function, we check the value of our &#8220;opened&#8221; boolean variable.<br />
If it&#8217;s false we want to open the card. To do so, we animate &#8220;page1_mc&#8221; rotationY property to a value of 180.  We add an ENTER_FRAME event listener, event that will be handled by the openCard() function.  In the openCard() function, we check the value of the &#8220;page1_mc&#8221; rotationY property. If it&#8217;s superior to 90° which means the card is half opened, we stop &#8220;page1_mc&#8221; to frame 2. </p>
<p>To close the card we apply the same principles to reverse.</p>
<pre class="brush: jscript;">
function turnPage(e:MouseEvent):void{
	if(!opened){
		opened = true;
		addEventListener(Event.ENTER_FRAME, openCard);
		TweenLite.to(card_mc.page1_mc,2,{rotationY:180, ease:Strong.easeOut});
	}
	else{
		opened = false;
		addEventListener(Event.ENTER_FRAME, closeCard);
		TweenLite.to(card_mc.page1_mc,2,{rotationY:0, ease:Strong.easeOut});
	}
}

function openCard(e:Event):void{
	if(card_mc.page1_mc.rotationY &gt; 90){
		card_mc.page1_mc.gotoAndStop(2);
	}
}

function closeCard(e:Event):void{
	if(card_mc.page1_mc.rotationY &lt; 90){
		card_mc.page1_mc.gotoAndStop(1);
	}
}
</pre>
<p><em>8.</em> Finally to animate the card at the beginning, we add the following line.</p>
<pre class="brush: jscript;">
TweenLite.to(card_mc,4,{x:400, rotationZ:-5,  ease:Strong.easeInOut});
</pre>
<p>Here&#8217;s the final code, test your movie to see it in action.</p>
<pre class="brush: jscript;">
import com.greensock.*;
import com.greensock.easing.*;

var opened :Boolean = false;
card_mc.page1_mc.stop();
card_mc.page1_mc.addEventListener(MouseEvent.CLICK,turnPage);

TweenLite.to(card_mc,4,{x:400, rotationZ:-5,  ease:Strong.easeInOut});

function turnPage(e:MouseEvent):void{
	if(!opened){
		opened = true;
		addEventListener(Event.ENTER_FRAME, openCard);
		TweenLite.to(card_mc.page1_mc,2,{rotationY:180, ease:Strong.easeOut});
	}
	else{
		opened = false;
		addEventListener(Event.ENTER_FRAME, closeCard);
		TweenLite.to(card_mc.page1_mc,2,{rotationY:0, ease:Strong.easeOut});
	}
}

function openCard(e:Event):void{
	if(card_mc.page1_mc.rotationY &gt; 90){
		card_mc.page1_mc.gotoAndStop(2);
	}
}

function closeCard(e:Event):void{
	if(card_mc.page1_mc.rotationY &lt; 90){
		card_mc.page1_mc.gotoAndStop(1);
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.riacodes.com/flash/flash-christmas-card/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Image Appearance Effect : Fall Down</title>
		<link>http://www.riacodes.com/flash/image-appearance-effect-fall-down/</link>
		<comments>http://www.riacodes.com/flash/image-appearance-effect-fall-down/#comments</comments>
		<pubDate>Sun, 19 Sep 2010 15:14:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[special effect]]></category>
		<category><![CDATA[Tweenlite]]></category>

		<guid isPermaLink="false">http://www.riacodes.com/?p=1566</guid>
		<description><![CDATA[<img src="http://www.files.riacodes.com/flash_image-appearance-effect-fall-down/preview.jpg">]]></description>
			<content:encoded><![CDATA[<p>In this Image Appearance Effect tutorial, see how to reveal an image piece by piece with a fall down effect.<br />
<span id="more-1566"></span></p>
<div class="demosource"><a href="http://www.files.riacodes.com/flash_image-appearance-effect-fall-down/" target="_blank"><img src="http://www.riacodes.com/wp-content/themes/riacodes/images/icons/demo.png" alt="View Demo" /></a><a href="http://www.files.riacodes.com/flash_image-appearance-effect-fall-down/src.zip"><img src="http://www.riacodes.com/wp-content/themes/riacodes/images/icons/download.png" alt="Download Source" /></a></div>
<p><em>1.</em> Here&#8217;s the code to achieve the Fall Down effect.<br />
The code is the same as previous tutorials except for the highlighted lines.<br />
To make the image&#8217;s pieces appear horizontally, we loop through the rows and through the columns (instead of columns and rows).<br />
In the revealImage() function, we use the Tweenlite.from (instead of Tweenlite.to) method to animate the y property of each image&#8217;s piece.</p>
<pre class="brush: jscript; highlight: [20,22,52];">
import com.greensock.*;
import com.greensock.easing.*;

const COLUMNS:uint=5;
const ROWS:uint=5;

var imagesGrid : Array = new Array();    

var imageLoader:Loader = new Loader();
imageLoader.load(new URLRequest(&quot;image.jpg&quot;));
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded);

function onImageLoaded(e:Event):void {

	var originalBitmapData:BitmapData = e.target.content.bitmapData;

	var imageWidth : Number  = originalBitmapData.width / COLUMNS;
    var imageHeight : Number = originalBitmapData.height / ROWS;

	for (var i = 0; i &lt; ROWS; i++) {

		for (var j = 0; j &lt; COLUMNS; j++) {

			var imageHolder:MovieClip = new MovieClip();

			var image:Bitmap = new Bitmap();
			image.bitmapData=new BitmapData(imageWidth,imageHeight);
 			image.bitmapData.copyPixels(
								originalBitmapData,
			  					new Rectangle(j * imageWidth, i * imageHeight,imageWidth, imageHeight),
			  					new Point(0,0));

			imageHolder.addChild(image);

			imageHolder.x= j*imageWidth ;
			imageHolder.y= i*imageHeight ;

			imageHolder.alpha=0;

  			imagesGrid.push(imageHolder);
			addChild(imageHolder);

		}
	}
	revealImage();
}

function revealImage():void {
	for (var i:int = 0; i &lt;imagesGrid.length; i++){
		var imageGrid:MovieClip = imagesGrid[i] as MovieClip;
		imageGrid.alpha = 1;
		TweenLite.from(imageGrid,.8,{alpha:0,y:-200,delay:i*.1,ease:Back.easeOut});
	}
 }
</pre>
<p><em>2.</em> That&#8217;s it, test your movie to see it in action.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.riacodes.com/flash/image-appearance-effect-fall-down/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Image Appearance Effect : Random Vertical Rotation</title>
		<link>http://www.riacodes.com/flash/image-appearance-effect-random-vertical-rotation/</link>
		<comments>http://www.riacodes.com/flash/image-appearance-effect-random-vertical-rotation/#comments</comments>
		<pubDate>Tue, 14 Sep 2010 14:09:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[special effect]]></category>

		<guid isPermaLink="false">http://www.riacodes.com/?p=1541</guid>
		<description><![CDATA[<img src="http://www.files.riacodes.com/flash_image-appearance-effect-random-vertical-rotation/preview.jpg"/>]]></description>
			<content:encoded><![CDATA[<p>The following code is one of a serie of codes that we will publish on Image Appearance Effect. This one proposes to reveal an image piece by piece randomly, each piece appears by rotating vertically.<br />
<span id="more-1541"></span></p>
<div class="demosource"><a href="http://www.files.riacodes.com/flash_image-appearance-effect-random-vertical-rotation/" target="_blank"><img src="http://www.riacodes.com/wp-content/themes/riacodes/images/icons/demo.png" alt="View Demo" /></a><a href="http://www.files.riacodes.com/flash_image-appearance-effect-random-vertical-rotation/src.zip"><img src="http://www.riacodes.com/wp-content/themes/riacodes/images/icons/download.png" alt="Download Source" /></a></div>
<p><em>1.</em> To get started, go check our previous tutorial entitled <a href="http://www.riacodes.com/flash/move-the-mouse-to-reveal-the-poster/">&#8220;Move the Mouse to Reveal the Poster&#8221;</a>.</p>
<p><em>2.</em> With Flash CS4 or Flash CS5, create a new flash file (Actionscript 3.0).<br />
Open the actions panel.</p>
<p><em>3.</em> Paste the following code. It&#8217;s almost the same as the previous tutorial except for the highlighted lines.<br />
To make each piece of the image to appear randomly, we create a delayTime property and set it to a random value.<br />
In the revealImage() function, we loop through the imagesGrid array and for each piece use the Tweenlite engine to animate its alpha and rotationY property. We specify the delay parameter to the delayTime property that we&#8217;ve set before.</p>
<pre class="brush: jscript; highlight: [43,50,53,54,54,55,56,57,58];">
import com.greensock.*;

const COLUMNS:uint=8;
const ROWS:uint=4;

var imagesGrid : Array = new Array();    

var imageLoader:Loader = new Loader();
imageLoader.load(new URLRequest(&quot;img.jpg&quot;));
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded);

function onImageLoaded(e:Event):void {

	var originalBitmapData:BitmapData = e.target.content.bitmapData;

	var imageWidth : Number  = originalBitmapData.width / COLUMNS;
    var imageHeight : Number = originalBitmapData.height / ROWS;

	for (var i = 0; i &lt; COLUMNS; i++) {

		for (var j = 0; j &lt; ROWS; j++) {

			var imageHolder:MovieClip = new MovieClip();

			var image:Bitmap = new Bitmap();
			image.bitmapData=new BitmapData(imageWidth,imageHeight);
 			image.bitmapData.copyPixels(
								originalBitmapData,
			  					new Rectangle(i * imageWidth, j * imageHeight,imageWidth, imageHeight),
			  					new Point(0,0));

			image.smoothing = true;

			imageHolder.addChild(image);

			image.x = -imageWidth / 2;
			image.y = -imageHeight / 2;

			imageHolder.x= i*imageWidth + imageWidth/2;
			imageHolder.y= j*imageHeight + imageHeight/2;

			imageHolder.alpha=0;
			imageHolder.delaytime = Math.random();

  			imagesGrid.push(imageHolder);
			addChild(imageHolder);

		}
	}
	revealImage();
}

function revealImage():void {
	for (var i:int = 0; i &lt; imagesGrid.length; i++){
		var imageGrid:MovieClip = imagesGrid[i] as MovieClip;
		TweenLite.to(imageGrid,.5,{rotationY: -360,alpha:1,delay:imageGrid.delaytime});
	}
}
</pre>
<p><em>4.</em> That&#8217;s it, test your movie to see it in action.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.riacodes.com/flash/image-appearance-effect-random-vertical-rotation/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Move the Mouse to Reveal the Poster</title>
		<link>http://www.riacodes.com/flash/move-the-mouse-to-reveal-the-poster/</link>
		<comments>http://www.riacodes.com/flash/move-the-mouse-to-reveal-the-poster/#comments</comments>
		<pubDate>Mon, 06 Sep 2010 14:21:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[effect]]></category>
		<category><![CDATA[special effect]]></category>

		<guid isPermaLink="false">http://www.riacodes.com/?p=1522</guid>
		<description><![CDATA[<img src="http://www.files.riacodes.com/flash_reveal-poster-hover/preview.jpg"/>]]></description>
			<content:encoded><![CDATA[<p>In this tutorial, learn how to reveal a poster piece by piece when the user hovers it.<br />
<span id="more-1522"></span></p>
<div class="demosource"><a href="http://www.files.riacodes.com/flash_reveal-poster-hover/" target="_blank"><img src="http://www.riacodes.com/wp-content/themes/riacodes/images/icons/demo.png" alt="View Demo" /></a><a href="http://www.files.riacodes.com/flash_reveal-poster-hover/src.zip"><img src="http://www.riacodes.com/wp-content/themes/riacodes/images/icons/download.png" alt="Download Source" /></a></div>
<p><em>1.</em> This tutorial is a variation of our previous tutorial entitled <a href="http://www.riacodes.com/flash/revealing-an-image-with-a-grid-effect-animation/">&#8220;Revealing an Image with a Grid Effect Animation&#8221;</a>, so first go check it to get the main explanations as we&#8217;ll go quickly here.</p>
<p><em>2.</em> Create a new flash file (Actionscript 3.0) and set its dimensions to the dimensions of your poster.<br />
Open the actions panel.</p>
<p><em>3.</em> Paste the following code. It&#8217;s the same as the previous tutorial except for the highlighted lines. The difference here is the way we position the elements so that the tween scale animation on each piece will start from the center of the piece.<br />
Also we add a MOUSE_OVER event listener to each piece of the poster.</p>
<pre class="brush: jscript; highlight: [34,35,37,38,41];">
import com.greensock.*;

const COLUMNS:uint=10;
const ROWS:uint=10;

var imagesGrid : Array = new Array();    

var imageLoader:Loader = new Loader();
imageLoader.load(new URLRequest(&quot;theamerican.jpg&quot;));
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded);

function onImageLoaded(e:Event):void {

	var originalBitmapData:BitmapData = e.target.content.bitmapData;

	var imageWidth : Number  = originalBitmapData.width / COLUMNS;
    var imageHeight : Number = originalBitmapData.height / ROWS;

	for (var i = 0; i &lt; COLUMNS; i++) {

		for (var j = 0; j &lt; ROWS; j++) {

			var imageHolder:MovieClip = new MovieClip();

			var image:Bitmap = new Bitmap();
			image.bitmapData=new BitmapData(imageWidth,imageHeight);
 			image.bitmapData.copyPixels(
								originalBitmapData,
			  					new Rectangle(i * imageWidth, j * imageHeight,imageWidth, imageHeight),
			  					new Point(0,0));

			imageHolder.addChild(image);

			image.x = -imageWidth / 2;
			image.y = -imageHeight / 2;

			imageHolder.x= i*imageWidth + imageWidth/2;
			imageHolder.y= j*imageHeight + imageHeight/2;

			imageHolder.alpha=0;
			imageHolder.addEventListener(MouseEvent.MOUSE_OVER, overHandler);

  			imagesGrid.push(imageHolder);
			addChild(imageHolder);
		}
	}
}
</pre>
<p><em>4.</em> The overHandler() function gets the piece of the poster which has triggered the event and uses the Tweenlite engine to animate its alpha and scales properties. Then we prevent the piece that has been revealed from receiving mouse messages and remove its event listener.</p>
<pre class="brush: jscript;">
function overHandler(e:MouseEvent):void {
	var imageGrid = e.target as MovieClip;
 	imageGrid.scaleX = imageGrid.scaleY = 0;
 	TweenLite.to(imageGrid, .5, {alpha: 1,scaleX:1,scaleY:1});
 	imageGrid.mouseEnabled = false;
 	imageGrid.removeEventListener(MouseEvent.MOUSE_OVER, overHandler);
}
</pre>
<p><em>5.</em> Here&#8217;s the final code. Test your movie to see it in action.</p>
<pre class="brush: jscript;">
import com.greensock.*;

const COLUMNS:uint=10;
const ROWS:uint=10;

var imagesGrid : Array = new Array();    

var imageLoader:Loader = new Loader();
imageLoader.load(new URLRequest(&quot;theamerican.jpg&quot;));
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded);

function onImageLoaded(e:Event):void {

	var originalBitmapData:BitmapData = e.target.content.bitmapData;

	var imageWidth : Number  = originalBitmapData.width / COLUMNS;
    var imageHeight : Number = originalBitmapData.height / ROWS;

	for (var i = 0; i &lt; COLUMNS; i++) {

		for (var j = 0; j &lt; ROWS; j++) {

			var imageHolder:MovieClip = new MovieClip();

			var image:Bitmap = new Bitmap();
			image.bitmapData=new BitmapData(imageWidth,imageHeight);
 			image.bitmapData.copyPixels(
								originalBitmapData,
			  					new Rectangle(i * imageWidth, j * imageHeight,imageWidth, imageHeight),
			  					new Point(0,0));

			imageHolder.addChild(image);

			image.x = -imageWidth / 2;
			image.y = -imageHeight / 2;

			imageHolder.x= i*imageWidth + imageWidth/2;
			imageHolder.y= j*imageHeight + imageHeight/2;

			imageHolder.alpha=0;
			imageHolder.addEventListener(MouseEvent.MOUSE_OVER, overHandler);

  			imagesGrid.push(imageHolder);
			addChild(imageHolder);
		}
	}
}

function overHandler(e:MouseEvent):void {
	var imageGrid = e.target as MovieClip;
 	imageGrid.scaleX = imageGrid.scaleY = 0;
 	TweenLite.to(imageGrid, .5, {alpha: 1,scaleX:1,scaleY:1});
 	imageGrid.mouseEnabled = false;
 	imageGrid.removeEventListener(MouseEvent.MOUSE_OVER, overHandler);
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.riacodes.com/flash/move-the-mouse-to-reveal-the-poster/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
	</channel>
</rss>

