Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- iBatis
- node.js web framework
- flex3
- nodejs express
- 주식이야기
- rss
- php thumbnail
- Node.js
- ajax
- 베트남어
- 책이야기
- php
- ejb
- Cross
- 도커
- 메일왕창보내는법
- 명사 분석기
- C/C++
- Lift
- 디즈니씨
- ror실행
- 명사 추출기
- express for node.js
- 스킨 스쿠버
- 명사 뽑아내기
- 나의 프로젝트
- Eclipse
- 나의 취미
- docker
- scala
Archives
- Today
- Total
nkdk의 세상
AS3.0의 버튼 제어 Simple type, Standard Type 비교 본문
var mButton:SimpleButton = new SimpleButton();
var mUpShape:Shape = new Shape();
var mDownShape:Shape = new Shape();
var mOverShape:Shape = new Shape();
var mhitTestShape:Shape = new Shape();
mButton.overState=mOverShape;
mButton.upState=mUpShape;
mButton.downState=mDownShape;
mButton.hitTestState=mhitTestShape;
function draw(mShape:Shape, mColor:uint, mWidth:uint, mHeight:uint):void{
mShape.graphics.lineStyle(1, 0x000000, 0.6);
mShape.graphics.beginFill(mColor);
mShape.graphics.drawRect(100,100,mWidth,mHeight); // 위치 조정
mShape.graphics.endFill();
}
draw(mOverShape, 0xFFCC00, 100,30);
draw(mUpShape, 0xCCFF00, 100,30);
draw(mDownShape, 0x00CCFF, 100, 30);
draw(mhitTestShape, 0xCC00FF, 100 , 30);
stage.addChild(mButton);
// 하지만 이건 simple코딩이기 때문에 좋지 않은 코딩입니다. 버튼이 많아지면.. 곤란합니다.
그럼 이렇게 해 봅시다.
BtnSta.as
package{
import flash.display.Shape;
import flash.geom.Point;
public class BtnState extends Shape
{
private var bgColor:uint;
private var size:Point;
public function BtnState(bgColor:uint, size:Point):void
{
bgColor = bgColor;
size = size;
draw();
}
private function draw():void
{
graphics.beginFill(bgColor);
graphics.drawRect(0, 0, size.x, size.y);
graphics.endFill();
}
}
}
BtnStateTest.fla
import flash.display.Shape;
import flash.geom.Point;
import BtnState;
var mButton:SimpleButton = new SimpleButton();
var mPoint:Point = new Point(120, 50);
var mUpShape:DisplayObject = new BtnState(0xFFCC00, mPoint);
var mDownShape:DisplayObject = new BtnState(0xFF00CC, mPoint);
var mOverShape:DisplayObject = new BtnState(0xFFCCCC, mPoint);
var mhitTestShape:DisplayObject = new BtnState(0xFFCC00, mPoint);
mButton.overState = mOverShape;
mButton.downState = mDownShape;
mButton.upState = mUpShape;
mButton.hitTestState = mhitTestShape;
addChild(mButton);
여기 까지고요. 추가 적으로..
stage.addChild(child:DisplayObject):DisplayObject
stage.addChildAt(child:DisplayObject,index:int):DisplayObject
removeChild(child:DisplayObject):DisplayObject
removeChildAt(index:int):DisplayObject
getChildAt(index:int):DisplayObject // Z-Index에 해당하는 디스플레이
getChildByName(name:String):DisplayObject // 이름으로 검색후 반환
getChildIndex(child:DisplayObject):int // zIndex반환
setChildIndex(child:DisplayObject, index:int):void // 변경
swapChidren(child1:DisplayObject, Child2:DisplayObject):void // z-index 교환
numChildren // 포함된 DisplayObject객체 개수
contains(child:DisplayObject):Boolean // 컨테이너 이미 삽입된 여부확인
그 외 여러가지가 있습니다.
자 그럼 첨부되어 있는 Class Diagram 을 올리도록 하겠습니다.