Tampering with the stage is a way to get in trouble. I discourage you from that.
It is better transform MovieClip object with the scene only. Either to transform object with entire loaded file (this in file’s main line frame script or _root.ptr from loader’s POV) or better only transform the object with animation itself, so it doesn’t affect buttons/controls of the animation.
You don’t need to use Transform class (which is for color transformation anyway) or Matrix class, you can access/change MovieClip type object offset and scale properties directly.
For example if the script is in the object you are transforming, properties are:
this._x //offset in pixels
this._y
this._xscale //scale in percents
this._yscale
By default the _root.ptr node where the file is mounted on has zero offset and 100% scale. However scene loader doesn’t reset these properties on next file load (unless you go through loader menu where _root.ptr object is deleted and recreated. To avoid mounting point properties carry over from one scene to another, update hth_beta.swf loader script in frame 2 with following code:
stop();
Mouse.show();
var file_path = "data/" + _root.filename;
if(_root.filename == "none" || _root.filename == undefined)
{
gotoAndStop("loadmenu");
}
else
{
var sceneListener = new Object();
sceneListener.onLoadError = function(target_mc, errorCode)
{
var _loc3_ = createTextField("emsg",getNextHighestDepth(),100,100,600,40);
_loc3_.text = "Error loading file " + file_path + "\nErrorCode " + errorCode;
var _loc4_ = new TextFormat();
_loc4_.bold = true;
_loc4_.font = "Arial";
_loc4_.color = 16777215;
_loc4_.leftMargin = 5;
_loc3_.setTextFormat(_loc4_);
};
var scene_mcl = new MovieClipLoader();
scene_mcl.addListener(sceneListener);
if(emsg != undefined)
{
emsg.removeTextField();
}
this.ptr.removeMovieClip();
this.createEmptyMovieClip("ptr",2);
scene_mcl.loadClip(file_path,"ptr");
nextFrame();
}
There is already similar code.
Mounting point object is deleted and recreated here. (also fixes bug not printing error on file load fail)
You can use the same fluent camera move that I’ve added to many scenes in HTH Offline where I’ve replaced control buttons.
Lets the scene have to main MovieClip class objects:
this.scene in layer 1 where the background and animation are.
this.controller where all buttons are.
Inside the controller a zoom button is: this.controller.zoom_btn
Now lets create a script for main scene object to automatically follow scale and offset in command variables.
First declare command variables (note that this[/] inside function refers to scene object)
scene.onLoad = function()
{
this.cmd_x = 0;
this.cmd_y = 0;
this.cmd_s = 100;
}[/]
And then each frame check these variables to current offset/scale and if it differs, move half distance from current position to commanded position. Except when the difference is less than 1 pixel (or 1% of scale), then go to the final offset because iterative halving is an infinite row.
scene.onEnterFrame = function()
{
var difference = this.cmd_x - this._x; // check difference into local variable
if(difference != 0)
{
if(difference > -1 && difference < 1) // difference is too small, go final
{
this._x = this.cmd_x;
}
else
{
difference = difference / 2; // go half way
this._x = this._x + difference;
}
}
difference = this.cmd_y - this._y; // the same for vertical offset
if(difference != 0)
{
if(difference > -1 && difference < 1)
{
this._y = this.cmd_y;
}
else
{
difference = difference / 2;
this._y = this._y + difference;
}
}
difference = this.cmd_s - this._xscale; // the same for scale, assuming you want to keep aspect ratio, _xscale = _yscale
if(difference_ != 0)
{
if(difference > -1 && difference < 1)
{
this._xscale = this.cmd_s;
this._yscale = this.cmd_s;
}
else
{
difference = difference / 2;
this._xscale = this._xscale + difference;
this._yscale = this._xscale;
}
}
}
Now create scripts for control button going through 3 camera view steps sequentially, one on each click
controller.camera = 1; // declaring camera step tracking variable (not using "var" as it's not a local temporary variable
controller.zoom_btn.onRelease = function() // script for button click
{
if(this._parent.camera == 1) // camera is currently in the first view, go to next
{
this._parent.camera = 2;
this._parent._parent.scene.cmd_x = -103; // move scene left by 103 pixels
this._parent._parent.scene.cmd_y = -80;
this._parent._parent.scene.cmd_s = 125; // +25% zoom
}
else if(this._parent.camera == 2)
{
this._parent.camera = 3;
this._parent._parent.scene.cmd_x = -150;
this._parent._parent.scene.cmd_y = -100;
this._parent._parent.scene.cmd_s = 200;
}
else if(this._parent.camera == 3) // camera is in the last step, go back to the first
{
this._parent.camera = 1;
this._parent._parent.scene.cmd_x = 0;
this._parent._parent.scene.cmd_y = 0;
this._parent._parent.scene.cmd_s = 100;
}
};
Of course you have to replace references to actual object paths in your file.
To find the right offset is just to iteratively try numbers until you find the best one.