views:

186

answers:

2

hi I have a flash script, i added one move clip via addChild, my movie area is 500x400 and the movieClip i aligned to center. But when am trying to set the size with in browser its not aligned to center. all my calculations are getting wrong.

package {
    import flash.display.*;
    import flash.display.Stage;
    import flash.geom.*;
    import flash.net.*;
    import flash.media.*;
    import flash.utils.Timer;
    import fl.motion.Color;
    import flash.events.*;
    import flash.text.*;
    import flash.system.LoaderContext;
    import flash.system.Security;

    public class main extends Sprite {

        public function main(){
            trace("Hello");


            var btn:_Button = new _Button();
            btn.x= (stage.stageWidth - btn.width)/2
            btn.y= (stage.stageHeight - btn.height)/2
            addChild(btn);
        }
    }
}

Here is my code

A: 

Hi there, try this:

if center aligned

btn.x = stage.stageWidth / 2;
btn.y = stage.stageHeight / 2;

if top left

btn.x = stage.stageWidth / 2 - btn.width / 2;
btn.y = stage.stageHeight / 2 - btn.height / 2;
Tyler Egeto
WHAT IS THIS? I DON'T UNDERSTAND.I NEED TO CHECK MY SCALEING FACTOR, MY EQUATIONS ARE CORRECT. BUT THE FLASH SETTINGS ...
coderex
+2  A: 
bhups