Don't trust Stage.width
Just found an issue with cached SWF files in IE7 - Stage.width will sometimes be reported incorrectly. We had a Movieclip that used Stage.width for positioning and whenever the SWF was cached, that movieclip would be positioned off stage. Hardcoding a variable instead of using the property solved the problem.
I seem to remember that there were some issues with Stage.width some years ago as well? Anyway - great to finally be doing some Flash work after editing JSP and portlets the last couple months...
Comments
If I recall correctly, you have to wait a frame for the Stage props to instantiate correctly. Putting all your code on frame 2 - or putting in a wait generally fixes these issues.
Posted by: Mike | February 28, 2007 05:11 PM
Generally, you can get around weird stage size problems by listening for it's resize event and doing your positioning in the event handler. At least one of the browsers out there doesn't report the correct value when the SWF first starts playing.
Posted by: Josh | March 1, 2007 02:32 AM
Hi Mike,
Sounds probable, but unfortunatly it won't work for me. I don't use frames at all since I only do class based stuff using FlashDevelop and all my code is usually on frame one.
I think Josh's idea will work, since the resize event should trigger after the first frame is drawn. Thanks for good pointers!
The odd thing is that if I trace the value to a text field in the faulty SWF, it will report the correct value despite failing to position the MC? Odd...
Posted by: Jensa | March 1, 2007 10:51 AM
Use interval instead of frames and wait couple ms for "initialization". You can do it gracefully with setInterval and dispatching custom event (sceneInitialized, or sth). In event handler write your code for layouting.
Posted by: maliboo | March 1, 2007 12:35 PM