0
무대 중간에 이미지의 중심을 맞추고 이미지가로드 될 때 이미지의 로더 크기를 기준으로 올바른 종횡비에 비례하여 크기를 조정하려고합니다. . 내 주요 응용 프로그램 러너에서스테이지 계산을 통해 이미지의 크기를 조정하는 방법
내가 할 :
내 이미지에서 다음private var rec:Rectangle = new Rectangle();
private var img:BitmapDisplay = new BitmapDisplay();
stage.addEventListener(Event.RESIZE, setRect);
img.imageURL = "some/path/to/image.jpg";
addChild(img);
private function setRect():void
{
var horz:Number = stage.stageWidth/16;
var vert:Number = stage.y + stage.stageHeight/16;
rec.x = horz;
rec.y = 80;
rec.width = stage.stageWidth - horz;
rec.height = stage.stageHeight - (vert * 2) - rec.y;
img.boundary = rec;
}
(BitmapDisplay) 클래스 내가 가진 :
// sets the boundary of the image and resizes it
public function set boundary(rect:Rectangle):void
{
_imageBoundary = rect;
resizeImage();
}
private function resizeImage():void
{
var aspect:Number = _ldr.content.width/_ldr.content.height;
var cAspect:Number = _imageBoundary.width/_imageBoundary.height;
if (aspect <= cAspect)
{
_ldr.height = _imageBoundary.height;
_ldr.width = aspect * _ldr.height;
}
else
{
_ldr.width = _imageBoundary.width;
_ldr.height = _ldr.width/aspect;
}
var _pad:int = 7;
_ldr.x = (_imageBoundary.width - _ldr.width)/2 + _imageBoundary.x - _pad;
_ldr.y = (_imageBoundary.height - _ldr.height)/2 + _imageBoundary.y - _pad;
}
}
를 잘 작성 작업에서 뭔가 분명 보관이 있습니까? 스테이지의 16th가 이미지의 경계가되고 이미지가이 rect를 기준으로 크기를 조절하거나 크기를 조정하려고합니다.
덕분에 ...
나는 스테이지의 계산과 관련이없는 이미지의 맨 위에 최소 공간을두고 싶다는 언급을해야한다 ... 이것은 내가 노력하고있는 코드에서 분명해야한다. – jml
조금 더 명확하게 표시 할 수 있습니까? 예를 들어 스테이지 (500x400) 이미지는 (widthxheight)이어야하고 왼쪽 하단 모서리는 (c1xc2)이어야합니다. – bhups
안녕하세요 bhups 외; 직사각형과 이미지를 어떻게 사용하고 있는지 더 잘 이해할 수 있도록 코드를 업데이트했습니다. 사용자가 브라우저 윈도우의 오른쪽 하단 부분을 드래그하면 무대 이벤트의 이미지 크기를 동적으로 조정해야하기 때문에 스테이지 크기에 대한 예제가 필요하지 않다고 생각합니다.하지만 아마도 누락 된 부분이있을 수 있습니다. – jml