Class com.lookmum.util.ParallaxManager

com.lookmum.util.ParallaxManager

Description

The parallax manager utility class, manages the parallax movement of specified movieclips based on the mouse position relative to their parent movieclips.

How to use the extension:

Install the extension and you'll find the parallax manager component in your components panel.

Drag an instance to the stage of your movie then delete it so you have a copy in your library.

If you are using actionscript 2 then you'll also need to place a copy of the intrinsic class files included with the extension in your classpath in order to compile.

Usage:

You can use the class to create parallax effects in two main ways. The first is to create your movieclips at the actual size you want them to be contolled as, so if for instance you have a small movieclip that you want to move around in the middle of the creen, you would edit the movieclip to contain a large invisible square, with the object in the centre.

Alternatively you can leave the movieclip as it is, and by manipulating the xOffset, yOffset, width, and height properties of the manager for that movieclip you can achieve the same effect.

Code example:

import com.lookmum.util.ParallaxManager
 
 var mc1:MovieClip = containerClip.mc1
 var mc2:MovieClip = containerClip.mc2
 
 ParallaxManager.addItem(mc1,300,200)
 ParallaxManager.addItem(mc2,300,200)

Method Index

addItem(), removeItem(), setFrameHeight(), setFrameWidth(), setHeight(), setHorizontal(), setMouseControl(), setValue(), setVertical(), setWidth(), setXOffset(), setYOffset()

Method Detail

addItem

static public function addItem(target:MovieClip, frameWidth:Number, frameHeight:Number, vertical:Boolean, horizontal:Boolean):Void

Register a movieclip with the manager

Parameters

targetThe movieclip to control
frameWidthThe frame width in which the movieclip moves. Optional parameter, defaults to Stage.width
frameHeightThe frame height in which the movieclip moves. Optional parameter, defaults to Stage.height
verticalMove the movie clip vertically. Optional parameter, defaults to true
horizontalMove the movie clip horizontally. Optional parameter, defaults to true

removeItem

static public function removeItem(target:MovieClip):Void

Unregister a movieclip from the manager

Parameters

targetThe target movieclip to no longer control

setMouseControl

static public function setMouseControl(mouseControl:Boolean):Void

Turn on/off mouse control for the parallax manager (true by default)

Parameters

mouseControlSets the mouse position to control parallaxing.

setValue

static public function setValue(x:Number, y:Number):Void

Allows you to manually set a coordinate to control parallaxing, so that you can control parallaxing numerically without the mouse.

This is a global value, and unlike with mouse control, not relative to each controlled movieclip's parent movieclip. This means if your controlled clips are in differently placed containers, you may get strange results.

Parameters

xScreen x coordinate in pixels
yScreen y coordinate in pixels

setFrameWidth

static public function setFrameWidth(target:MovieClip, value:Number):Void

Change the frame width for a specified movieclip

Parameters

targetThe target movieclip to change the frame width for
valueThe new value of the frame width

setFrameHeight

static public function setFrameHeight(target:MovieClip, value:Number):Void

Change the frame height for a specified movieclip

Parameters

targetThe target movieclip to change the frame height for
valueThe new value of the frame height

setVertical

static public function setVertical(target:MovieClip, value:Number):Void

Sets the target to move vertically or not

Parameters

targetThe target movieclip to change vertical parallaxing for
valueSets the target to move vertically or not

setHorizontal

static public function setHorizontal(target:MovieClip, value:Number):Void

Sets the target to move horizontally or not

Parameters

targetThe target movieclip to change horizontally parallaxing for
valueSets the target to move horizontally or not

setXOffset

static public function setXOffset(target:MovieClip, value:Number):Void

Set the x coordinate with which to offset the specified movieclip from its calculated value

Parameters

targetThe target movieclip
valueThe amount in pixels by which to offset the targets x coordinate

setYOffset

static public function setYOffset(target:MovieClip, value:Number):Void

Set the y coordinate with which to offset the specified movieclip from its calculated value

Parameters

targetThe target movieclip
valueThe amount in pixels by which to offset the targets y coordinate

setWidth

static public function setWidth(target:MovieClip, value:Number):Void

Sets a value to override the physical width of the target movieclip when calculating the parallax

Parameters

targetThe target movieclip
valueThe new value for the target width in pixels

setHeight

static public function setHeight(target:MovieClip, value:Number):Void

Sets a value to override the physical height of the target movieclip when calculating the parallax

Parameters

targetThe target movieclip
valueThe new value for the target height in pixels