简体   繁体   中英

How to center a flash projector on screen when launched?

Is there a way to center a flash projector on a screen when it is launched? I noticed when I launch a flash projector file, it gets positioned on the screen randomly. I am using ActionScript 3.

AFAIK it is not possible, but I can think of two workarounds:

  • Call fscommand("exec", args) and call some custom application that centers the projector window, through FindWindowEx and SetWindowPos.
  • Make your own app that plays the SWF file (by wrapping it in a browser, or using some alternative like the OCX) and is already centered.

Since both of them require you to make another app, I'd go myself with the first option in this case. If it would require more things I'd go with the second one.

EDIT: Although depending on your experience, and language knowledge the second one may be best.

If you need to center your project sprite in the flash player after start (otherwise I get it wrong), you need to 1) set size of the project sprite manually and 2) set stage scale mode:

package
{
    import flash.display.Sprite;
    import flash.display.StageScaleMode;

    [SWF(width="203", height="203")]
    public class MyProject extends Sprite
    {
        public function MyProject()
        {
            stage.scaleMode = StageScaleMode.NO_SCALE;

            var sprite:Sprite = new Sprite;
            sprite.graphics.lineStyle(1, 0, 1);
            sprite.graphics.drawRect(0, 0, 200, 200);
            addChild(sprite);
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM