=================================
=================================
=================================
출처: (여기) 202psj.tistory.com
통째로 구현 코드.
package
{
import flash.display.InteractiveObject;
import flash.display.LoaderInfo;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.geom.Point;
import flash.text.TextField;
import flashx.textLayout.formats.Float;
[SWF(width=305, height=283, backgroundColor=0xffffff)]
//[SWF(backgroundColor=0x000000)]
public class testPentagon extends Sprite
{
//팬타곤 그래프 이미지 크기
public static var _SCREEN_W:int = 305;
public static var _SCREEN_H:int = 283;
public var _chartBG:RImgPentagon = new RImgPentagon(); //배경 이미지 스프라이트 클래스 (swc에서가져옴)
public var _pentagon:Sprite = new Sprite();
public static var _me:testPentagon = null;
public const point1:Point = new Point(153, 32);
public const point2:Point = new Point(260, 110);
public const point3:Point = new Point(220, 235);
public const point4:Point = new Point(87, 235);
public const point5:Point = new Point(46, 110);
public var point1tmp:Point = new Point(point1.x, point1.y);
public var point2tmp:Point = new Point(point2.x, point2.y);
public var point3tmp:Point = new Point(point3.x, point3.y);
public var point4tmp:Point = new Point(point4.x, point4.y);
public var point5tmp:Point = new Point(point5.x, point5.y);
public const pointCenter:Point = new Point(154, 145);
public var _max:int = 5;
public var _point1:int = 5;
public var _point2:int = 5;
public var _point3:int = 5;
public var _point4:int = 5;
public var _point5:int = 5;
public function testPentagon()
{
_me = this;
addChild(_chartBG);
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
_ParameterStr = getParameters(this.root.loaderInfo);
//test
setPoint1Val(3);
setPoint2Val(3);
setPoint3Val(3);
setPoint4Val(3);
setPoint5Val(4);
drawPentagon();
}
public function setMax(val:int):void
{
_max = val;
}
public function setPoint1Val(val:int):void
{
_point1 = val;
var per:Number = Number(val/_max);
var tmp:Number = pointCenter.y - point1.y;
tmp = tmp * per;
point1tmp.y = pointCenter.y - tmp;
}
public function setPoint2Val(val:int):void
{
_point2 = val;
//각각 x,y 의 길이 106, 35 길이대비 3:1
var per:Number = Number(val/_max);
var wid:Number = point2.x - pointCenter.x;
var hei:Number = pointCenter.y - point2.y;
var sc:Number = hei/wid; //길이대비
var wPer:Number = wid * per; //퍼센트 비율 가로길이
var pW:Number = pointCenter.x+(wPer);
var pH:Number = pointCenter.y-(wPer * sc);
point2tmp.x = pW;
point2tmp.y = pH;
}
public function setPoint3Val(val:int):void
{
_point3 = val;
var per:Number = Number(val/_max);
var wid:Number = point3.x - pointCenter.x;
var hei:Number = pointCenter.y - point3.y;
var sc:Number = hei/wid; //길이대비
var wPer:Number = wid * per; //퍼센트 비율 가로길이
var pW:Number = pointCenter.x+(wPer);
var pH:Number = pointCenter.y-(wPer * sc);
point3tmp.x = pW;
point3tmp.y = pH;
}
public function setPoint4Val(val:int):void
{
_point4 = val;
var per:Number = Number(val/_max);
var wid:Number = point4.x - pointCenter.x;
var hei:Number = pointCenter.y - point4.y;
var sc:Number = hei/wid; //길이대비
var wPer:Number = wid * per; //퍼센트 비율 가로길이
var pW:Number = pointCenter.x+(wPer);
var pH:Number = pointCenter.y-(wPer * sc);
point4tmp.x = pW;
point4tmp.y = pH;
}
public function setPoint5Val(val:int):void
{
_point5 = val;
var per:Number = Number(val/_max);
var wid:Number = point5.x - pointCenter.x;
var hei:Number = pointCenter.y - point5.y;
var sc:Number = hei/wid; //길이대비
var wPer:Number = wid * per; //퍼센트 비율 가로길이
var pW:Number = pointCenter.x+(wPer);
var pH:Number = pointCenter.y-(wPer * sc);
point5tmp.x = pW;
point5tmp.y = pH;
}
public function drawPentagon():void
{
//꼭지점 부터 시계 방형 순으로
_pentagon.graphics.beginFill(0x80FF0000, 0.1);
_pentagon.graphics.moveTo(point1tmp.x, point1tmp.y); //꼭대기 꼭지점1
_pentagon.graphics.lineTo(point2tmp.x, point2tmp.y); //오른쪽 꼭지점2
_pentagon.graphics.lineTo(pointCenter.x, pointCenter.y); //꼭센터 꼭지점
_pentagon.graphics.beginFill(0x80FF0000, 0.3);
_pentagon.graphics.moveTo(point2tmp.x, point2tmp.y); //꼭대기 꼭지점2
_pentagon.graphics.lineTo(point3tmp.x, point3tmp.y); //오른쪽 꼭지점3
_pentagon.graphics.lineTo(pointCenter.x, pointCenter.y); //센터 꼭지점
_pentagon.graphics.beginFill(0x80FF0000, 0.4);
_pentagon.graphics.moveTo(point3tmp.x, point3tmp.y); //꼭대기 꼭지점3
_pentagon.graphics.lineTo(point4tmp.x, point4tmp.y); //오른쪽 꼭지점4
_pentagon.graphics.lineTo(pointCenter.x, pointCenter.y); //센터 꼭지점
_pentagon.graphics.beginFill(0x80FF0000, 0.3);
_pentagon.graphics.moveTo(point4tmp.x, point4tmp.y); //꼭대기 꼭지점4
_pentagon.graphics.lineTo(point5tmp.x, point5tmp.y); //오른쪽 꼭지점5
_pentagon.graphics.lineTo(pointCenter.x, pointCenter.y); //센터 꼭지점
_pentagon.graphics.beginFill(0x80FF0000, 0.1);
_pentagon.graphics.moveTo(point5tmp.x, point5tmp.y); //꼭대기 꼭지점5
_pentagon.graphics.lineTo(point1tmp.x, point1tmp.y); //오른쪽 꼭지점1
_pentagon.graphics.lineTo(pointCenter.x, pointCenter.y); //센터 꼭지점
this.addChild(_pentagon);
}
public function destroy():void
{
//삭제....처리..
}
}
}
=================================
=================================
=================================
'ADOBE > ActionScript' 카테고리의 다른 글
[AS] SWF 로 값 넘기기 브라우저별 테스트 (0) | 2013.07.22 |
---|---|
플래시 AS3.0 액션스크립트 안드로이드등등의 스마트기기에서 onMoveHandler 리스너 좌표를 int로 바꿀때,혹은 소수점 값을 int로 바꿀때 주의점 (0) | 2013.05.07 |
플래시 액션스크립트 폰트 관련 폰트 임베디드 폰트 안티앨리어싱 등등,.. (0) | 2013.03.14 |
[AS] 플래시 AS3.0 URLRequest,URLLoader 관련 페이지 불러오기 (0) | 2013.02.25 |
flash as3.0 textField autoSize 이용 글자수에 따라 width값 구하기(as3.0) [출처] textField autoSize 이용 글자수에 따라 width값 구하기(as3.0) (0) | 2012.12.17 |