;

PDA

Click to See Complete Forum and Search --> : RESIZE delay?


Mpjraaij
10-30-2009, 01:41 PM
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.
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):
_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

v5000
10-30-2009, 02:24 PM
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;

Mpjraaij
10-30-2009, 07:53 PM
I have those declared. I figured out I declared the _shapewidth var too soon. - it is fixed now. Thank you anyway :)