A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: RESIZE delay?

  1. #1
    Member
    Join Date
    Mar 2009
    Posts
    55

    RESIZE delay?

    Hello,

    I have a file in which I use this stage resize function. However if I resize really fast (like maximize button) it doesn't resize the Timeline.
    Code:
    stage.addEventListener(Event.RESIZE,resizeStage);
    
    private function resizeStage(e:Event):void
    		{
    			resetVideo();
    			_controlbar.resetControlBar(stage.stageWidth);
    			
    			_barlength = _clickbar.width;
    			_levelstart = _level.x;
    			
    			_Controls.y = stage.stageHeight-BAR_HEIGHT;
    		}
    
    		public function resetControlBar(_width:int):void
    		{
    			// get all properties
    			_basics = Shape(mcControlBar.getChildByName("_basics"));
    			_controls = MovieClip(mcControlBar.getChildByName("_controls"));
    			_volumebar = MovieClip(mcControlBar.getChildByName("_volume"));
    			_timebar = MovieClip(mcControlBar.getChildByName("_timeline"));
    			
    			// resize the basic shape
    			_basics.width = _width;
    			
    			resetControls(_width);
    			resetTimeline(_width);
    		}
    		
    		private function resetControls(_width:int)
    		{
    			// resize the controls
    			_volumebar.getChildByName("_base").x = _width-(_volumebar.getChildByName("_base").width+PADDING);
    			_volumebar.getChildByName("_level").x = _volumebar.getChildByName("_base").x+1;
    			_volumebar.getChildByName("_clickbar").x = _volumebar.getChildByName("_base").x+1;
    			_volumebar.getChildByName("_scrub").x = _volumebar.getChildByName("_base").x;
    			_volumebar.getChildByName("_mute").x = _volumebar.getChildByName("_base").x-_volumebar.getChildByName("_mute").width-PADDING;
    			_volumebar.getChildByName("_unmute").x = _volumebar.getChildByName("_base").x-_volumebar.getChildByName("_unmute").width-PADDING;
    			_volumebar.getChildByName("_line").x = (_volumebar.getChildByName("_mute").x-PADDING);
    			_volumebar.getChildByName("_line2").x = (_volumebar.getChildByName("_mute").x-PADDING)-1;
    			
    			// resize the timeline
    			_volumestart = (_volumebar.getChildByName("_mute").x-PADDING);
    		}
    		
    		private function resetTimeline(_width:int)
    		{	
    			var _shapewidth:int = _width-(_play.x+_play.width+PADDING);
    			_shapewidth-= _width-_timedisplay.x+PADDING;
    			
    			// dynamic bars
    			var _bwidth:int = _shapewidth-2;
    			
    			_timebar.getChildByName("_timedisplay").x = _volumestart-_timebar.getChildByName("_timedisplay").width-PADDING;
    			_timebar.getChildByName("_base").width = _shapewidth;
    			
    			var _click:MovieClip = MovieClip(_timebar.getChildByName("_clickbar"));
    			var _child:Shape = Shape(_click.getChildAt(0));
    			_click.removeChild(_child);
    			// the shape
    			var _clickshape:Shape = new Shape();
    			_clickshape.graphics.beginFill(SEC_COLOR);
    			_clickshape.graphics.drawRect(0,0,_bwidth,_timebar.getChildByName("_progress").height);
    			_clickshape.graphics.endFill();
    			_click.addChild(_clickshape);
    		}
    So to be exactly this part stays behind (oddly enough it does set the _timedisplay on the right spot):
    Code:
    _timebar.getChildByName("_base").width = _shapewidth;
    			
    			var _click:MovieClip = MovieClip(_timebar.getChildByName("_clickbar"));
    			var _child:Shape = Shape(_click.getChildAt(0));
    			_click.removeChild(_child);
    			// the shape
    			var _clickshape:Shape = new Shape();
    			_clickshape.graphics.beginFill(SEC_COLOR);
    			_clickshape.graphics.drawRect(0,0,_bwidth,_timebar.getChildByName("_progress").height);
    			_clickshape.graphics.endFill();
    			_click.addChild(_clickshape);
    Is there a way to solve this (without using a timer)?

    Thank you

  2. #2
    Senior Member
    Join Date
    May 2004
    Posts
    226
    I have never had this problem with the resize event. I don't think a timer is going to help. Are you sure the resizeStage function is not being called, or that stage.stageWidth is returning an incorrect value? Also, I don't see the following stage props being set anywhere in your code, which is crucial for a liquid layout:

    stage.align = StageAlign.TOP_LEFT;
    stage.scaleMode = StageScaleMode.NO_SCALE;

  3. #3
    Member
    Join Date
    Mar 2009
    Posts
    55
    I have those declared. I figured out I declared the _shapewidth var too soon. - it is fixed now. Thank you anyway

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center