Hey, I was just wondering if there was any way I could change the origin of a movie clip using actionscript (so without actually moving the contents of the clip at authoring time). I just wanted to know because I have a virtual camera that I want to be able to rotate on the stage… it rotates from the center (it origin and anchor point), but when I set the stage to its rotation, the stage rotates from its (0,0) point… the top left hand corner… makeing a really weird and unwanted effect. I’ve tried to move the stage x and y manually using trig, but it’s complicated and I’ve have to do it 4 times (for every quadrant) and it doesn’t work.
In summary, is it possible to change the origin of the stage to its center, for the purposes of rotation using a virtual camera?
The AS for the virtual cam looks like this:
function camControl():Void {
parentColor.setTransform(camColor.getTransform());
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;
Any suggestions?