At 11/28/07 08:43 PM, PicoZX wrote:
function camControl():Void {
parentColor.setTransform(camColor.getTra nsform());
var scaleX:Number = sX/this._width;
var scaleY:Number = sY/this._height;
_parent._x = cX-(this._x*scaleX);
_parent._y = cY-(this._y*scaleY);
_parent._xscale = 100*scaleX;
_parent._yscale = 100*scaleY;
}
function resetStage():Void {
var resetTrans:Object = {ra:100, rb:0, ga:100, gb:0, ba:100, bb:0, aa:100, ab:0};
parentColor.setTransform(resetTrans);
_parent._xscale = 100;
_parent._yscale = 100;
_parent._x = 0;
_parent._y = 0;
}
// make frame invisible
this._visible = false;
// Capture stage parameters
var oldMode:String = Stage.scaleMode;
Stage.scaleMode = "exactFit";
var cX:Number = Stage.width/2;
var cY:Number = Stage.height/2;
var sX:Number = Stage.width;
var sY:Number = Stage.height;
Stage.scaleMode = oldMode;
// create color instances for color
// transforms (if any).
var camColor:Color = new Color(this);
var parentColor:Color = new Color(_parent);
// Make the stage move so that the
// v-cam is centered on the
// viewport every frame
this.onEnterFrame = camControl;
// Make an explicit call to the camControl
// function to make sure it also runs on the
// first frame.
camControl();
// If the v-cam is ever removed (unloaded)
// the stage, return the stage to the default
// settings.
this.onUnload = resetStage;
This might work.
Make a symbol, then put this.
Ahh, well here's my V-Cam:
/*<Note:> All terms and phrases will be explained at the end of this code*/
import flash.geom.Matrix; //Import the flash Matrix class <NOTE:>This is the location if you are using Flash Proffesional 8: My Computer> Local Disk(C:)> Program Files> Macromedia> Flash 8> en> First Run> Classes> FP8> flash> Geom> Matrix
import flash.geom.Transform; //Import the flash Transform class <NOTE:>This is the location if you are using Flash Proffesional 8: My Computer> Local Disk(C:)> Program Files> Macromedia> Flash 8> en> First Run> Classes> FP8> flash> Geom> Transform
import flash.geom.ColorTransform; //Import the flash ColorTransform class <NOTE:>This is the location if you are using Flash Proffesional 8: My Computer> Local Disk(C:)> Program Files> Macromedia> Flash 8> en> First Run> Classes> FP8> flash> Geom> ColorTransform
var animator = new Transform(this); //We create a new variable called "animator". With "animator" we state that its tranformation is equal to "this", the camera MC
var camera = new Transform(this._parent); //We create a new variable called "camera". With "camera" we state that its color tranformation is equal to "this._parent", the _root stage, which is everything on that frame
var camColor = new Color(this); //We create a new variable that will get all of the color effects applied to the camera
var parentColor = new Color(this._parent); //We create a new variable that will get the color effects of the _root timeline
var Width = Stage.width; //We create a varable called "Width" which is equal to the stage's total width
var Height = Stage.height; //We create a variable called "Height" which is equal to the stage's total height
this._visible = false; //Makes the camera MC invisible
function setCamera() { //We create and define the function "setCamera"
this._parent.filters = this.filters; //The filter that is put on the camera MC (EG. the blur filter) will now effect everything on the stage
parentColor.setTransform(camColor.getTra nsform()); //We apply te color effects used on the camera to every object that's on the stage
var stageMatrix = animator.matrix; //We create a new variable called "stageMatrix", which is equal to our variable "animaotr"'s matrix
camera.ColorTransform = animator.ColorTransform; //our variable "camera"'s ColorTransform is equal to our varialbe "animator"'s ColorTransform
stageMatrix.invert(); //We call upon the invert() method and apply it to our variable "stageMatrix"
stageMatrix.translate(Width * 0.5, Height * 0.5); //We call upon the translate() method and apply it to our variable "stageMatrix". Within our translate() method our X factor is Width * 0.5 (half of our stage width) and our Y factor is Height * 0.5 (half of our stage height)
camera.matrix = stageMatrix; //our variable "camera"'s matrix is equal to our variable "stageMatrix"
}
function stageRestore() { //We create and define the function "stageRestore"
_root._xscale = 100; //Our _root timeline's _xscale is set back to its original size
_root._yscale = 100; //Our _root timeline's _yscale is set back to its original size
_root._x = Stage.width / 2; //Our _root timeline's X position is set back to the centre of the stage
_root._y = Stage.height / 2; //Our _root timeline's Y position is set back to the centre of the stage
}
this.onEnterFrame = setCamera; //We call upon the "setCamera" function is called every frame
this.unload = stageRestore; //If the camera is ever removed, then it will restore the stage back the way it originally was by using the "stageRestore" function
/*Terms And Phrases:
Matrix: A transformation matrix that determines how to map points from one coordinate space to another
Transform: The Transform class collects data about color transformations and coordinate manipulations that are applied to a MovieClip object
ColorTransform: The ColorTransform class lets you mathematically adjust all of the color values in a movie clip
filters: An indexed array containing each filter object currently associated with the movie clip
invert: Performs the opposite transformation of the original matrix
translate: Modifies a Matrix object so that the effect of its transformation is to move an object along the x and y axes
matrix: An array of 20 elements for 4 x 5 color transform
<NOTE:> All of these definitions were copied from Flash's Help Menu*/
P.S. Code is commented, also this V-Cam accepts rotation and all kinds of effects ;)
And to archont, thx! ill try the code out and hope it works! :)
P.S. how do u get that actionscript code box thingy? thx alot for sum help :)