Stage Resizing Issues

By cinco-pata5 | Jun 23, 2009

actionscript3

I’m trying to solve a problem with a stage listener. My site consists of 3 external swf’s one is the loader, then there is a background swf, and a main interface swf, when the user loads the site, and let’s say they resize the browser, I want to pass the variables to each of the swf document class. But I’m getting an ArgumentError #1063. The code bellow is that I have done.

Main Document Class

Code:

package com.brunomilitzer.framework
{
        import flash.display.*;
        import flash.events.*;
       
        import com.brunomilitzer.events.StageEvent;
        import com.brunomilitzer.framework.TopBg;
       
        public class TopLevel extends MovieClip
        {
               
                public static  var stage:Stage;
                public static  var root:DisplayObject;

                public var stageAlign:StageAlign;
                public var stageScaleMode:StageScaleMode;
                       
                private var stageEvent:StageEvent = new StageEvent();
               
                private var background:TopBg;
               
                public function TopLevel() {
                       
                        TopLevel.stage = this.stage;
                        TopLevel.root = this;

                        stage.align = StageAlign.TOP_LEFT;
                        stage.scaleMode = StageScaleMode.NO_SCALE;
                        stage.displayState = StageDisplayState.NORMAL;
                        stage.showDefaultContextMenu = false;
                       
                        stage.addEventListener(Event.RESIZE, onStageResize);
                        stage.dispatchEvent(new Event(Event.RESIZE));
                       
                        background = new TopBg(stageEvent.xWidth, stageEvent.yHeight);
                       
                }
                       
                private function onStageResize(event:Event):void {
                       
                        if (stage.stageWidth < 980) {
                               
                                stageEvent.xWidth = 980;
                               
                        } else {
                               
                                stageEvent.xWidth = stage.stageWidth;
                        }
                        if (stage.stageHeight < 600) {
                               
                                stageEvent.yHeight = 600;
                               
                        } else {
                               
                                stageEvent.yHeight = stage.stageHeight;
                        }
                       
                        if (preloader_mc != null) {
                               
                                preloader_mc.x = (stageEvent.xWidth / 2) - (preloader_mc.width / 2);
                                preloader_mc.y = (stageEvent.yHeight / 2) - (preloader_mc.height / 2);
                        }
                }
        }
}


Background Class

Code:

package com.brunomilitzer.framework
{
        import flash.display.*;
        import flash.events.*;
       
        public class TopBg extends MovieClip
        {
                private var stageWidth:Number;
                private var stageHeight:Number;
               
                public function TopBg(sW:Number, sH:Number) {
                       
                        stageWidth = sW;
                        stageHeight = sH;
                }
        }
}


actionscript3

Please reply at our Forum

Leave a Comment

If you would like to make a comment, please fill out the form below.

Name (required)

Email (required)

Website

Comments

© 2007 ActionScript 3.0