I’m currently working in Flash 8 with Actionscript 2.0.
I’ve been trying different alternatives and none of them are working. I’ve even posted here previously and tried a few things but I haven’t quite resolved my centering to stage problem. Some of you may have already read pieces of this from another post.
I have a landscape that functions sort of like a 360 vr tour. The main movie clip directly on the stage is labeled, “mainMovie”, and within it is another movieclip labeled, “singleStrip”.
To simulate the 360 vr tour, there’s script inside, “mainMovie” to duplicate “singleStrip”. Also, inside the “singleStrip” movie clip, I have different elements appearing through the landscape, in this case, we’ll use letters as an example. The letters A - Z are sitting on the landscape throughout the entire “singleStrip” movie clip.
Everything rotates fine with the script that’s placed some sensitive area movie clips that are placed on the root level. When you place your mouse pointer to the left edge of the stage, the landscape shifts left, when you move the mouse pointer to the right edge, the landscape shifts right, (or vice versa, I can’t remember).
The problem I’m having is for the letters that are in view on the stage, I want the user to be able to “click” on them and then that letter zoom up to the center of the stage, (through the “x” coordinate). I’m having difficulty with this since the letter movieclips, (example, “letterA”), are within the “singleStrip” movie clip, which sits inside the “mainMovie” movie clip, which are both constantly moving and their x position continues to change.
I’ve been using the tween class in order to animate them with easing and it’s usually the “endx” variable that I’m having trouble because I don’t know how I can match it up to the center of the stage, whether it’s a "endx = stage.width._x /2; " or something else. Here’s an example of some of the code.
function tweenLetterA() {
easeType = mx.transitions.easing.Regular.easeOut;
var beginx = 74;
var beginy = 93;
var endx = stage.width._x / 2;
var endy = 81;
var time = .75;
var mc = letterA;
var begin_xscale = 40;
var begin_yscale = 40;
var end_xscale = 100;
var end_yscale = 100;
letterATween = new mx.transitions.Tween(mc, “_x”, easeType, beginx, endx, time, true);
letterATween = new mx.transitions.Tween(mc, “_y”, easeType, beginy, endy, time, true);
letterATween = new mx.transitions.Tween(mc, “_xscale”, easeType, begin_xscale, end_xscale, time, true);
letterATween = new mx.transitions.Tween(mc, “_yscale”, easeType, begin_yscale, end_yscale, time, true);
}
I’ve even tried to add tweening to the “mainMovie” movie clip on the root level, to place it at a specific “x” coordinate, while the “letterA” movie clip I only scale the size and shift it down on the “y” axis, to make it appear like it’s centering in accordance to the placement of “mainMovie” movie clip’s “x” coordinate. This has functioned partially where if I scroll left, I have no problem with the “mainMovie” movie clip positioning to where I want it, and the inside movie clip “letterA” shifting down to give the illusion that it’s being centered to stage.
However, if I scroll right instead of left and then “click” on a letter, then the entire landscape scrolls through one full turn before landing on the letter. I’m sure it has a lot to do with the fact that both the “mainMovie” movie clip and the internal movie clip, “singleStrip” continually change x position in order to have the 360 vr tour work.
Here’s my code for tweening the “mainMovie” clip.
easeType = mx.transitions.easing.Regular.easeOut;
var beginx = _root.mainMovie._x;
var beginy = _root.mainMovie._y;
var endx = 324;
var endy = 257;
var time = .75;
var mc = _root.mainMovie;
var begin_xscale = 100;
var begin_yscale = 100;
var end_xscale = 100;
var end_yscale = 100;
mainMovieTween = new mx.transitions.Tween(mc, "_x", easeType, beginx, endx, time, true);
mainMovieTween = new mx.transitions.Tween(mc, "_y", easeType, beginy, endy, time, true);
mainMovieTweenn = new mx.transitions.Tween(mc, "_xscale", easeType, begin_xscale, end_xscale, time, true);
mainMovieTween = new mx.transitions.Tween(mc, "_yscale", easeType, begin_yscale, end_yscale, time, true);
… And that’s kind of where I am now. I’m thinking there’s got to be an easier way to pull this off, perhaps even if I add a variable that knows what the center of the stage is and my letters nested within 2 movie clips can appear in the center. I’m just not that experienced with my actionscript.
How can I do this… ?
Also including the file for anyone interested in looking at it.
Thanks for any help you might be able to provide.