Bitmap too small for its content

Стас Пишевский

I'm creating graphics by the code and placing them into a Bitmap. But they are higher than this Bitmap container.

import flash.display.*;

function getLine(){         
    var containerWidh:Number =enter code here 300;
    var containerHeight:Number = 300;
    var borderWidt:Number = 1;
    var spriteWrap:Sprite = new Sprite();

    var innerContainer:Sprite = new Sprite();
    innerContainer.x = 0;
    innerContainer.y = 0;

    var line1:Shape = new Shape();
    line1.graphics.lineStyle(5, 0x6F4356, 1, false, StageScaleMode.SHOW_ALL, CapsStyle.ROUND);
    line1.graphics.moveTo(50, 5);
    line1.graphics.lineTo(50, 800);
    line1.graphics.endFill();

    var line2:Shape = new Shape();
    line2.graphics.lineStyle(5, 0x6F4356, 1, false, StageScaleMode.SHOW_ALL, CapsStyle.ROUND);
    line2.graphics.moveTo(200, 290);
    line2.graphics.lineTo(200, 300);
    line2.graphics.endFill();

    innerContainer.addChild(line1);
    innerContainer.addChild(line2);
    spriteWrap.addChild(innerContainer);    

    return spriteWrap;
}

var spriteWrap:Sprite = getLine();
var wrapForBitmap:Sprite = new Sprite();            
var drawBitmap:BitmapData = new BitmapData(300, 300, true, 0x00ffaa);
var goOnStage:Bitmap = new Bitmap(drawBitmap);
wrapForBitmap.graphics.beginBitmapFill(drawBitmap);
wrapForBitmap.graphics.lineStyle(1, 0x6F7E84);
wrapForBitmap.graphics.drawRect(0, 0, 300, 300);
wrapForBitmap.graphics.endFill();
wrapForBitmap.x = 10;
wrapForBitmap.y = 10;

drawBitmap.draw(spriteWrap, new Matrix(1, 0, 0, 1, 0, 0));

wrapForBitmap.addChild(goOnStage);
stage.addChild(wrapForBitmap);
helloflash

Your Shape line1 is higher than your Bitmap's height (300):

line1.graphics.moveTo(50, 5); // begins at x = 50 and y = 5
line1.graphics.lineTo(50, 800); // begins at x = 50 and y = 800

With the following code, you will draw a line from the top to the bottom of your Bitmap:

line1.graphics.moveTo(50, 0);
line1.graphics.lineTo(50, 300);

If you want line1 to be visible without changing it's height, you have to change your Bitmap's height (800) by modifying the second argument of your BitmapData method:

var drawBitmap:BitmapData = new BitmapData(300, 800, true, 0x00ffaa);

You should modify at the same time your rectangle's height:

wrapForBitmap.graphics.drawRect(0, 0, 300, 800);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related