CarousselOne

Package:
Class:
Inheritance:
biz.flashscript.animation
public class CarousselOne (Flash 10)
Sprite
The CarousselOne class is used to create image caroussels. The movement can be changed to waves and the view can be changed. To create an instance of the CarousselOne use the constructor new CarousselOne().

See also

   biz.flashscript.animation.CarousselTwo

Public Properties
Property Defined By
setAngleFactor : Number
To alter the movement to waves.
CarousselOne
changeYY : Boolean
Required to alter the setAngleFactor.
CarousselOne
setAlpha : Boolean
If true the scene will be dimmed.
CarousselOne
setRotation : Boolean
If true the objects will rotate according to their position inside the circle.
CarousselOne
Public Methods
Method Defined By
CarousselOne()
Creates a new instance of the CarousselOne class.
CarousselOne
setParams(container:Sprite, object_mc:MovieClip, objectArray:Array, numberOfObjects:int, objectArray:int, speedfactor:int, viewDist:int, xo:int, yo:int, xc:int, yc:int, zc:int, rad:int, angle:Number=1):void
Will initiate the tween when an instance of the CarousselOne class exists.
CarousselOne
changeTimer(count:int, angle:Number=1):void
Allows to change the speed for the circle to move and the angle in which the objects are oriented to each other.
CarousselOne
Events
Event Defined By
All inherited events for the Sprite class. N/A
Property Detail
setAngleFactor property
setAngleFactor:Number [read-write]

Changing the value will alter the movement. Increasing the value will cause the objects to jump while decreasing will cause the circle to move in a different angle. To use this the changeYY variable must be set to true.

The default value is 1.

Implementation

public function get setAngleFactor():Number
public function set setAngleFactor(value:Number):void

changeYY property
changeYY:Boolean [read-write]

When set to true the angle of the circle will be changed. The angle can be further changed by changing the setAngleFactor variable.

The default value is false.

Implementation

public function get changeYY():Boolean
public function set changeYY(value:Boolean):void

setAlpha property
setAlpha:Boolean [read-write]

If true all objects will behave reduced alpha.

The default value is false.

Implementation

public function get setAlpha():Boolean
public function set setAlpha(value:Boolean):void

setRotation property
setRotation:Boolean [read-write]

To cause objects to rotate by themselves according to the position in the circle set setRotation to true.

The default value is false.

Implementation

public function get setRotation():Boolean
public function set setRotation(value:Boolean):void
Constructor Detail
CarousselOne ()  Constructor
public function CarousselOne()
Intializes a new CarousselOne instance.
Method Detail

setParams()  method
public function setParams(container:Sprite, object_mc:MovieClip, objectArray:Array, numberOfObjects:int, objectArray:int, speedfactor:int, viewDist:int, xo:int, yo:int, xc:int, yc:int, zc:int, rad:int, angle:Number=1):void

This method will initiate the caroussel methods.

Parameters

  • container:Sprite ____ This is an optional container (Sprite), which is holding all the objects. Create it in the movie.
  • object_mc:MovieClip ____ The individual objects of the circle.
  • objectArray:Array ____ This array holds all the objects and is created in the movie. It can also be used to give each of the circle objects behavior.
  • numberOfObjects:int ____ Specifies to total number of objects.
  • speedfactor:int ____ Specifies to speed with which the objects circle.
  • viewDist:int ____ Specifies viewer's distance to the circle.
  • xo:int ____ Specifies x position of the circle.
  • numberOfObjects:int ____ Specifies to total number of objects.
  • yo:int ____ Specifies y position of the circle.
  • zc:int ____ Specifies the z axis of the circle. A high value will let the circie appear smaller in a wide distance.
  • rad:int ____ Specifies the radius of the circle.
  • angle:Number ____ (Optional) Specifies the angle of the objects in relation to each other. The default value is 1.

changeTimer()  method
public function changeTimer(count:int, angle:Number):void

This method will initiate the caroussel methods. To change certain properties add the property before the method call:

Parameters

  • count:int ____ Specifies the delay count for a Timer object and allows to change the speed of the circle movement.
  • angle:Number ____ (Optional) Specifies the angle of the objects in relation to each other. The default value is 1. This function allows to change the angle when the movie is running.
