Do you have any idea why do stage.stageWidth and stage.stageHeight return 0 in Firefox or Internet Explorer when using dynamic publishing?
Submitted by: AdministratorWhen using the dynamic publishing method in Internet Explorer or Firefox on Mac stage.stageWidth and stage.stageHeight might initially return 0 (note that for Internet Explorer the stage size will be available on first load, however when reloading or revisiting a page it will initially be 0).
The solution is to define a resize handler in your ActionScript code. The Flash Player team was obviously aware of this issue and therefore the Flash Player will keep on triggering the stage.resize event until it receives its actual width and height.
An AS3 example:
stage.addEventListener(Event.RESIZE, resizeHandler);
stage.dispatchEvent(new Event(Event.RESIZE)); // force stage resize event for normal cases
function resizeHandler(event:Event):void {
if (stage.stageHeight > 0 && stage.stageWidth > 0) {
stage.removeEventListener(Event.RESIZE, resizeHandler); // only execute once
// your initialization code here
}
}
Submitted by: Administrator
The solution is to define a resize handler in your ActionScript code. The Flash Player team was obviously aware of this issue and therefore the Flash Player will keep on triggering the stage.resize event until it receives its actual width and height.
An AS3 example:
stage.addEventListener(Event.RESIZE, resizeHandler);
stage.dispatchEvent(new Event(Event.RESIZE)); // force stage resize event for normal cases
function resizeHandler(event:Event):void {
if (stage.stageHeight > 0 && stage.stageWidth > 0) {
stage.removeEventListener(Event.RESIZE, resizeHandler); // only execute once
// your initialization code here
}
}
Submitted by: Administrator
Read Online SWFObject Job Interview Questions And Answers
Top SWFObject Questions
☺ | How to avoid Active Server Pages error ASP 0139 when using static publishing and Microsoft IIS? |
☺ | Tell me why does Internet Explorer 6 and 7 show the error message J.parentNode is null or not an object? |
☺ | Explain why can we see memory usage increase on every page refresh in Internet Explorer? |
☺ | Tell us why does Firefox report Permission denied to call method Location.toString in the error console? |
☺ | Do you know why does Firefox load my SWF twice? |
Top Scripting language Categories
☺ | AngularJS Interview Questions. |
☺ | Ext-JS Interview Questions. |
☺ | Dojo Interview Questions. |
☺ | Expert Developer JavaScript Interview Questions. |
☺ | SWFObject Interview Questions. |