views:

79

answers:

2

Anyone else has experienced weird behaviors and unexpected values when checking for stage.stageHeight while you have Bandwith Profiler open in Flash IDE?

Say, I have been using this for testing Perlin Noise stuff:

package {

    import flash.display.StageAlign;
    import flash.display.StageScaleMode;

    import flash.display.Sprite;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.events.Event;
    import flash.geom.Point;

    [SWF(width="550", height="400", backgroundColor="#000000", frameRate="60")]
    public class Clouds extends Sprite {
        private var _bitmap:BitmapData;
        private var _xoffset:int = 0;
        private var _yoffset:int = 0;

        public function Clouds() {
            stage.align = StageAlign.TOP_LEFT;
            stage.scaleMode = StageScaleMode.NO_SCALE;

            trace("stage.stageHeight: "+stage.stageHeight);

            _bitmap = new BitmapData(stage.stageWidth, stage.stageHeight,true, 0xffffffff);
            var image:Bitmap = new Bitmap(_bitmap);
            addChild(image);
            addEventListener(Event.ENTER_FRAME, onEnterFrame);
        }

        public function onEnterFrame(event:Event):void {
            _xoffset = _xoffset + Math.random()*4 -2;
            _yoffset = _yoffset + Math.random()*3;
            var point:Point = new Point(_xoffset, _yoffset);

            _bitmap.perlinNoise(200, 100, 3, 1000, false, true,
                            1, true, [point, point]);
        }
    }
}

As you see here, the swf is set to a height of 400 .. When executed with test movie, control-enter, the trace returns 400 .. now, if you try this with the Bandwidth Profiler open, it would return 300, and the Sprite would only extend to 300 height.

Anyone experiencing the same??

A: 

There's nothing weird about that. The stage height you've set is the default one but the stage size might vary if the user, the browser or in this case, FlashIDE resizes the player window (since the UI will proportionally allocate some space for the profiler).

You may want to create your own WIDTH/HEIGHT constants if you need specific base numbers for scaling etc.

Theo.T
Thanx for the answer Theo .. but when I try this with the Bandwidth Profiler open, the stage sizes are correct, only adding the BProfiler on top .. which doesn't affect the stage area. It would display a 400 pixels height stage, but the Sprite i'm using would only be 300 pixels height, leaving a background color band on the bottom.
elQueFaltaba
A: 

Absolutely - As far as i am aware the bug has been fixed in CS4. This bug used to plague me for a long time. The problem only occurs within the testing environment, so you can rest assured that wrapped inside an HTML page this problem disappears.

The only thing i can really suggest is compiling the clip and then opening the bandwidth profiler - or upgrade your flash ide if $ allows it.

You are not alone: http://www.google.com/search?hl=en&q=bandwidth+profiler+bug

Beans
Thanx for the input, Beans. It is happening to me on CS4. As you say, there is no problem when the swf file is into an html, or when you open it directly into flash player .. But I think I know what I did to make this happen .. i recently downloaded a Debug version of flash player, and i've been seeing this around that time .. so that is probably it.
elQueFaltaba
Im not sure debug has anything to do with it, I have dealt with the problem since Flash MX!
Beans