Examples
Create a new fla file with the dimensions of 700x500 pixels and name it CarousselOne.fla. Place the fla in the same folder as the biz folder. Create a MovieClip Models and export for actionscript. Add 9 frames to the MovieClip and keep the first frame empty. Place a stop(); in the first frame. Then place an object (image for example) into each frame. Create a background, give it the identifier "BackImage" and export for actionscript. Then create an Actionscript file, name it Carousselone.as and place this script. Create a folder named "images" and place the original-sized images in.
package 
{
	import flash.display.Sprite;
	import flash.display.Loader;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.net.URLRequest;
	import biz.flashscript.animation.CarousselOne;
	import biz.flashscript.animation.MirrorImage;
	import biz.flashscript.utils.LoaderClassStatic;
	import biz.flashscript.tweens.ApplyTweensTimer;
	import biz.flashscript.filters.DropShadow;

	public class Carousselone extends Sprite
	{
		private var mfArray:Vector.<CarousselOne> = new Vector.<CarousselOne&lgt;();
		private var at:ApplyTweensTimer;
		private var viewDist:int = 500;
		private var xo:int = stage.stageWidth / 2;
		private var yo:int = 0;
		private var xc:int = -50;
		private var yc:int = -200;
		private var zc:int = 150;
		private var rad:int = 500;
		private var angle:Number = 1;
		private var numberOfObjects:int = 8;
		private var speedfactor:Number = 10;
		private var _objectArray:Array = new Array();
		private var container:Sprite;
		private var myLoader:Loader;
		
		public function Carousselone ():void
		{
			var bg:BackImage=new BackImage();
			addChild (bg);

			container = new Sprite();
			addChild (container);
			container.x = 0;
			container.y = 0;

			for (var i:int = 0; i < numberOfObjects; i++)
			{
				var imageHolder:Models=new Models();
				imageHolder.i = i;
				imageHolder.gotoAndStop (i+2);
				imageHolder.buttonMode = true;
				_objectArray.push ( imageHolder );
				var mi:MirrorImage = new MirrorImage();
				imageHolder.addChild (mi);
				mi.setBitmap (imageHolder, 0.5, -150, 25);
				container.addChild (imageHolder);
				var mf:CarousselOne = new CarousselOne();
				//mf.changeYY=true;
				//mf.setAngleFactor=5;
				mf.setParams (container, imageHolder, _objectArray, numberOfObjects, speedfactor, viewDist, xo, yo, xc, yc, zc, rad, angle);
				//mf.setRotation = true;
				//mf.setAlpha = true;
				mfArray.push (mf);
			}

			for (var j=0; j<_objectArray.length; j++)
			{
				container.getChildAt(j).addEventListener (MouseEvent.MOUSE_OVER, mo);
				container.getChildAt(j).addEventListener (MouseEvent.MOUSE_OUT, mu);
				container.getChildAt(j).addEventListener (MouseEvent.CLICK, cl);
			}

			var loaderMH:Sprite=new Sprite();
			loaderMH.buttonMode = true;
			addChild (loaderMH);
			myLoader = new Loader();
			loaderMH.addChild (myLoader);
			loaderMH.x = 190;
			loaderMH.y = 40;
			
			var myShadow:DropShadow = new DropShadow(loaderMH);
		}
		private function mo (e:MouseEvent):void
		{
			for (var j=0; j < mfArray.length; j++)
			{
				mfArray[j].changeTimer (0, 100);
			}
		}
		private function mu (e:MouseEvent):void
		{
			for (var j=0; j < mfArray.length; j++)
			{
				mfArray[j].changeTimer (2, 50);
			}
		}
		private function cl (e:MouseEvent):void
		{
			myLoader.addEventListener (MouseEvent.CLICK, lcl);
			if (myLoader.width != 0)
			{
				myLoader.unload ();
			}
			var url:String = "images/A" + (e.currentTarget.i) + ".jpg";
			myLoader.load (new URLRequest(url));
			myLoader.contentLoaderInfo.addEventListener (Event.COMPLETE, comHandler);
		}
		private function lcl (event:MouseEvent):void
		{
			if (myLoader.width != 0)
			{
				at = new ApplyTweensTimer(event.currentTarget.content.parent, 75, "alphaOut", 10, 1000);
				at.initTweens ();
				at.addEventListener (ApplyTweensTimer.CALL_BACK,  callHandler);
				function callHandler (event:Event):void
				{
					myLoader.unload ();
				}
			}
		}
		private function comHandler (event:Event):void
		{
			at = new ApplyTweensTimer(event.currentTarget.content.parent, 75, "alphaIn", 1, 1000);
			at.initTweens ();
		}
	}
}