티스토리 뷰
[ Flex ][ Source ] circle 원 그리기 - Flash에서는 정상 Flex에서는 오류가 발생함 (원인 확인불가) - 해결 rawChildren.addChild()
MiniNeko 2015. 11. 29. 04:37// ActionScript file
import flash.display.Shape;
import flash.display.Sprite;
private function initApp():void {
var sh:Shape = new Shape();
addChild(sh);
var g:Graphics = sh.graphics;
g.lineStyle(5, 0x000000, 1);
g.beginFill(0x000000, 1);
g.drawEllipse(0,0, 200, 100);
var circle:Sprite = new Sprite();
circle.graphics.beginFill(0x000000);
circle.graphics.drawCircle(50,50,30);
circle.graphics.endFill();
addChild(circle);
}
-------------------------------------------------------------------------------------------------------------------
addChild(circle);
사용시에는 Flex 에서 1034 오류가 발생하였지만,
bgBitmap.rawChildren.addChild(circle);
으로 변경하면 정상적으로 bgBitmap(Canvas)에 정상 출력됨 /
rawChildren.addChild(circle);
Application 에 바로 출력됨.
===================================================================================================================
< ?xml version="1.0" encoding="utf-8"?>
< !-- http://blog.flexexamples.com/2008/09/09/rounding-the-corners-of-an-image-control-in-flex-using-a-mask/ -->
< mx:Application name="Image_mask_test"
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white"
initialize="init();">
<mx:Script>
<![CDATA[
import mx.events.ResizeEvent;
private var roundedMask:Sprite;
private function init():void {
roundedMask = new Sprite();
canvas.rawChildren.addChild(roundedMask);
}
private function image_resize(evt:ResizeEvent):void {
var w:Number = evt.currentTarget.width;
var h:Number = evt.currentTarget.height;
var cornerRadius:uint = 60;
roundedMask.graphics.clear();
roundedMask.graphics.beginFill(0xFF0000);
roundedMask.graphics.drawRoundRect(0, 0,
w, h,
cornerRadius, cornerRadius);
roundedMask.graphics.endFill();
image.mask = roundedMask;
}
]]>
</mx:Script>
<mx:Canvas id="canvas">
<mx:Image id="image"
source="http://www.helpexamples.com/flash/images/image1.jpg"
resize="image_resize(event);">
</mx:Image>
</mx:Canvas>
< /mx:Application>
'Language > Flex' 카테고리의 다른 글
[ Flex ][ Source ] Timer - 시간 (0) | 2015.11.29 |
---|---|
[ Flex ][ Source ] SQLite 기본 소스 - AIR 전용 (0) | 2015.11.29 |
[ Flex ][ Source ] Baindable | DataGrid (0) | 2015.11.29 |
[ Flex ][ Source ] Alert - 내용수정 필요 (0) | 2015.11.29 |
[ Flex ][ Source ] ex08_04 : 전자랜지 (0) | 2015.11.29 |