Center Obj SWF within larger Flash Container

Using Pano2VR/Object2VR SWF files with your own Flash projects
Post Reply
Plastic3D
Posts: 2
Joined: Fri Jul 23, 2010 2:35 am

Here is my first post here, in a little deadline panic.

Having a lot of trouble centering a 200x200 .swf within a 400x400 .fla file. It renders just fine using the script from the api page, but it always snaps to upper left corner, no matter what settings I use for "setWindowPos"

Using CS5, AS3 script from API posted on the Garden Gnome wiki.

Code: Select all

function initObj(e:Event) {
// check if the panorama object is available and initialize it
	if ((vr!=null) && (vr.obj!=null)) {
		removeEventListener( Event.ENTER_FRAME , initObj);
		vr.obj.setWindowSize(400,400); // resize the window
		vr.obj.setWindowPos(200,200); // reposition
I have tried to use alternate positioning code from the AS2 script, but

Code: Select all

// Set the dimensions and position of the pano
  vr.window_width=500;
  vr.window_height=380;
  vr.window_x=100;
  vr.window_y=10;
};
...does not work with AS3 apparently. What to do?!!?

I *have* successfully made the SWF to center within Flash within AS2, however the motion of the object SWF is chunky, resets oddly at random times, and the movie will only orbit when the mouse cursor is within the movie (forcing the user to click-pan-click-pan to rotate the model - not an ideal situation).

With AS3, the mouse can exit the frame and still orbit the movie, which is very nice.

Does anyone have any ideas? Are there tricks using skins? I tried to make a 400x400 skin, but that didn't seem to make a difference when bringing the swf into Flash CS5.

Also I'm having problems doing this in CS3. I have also tried to put the object SWF within a folder in Flash, and tried to move that new folder around, using align tool, center tool for example.

Thanks for any help!!
Plastic3D
Posts: 2
Joined: Fri Jul 23, 2010 2:35 am

I figured it out: it's all about making a movie clip symbol, applying the code to that symbol, and then dragging it onto a layer your stage. The symbol can be moved around that way.

Apparently in my case with AS3 code, the "vr.pano.SetWindowPos " code doesn't affect the location at all.
Noisy
Posts: 35
Joined: Wed Apr 04, 2007 12:49 am
Location: Scotland

Hi

Sorry this is slow, not been on here for a while. so way past your deadline, glad you got a fix!


If I'm right in following your solution, you are loading the pano into the movieclip and moving the clip to suit the width of the pano?
what if you want to load a different size pano?

try (after load of the swf so that the width is known)
yourPano.x = YourPano.stage.stageWidth/2 - yourPano.width/2;

or tell it before load what the width is going to be

var panWidth:int = 400;
yourPano.x = YourPano.stage.stageWidth/2panWidth/2;
Post Reply