At the bottom i show my class DocObject
code which responds for MovieClips
location on the stage
with help of the stage.addEventListener(Event.RESIZE,onResizeDoc);
method.
The problem is that when i publish the main.fla file to swf or html, it’s not showing any Movie Clips or loaded object until the first Resizie od the window?
Do anyone know, how to handle with this problem?
I only know that the poroblem causes this two lines:
miniaturki.height = sh;
miniaturki.height = 500;
When I delete those two, the problem disappears.
Here is the DocObject
class code:
package
{
import flash.display.MovieClip;
import flash.text.TextField;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.StageDisplayState;
import flash.display.StageScaleMode;
import flash.display.SimpleButton;
import flash.display.StageAlign;
import flash.display.StageDisplayState;
public class DocObject extends MovieClip
{
public function DocObject():void
{
if(stage)
{
initialize();
}
else
{
addEventListener(Event.ADDED_TO_STAGE,initialize);
}
}
private function initialize(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE,initialize);
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.addEventListener(Event.RESIZE,onResizeDoc);
resizeMyDoc();
stage.addEventListener(Event.REMOVED_FROM_STAGE, onRemove);
}
private function onResizeDoc(event:Event = null):void
{
resizeMyDoc();
}
private function resizeMyDoc():void
{
var sw:Number = stage.stageWidth;
var sh:Number = stage.stageHeight;
var sBw = sw - 320;
if (stage.displayState == StageDisplayState.FULL_SCREEN)
{
nazwa.x = 0 + 10;
nazwa.y = sh + 20;
ilosc.x = sw-10;
ilosc.y = sh + 20;
scrolbar.x = 0;
scrolbar.y = sh;
scrolbar.width = sw;
scro.x = scro.x;
scro.y = sh;
miniaturki.x = miniaturki.x;
miniaturki.y = 0;
miniaturki.height = sh;
miniaturki.scaleX = miniaturki.scaleY;
bcgr.x = 0;
bcgr.y = 0;
bcgr.width = sw;
bcgr.height = sh;
maska1.x = 0;
maska1.y = 0;
maska1.width = sw;
maska1.height = sh;
}
else
{
nazwa.x = 0 + 10;
nazwa.y = sh / 2 + 200;
ilosc.x = sw-450;
ilosc.y = sh / 2 + 200;
scrolbar.x = 0;
scrolbar.y = sh / 2 + 250;
scrolbar.width = sBw;
scro.x = scro.x;
scro.y = sh / 2 + 250;
miniaturki.x = miniaturki.x;
miniaturki.y = sh / 2 - 250;
miniaturki.height = 500;
miniaturki.scaleX = miniaturki.scaleY;
bcgr.x = bcgr.x;
bcgr.y = sh / 2 - 250;
bcgr.width = sBw;
bcgr.height = 500;
maska1.x = 0;
maska1.y = sh / 2 - 250;
maska1.width = sBw;
maska1.height = 500;
}
}
private function onRemove(e:Event):void
{
stage.removeEventListener(Event.RESIZE, onResizeDoc);
}
}
}