<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>SnippetRepoBrowser</title>
    <link>http://snippet.gnstudio.com/snippetrepobrowser/index</link>    
    <description>RSS Feed of SnippetRepoBrowser (Global RSS)</description>    
    <language>en-us</language>
    <pubDate>Thu, 09 Feb 2012 21:03:52 +0100</pubDate>
    <docs>SnippetRepoBrowser/index</docs>
    <generator>SnippetRepoBrowser Feed Generator</generator>
    <item>
      <title><![CDATA[Using 3D and Video with Caurina Tween in Flash Cs4]]></title>
      <link>http://snippet.gnstudio.com/viewtopic/1</link>
      <description><![CDATA[In this sample, full-commented, we&#39;ll use the FlashPlayer 10 3D features to display a list of Video Thumbnails enabling the Mouse Click Event to enlarge them changing their  z and rotationY properties.<br />We&#39;ll use <a href="http://code.google.com/p/tweener/" target="_blank">Caurina Tween</a> to perform 3d animations, so download them and copy the caurina package in your project folder before test this sample (they are not included inside the source files)<br />IMPORTANT NOTE: 3D topic is really complex! This is only an introduction to this world and this VideoGallery needs a lot of improvements to be used in a real scenario.<br /><a href="http://www.fabiobiondi.com/blog/wp-content/uploads/2009/08/_tweencaurina_3d_e_videoblogversion.swf" target="_blank">To this URL</a> the flash file with the <span style="font-weight:bold">final result </span>(click on VideoThumbs to display 3D animations):<br /><br /><span style="font-weight:bold"><br />CREATE THE FLASH FILE</span><br />First of all we create a new Flash ActionScript 3.0 document (setting Flash Player 10 in the Publish Setting menu).<br />Create a new MovieClip with an FLVPlayBack component inside (with istance name videoFLB) and link the movieclip to the VideoThumb.as class. <br /><span style="font-style:italic">See image below</span><br /><br /><img alt="" src="http://www.fabiobiondi.com/blog/wp-content/uploads/2009/08/flashtimelinecommented.gif" border="0" /><br />]]><![CDATA[<div class="divcode"><pre lang="actionscript">// FLASH DOCUMENT CLASS<br />package {<br /><br />	import flash.display.Sprite;<br />	import flash.display.StageAlign;<br />	import flash.display.StageScaleMode;<br />	import flash.events.MouseEvent;<br />	import caurina.transitions.*<br />	import flash.display.DisplayObject;<br />	<br />	public class VideoMain extends Sprite<br />	{<br />		<br />		// Horizontal Gap between Video Thumbs<br />		private const HORIZONTAL_GAP:uint = 50;<br />		<br />		// Total of VideoThumbs to show<br />		private const VIDEO_TOTAL:uint = 6;<br />		<br />		// Thumbnails original Y position<br />		private const Y_POS:uint = 125;<br /><br />		// Thumbnails original Z position<br />		private const Z_POS:uint = 550;<br />		<br />	<br />		<br />		public function VideoMain()<br />		{<br />			stage.align = StageAlign.TOP_LEFT;<br />			stage.scaleMode = StageScaleMode.NO_SCALE;<br />			<br />			<br />			// Create video thumbs<br />			for (var i:uint = 0; i &lt; VIDEO_TOTAL; i++) {<br />				<br />				// Create a new VideoThumb istance <br />				var thumb:VideoThumb = new VideoThumb();<br />				<br />				// Save original Index VideoThumb <br />				thumb.originalIndex = i;<br />				<br />				// Set Thumb Position (x, y, z)<br />				thumb.x = thumb.originalX = HORIZONTAL_GAP * i <br />				thumb.y = Y_POS<br />				thumb.z = Z_POS;<br />				<br />				// Set Thumb Rotation<br />				thumb.rotationY = -90;<br /><br />				thumb.addEventListener(MouseEvent.CLICK, onClick)<br />				thumb.buttonMode = true;<br />				<br />				addChild(thumb)<br />			}<br />		}<br />		<br />		<br /><br />		/**<br />		* Click Video MovieClip<br />		*/<br />		private function onClick(event:MouseEvent):void<br />		{<br />			// If clicked videoThumb is already opened<br />			if(event.currentTarget.isOpened) {<br />				<br />				// Back to the original position				<br />				Tweener.addTween(event.currentTarget, {<br />									   rotationY: -90 , <br />							 		   x: event.currentTarget.originalX,<br />									   y: Y_POS,<br />									   z: Z_POS,									   <br />									   time:0.5, <br />									   transition:&quot;easeInOutSine&quot;,<br />									   onComplete: event.currentTarget.videoFLB.stop()});<br />			<br /><br />				// Set depth to the original Position<br />				this.swapChildrenAt(getChildIndex(event.currentTarget as DisplayObject), event.currentTarget.originalIndex)<br />				<br />				<br />				<br />			} else {<br /><br />				// Enlarge Video and PLay it when animation is completed<br />				Tweener.addTween(event.currentTarget, {<br />							 		   rotationY: 0 , <br />							 		   x: 230,<br />									   y: 200,<br />									   z: 0,<br />									   rotationY: 0,<br />									   time:0.5, <br />									   transition:&quot;easeInOutSine&quot;,<br />									   onComplete: event.currentTarget.videoFLB.play()});<br /><br />				// Bring to Front				<br />				this.swapChildrenAt(event.currentTarget.originalIndex, this.numChildren -1 )<br />				<br />			}<br />			<br />			<br />			// Change isOpened Status (to always know if a thumb is opened ) <br />			event.currentTarget.isOpened = !event.currentTarget.isOpened;<br />			<br />		}<br />		<br />		<br />	}<br />}<br /><br /><br /><br /><br /><br />// VideoThumb.as Class<br />package {<br /><br /><br />	import flash.display.MovieClip;<br /><br />	<br />	public class VideoThumb extends MovieClip<br />	{<br />		<br />		private var _originalIndex:Number ;<br />		private var _originalX:Number ;<br />		private var _isOpened:Boolean = false;<br />		<br />		<br />		/**<br />		* Constructor<br />		*/<br />		public function VideoThumb(){}<br />		<br />		<br />		/**<br />		* Original Index position (usefull to know the Thumb depth)<br />		*/<br />		public function set originalIndex(val:Number):void {<br />			_originalIndex = val;			<br />		}<br />		<br />		public function get originalX():Number {<br />			return _originalX ;			<br />		}<br />		<br />		<br />		<br />		<br />		/**<br />		* Original x position (usefull to position Thumb to the original Position)<br />		*/<br />		public function set originalX(val:Number):void {<br />			_originalX = val;			<br />		}<br />		<br />		<br />		public function get originalIndex():Number {<br />			return _originalIndex ;			<br />		}<br />		<br />		<br />		<br />		<br />		/**<br />		* If the VideoThumb is opened or not<br />		*/<br />		public function set isOpened(val:Boolean):void {<br />			_isOpened = val;			<br />		}<br />				<br />		<br />		public function get isOpened():Boolean {<br />			return _isOpened ;			<br />		}<br />		<br />		<br />	}<br />}<br /><br /><br /></pre></div><br /><br />]]></description>
      <author>flagers</author>
      <pubDate>Mon, 31 Aug 2009 22:19:18 +0200</pubDate>
      <category>ActionScript</category>
      <guid>http://snippet.gnstudio.com/viewtopic/1</guid>
   </item>
  </channel>
</rss>
