com.lookmum.util.ParallaxManager
The parallax manager utility class, manages the parallax movement of specified movieclips based on the mouse position relative to their parent movieclips.
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.
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.
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)
static public function addItem(target:MovieClip, frameWidth:Number, frameHeight:Number, vertical:Boolean, horizontal:Boolean):VoidRegister a movieclip with the manager
target | The movieclip to control |
frameWidth | The frame width in which the movieclip moves. Optional parameter, defaults to Stage.width |
frameHeight | The frame height in which the movieclip moves. Optional parameter, defaults to Stage.height |
vertical | Move the movie clip vertically. Optional parameter, defaults to true |
horizontal | Move the movie clip horizontally. Optional parameter, defaults to true |
static public function removeItem(target:MovieClip):VoidUnregister a movieclip from the manager
target | The target movieclip to no longer control |
static public function setMouseControl(mouseControl:Boolean):VoidTurn on/off mouse control for the parallax manager (true by default)
mouseControl | Sets the mouse position to control parallaxing. |
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.
x | Screen x coordinate in pixels |
y | Screen y coordinate in pixels |
static public function setFrameWidth(target:MovieClip, value:Number):VoidChange the frame width for a specified movieclip
target | The target movieclip to change the frame width for |
value | The new value of the frame width |
static public function setFrameHeight(target:MovieClip, value:Number):VoidChange the frame height for a specified movieclip
target | The target movieclip to change the frame height for |
value | The new value of the frame height |
static public function setVertical(target:MovieClip, value:Number):VoidSets the target to move vertically or not
target | The target movieclip to change vertical parallaxing for |
value | Sets the target to move vertically or not |
static public function setHorizontal(target:MovieClip, value:Number):VoidSets the target to move horizontally or not
target | The target movieclip to change horizontally parallaxing for |
value | Sets the target to move horizontally or not |
static public function setXOffset(target:MovieClip, value:Number):VoidSet the x coordinate with which to offset the specified movieclip from its calculated value
target | The target movieclip |
value | The amount in pixels by which to offset the targets x coordinate |
static public function setYOffset(target:MovieClip, value:Number):VoidSet the y coordinate with which to offset the specified movieclip from its calculated value
target | The target movieclip |
value | The amount in pixels by which to offset the targets y coordinate |