• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 763
  • Last Modified:

Flash 8 AS2 - Stage.width returns 0 in ie8

For a while i was completly stumped trying to figure out why I couldn't use Stage.width to horizontally center my dynamically loaded .swf on the stage.  I had a function that would center the .swf if the browser was resized, and that worked, but when the file was opened for the first time in the browser, the centering was way off.  And it's because Stage.width is returning a 0.

Is there a work around for that?   How can i determine a full screen width of a div?

Thanks for your help!!!  Hope this makes sense.

This is the line i'm running to center the movieclip, it's at the beginning of my actionscript:
mc_movie._x = (Stage.width/2) - (mc_movie._width/2);
0
slightlyoff
Asked:
slightlyoff
  • 2
  • 2
1 Solution
 
moagriusCommented:
Stage.width should not be undefined.

if you put this one line of code in a new FLA:

this.createTextField(0,0,0,0,200,20).text = Stage.width;

and run File > Publish Preview > HTML, it should show appropriately.
0
 
slightlyoffAuthor Commented:
Thanks for your response.  I will try it when i get back to the house tonight.  The problem with Stage.width returning 0 only happens when i view the page in a browser.  If i test it in Flash, it works like a champ.

Thanks again!
0
 
moagriusCommented:
File > Publish Preview > HTML will open the page in a browser
0
 
slightlyoffAuthor Commented:
Perfect, thanks :)
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now