Keep content centered in flash

A simple method to keep your content centered on the flash stage.

  1. myListener = new Object();
  2. myListener.onResize = centercontent;
  3. Stage.align = "TL";
  4. Stage.addListener(myListener);
  5. function centercontent() {
  6. mcContent._x = Math.ceil(Stage.width/2-mcContent._width/2);
  7. mcContent._y = Math.ceil(Stage.height/2-mcContent._height/2);
  8. }
  9. centercontent();
This entry was posted in Flash general and tagged , , , , . Bookmark the permalink.

5 Responses to Keep content centered in flash

  1. Pingback: True fullscreen flash | Life of a Glasgow Flash Developer

  2. mAqq says:

    Hello to Glasgow,
    many thanks for this script. it saved my project…i had that problem onResize that i couldnt solve by my self. tried the _root and _level0 but nothing worked.
    Best regards
    mAqq

  3. hey lol , woooah …

    i laughing cos have typed u out a msg liek 50 times now and each time , keep loosing it – nah not ur end – mine – it is 5 am , later , been up all night , and now have surfboard on lap as new desk , feet on coffee table , near full on vertical and cant see straight ! , i kepe on loosing the brwoser when i drop the flippin lot on bloddy floor lol …

    anwyays – Paul – u r a legend man , sorry bout the typing , wish i coudl say it was the hour , it not really , i just naturally crap at grammar , lol ,

    have spent maybe 3 hours on ur site , goign over all those links , ego7 , etc etc ,

    can u rememebr derbauer.de , billy bussey , 2advanced.com , old version V4 propechy not new one ( thats is gay ) ?

    i started to learn code this week , vertical learnign curve ( well even thou i am horizontal now lol – right state if u see me ha lol ) …

    basically despite my mad rambilings man , u have made my stuff work , well in most part – thanx man , really , THANX PAUL.

    trust me , there is alot of bad out there , and the godo aka urself , are few n far between man , and i been on all of them this week , on a mission , as in if i dotn work out how to do these things , then no rent , no food , so trust me – you are up there at the top man , and once agian b4 i fall off this bloody sofa and the surfboard smacks me in the face and i loose this message ,

    thanx , for allowing me to ….well …

    ” cre8_2morrow ”

    > will be in touch when i make more sense than a glass hammer ! – sleep maybe and english lessons lol
    ….

  4. Z says:

    Well the right side?

  5. Paul says:

    Well the right side?

    Can you elaborate?