Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 02-08-2010, 12:46 AM   #1
dmack
dmack = new Person()
 
Join Date: Jan 2005
Posts: 124
Question centering 3D objects on stage

I am new to working with 3D in Flash CS4. My project has a center-registered movie clip with a z-axis setting of 850 that I need to keep centered on the stage at all times, including when the stage is re-sized.

Code like this for centering 2D objects doesn't seem to work:

ActionScript Code:
mc.x = stage.stageWidth/2; mc.y = stage.stageHeight/2;

My guess is that I need to convert the movie clip back into 2D space somehow, center it using the code above and then change the z-axis back to 850. Does this sound about right, or is there another way to do this? A simplified code example would be much appreciated.

Thanks.
__________________
I am an instance of the Person class.
dmack is offline   Reply With Quote
Old 02-08-2010, 01:02 AM   #2
abeall
Senior Member
 
Join Date: Feb 2006
Location: Washington, DC
Posts: 2,812
Send a message via AIM to abeall
Default

If I understand correctly, you are placing an object at a Z depth and when the stage size changes the perspective projection causes the object to no longer be centered? The problem here is the 3D projection center point. You can control this at runtime:

ActionScript Code:
var perspective:PerspectiveProjection = root.transform.perspectiveProjection; perspective.projectionCenter = new Point(stage.stageWidth / 2, stage.stageHeight / 2);

Include this in your stage resize handler and it will keep the 3D projection center of the main timeline centered on the stage, which should solve your issue.
__________________
Aaron Beall | Flash portfolio | Fireworks extensions | Twitter
abeall is offline   Reply With Quote
Old 02-08-2010, 02:04 PM   #3
dmack
dmack = new Person()
 
Join Date: Jan 2005
Posts: 124
Question thank you, but still not working

Thank you for your reply abeall.

I think I wasn't explaining my problem correctly. The movie clip does rotate around the center of the stage (horizontally and vertically), but the 3D movie clip (which I've made sure is center-registered) doesn't appear to be centered on the stage after a stage resize. So when I move my cursor to the middle of the stage when the movie is running, the movie clip displays with no perspective -- which is exactly what I want. However, the movie clip is not always centered on the stage after a stage resize.

I thought it might be helpful to provide a working link to the project:

http://www.mackstudiopro.com/project...flashShowcase/

It's basically an adaptation of Lee Brimelow's gotoandlearn tutorial: http://www.gotoandlearn.com/play?id=103

If it helps I can also supply the source code. Any additional help would also be greatly appreciated. Thank you.
__________________
I am an instance of the Person class.
dmack is offline   Reply With Quote
Old 02-08-2010, 06:46 PM   #4
abeall
Senior Member
 
Join Date: Feb 2006
Location: Washington, DC
Posts: 2,812
Send a message via AIM to abeall
Default

Are you using stage aligh top left?
__________________
Aaron Beall | Flash portfolio | Fireworks extensions | Twitter
abeall is offline   Reply With Quote
Old 02-09-2010, 02:05 PM   #5
dmack
dmack = new Person()
 
Join Date: Jan 2005
Posts: 124
Wink

I'm using this code in the init:

ActionScript Code:
stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE;

To meet my deadline I had to abandon the centering issue (for now) and the Flash movie centers vertically and horizontally within the HTML page. Not ideal, but it works.

Thanks again for your advice.
__________________
I am an instance of the Person class.
dmack is offline   Reply With Quote
Old 02-09-2010, 03:49 PM   #6
dmack
dmack = new Person()
 
Join Date: Jan 2005
Posts: 124
Thumbs up solution link

Baby Minion replied to my query on Flashkit.com and provided some additional code to get the centering issue resolved:

http://board.flashkit.com/board/newr...te=1&p=4233357

And thanks again abeall for steering me in the right direction with perspective projection.
__________________
I am an instance of the Person class.
dmack is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:51 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.