1. 그래픽 버튼을 상속 받아 텍스트 버튼 클래스 만들기
2. 사용 예제


1. 그래픽 버튼을 상속 받아 텍스트 버튼 클래스 만들기
public class MyGraphicHaviButton extends HGraphicButton
{
private String text;
private int xTextPosition;
private int yTextPosition;

public MyGraphicHaviButton (String text,int xTextPosition,int yTextPosition,
Image image,int xPos,int yPos,int xDim,int yDim)
{
super(image,xPos,yPos,xDim,yDim);
this.text=text;
this.xTextPosition=xTextPosition;
this.yTextPosition=yTextPosition;
}

public void paint(Graphics g){
//displays the image...
super.paint(g);
// display the String
g.drawString(text,xTextPosition,yTextPosition);
}
}


2. 사용 예제
Image sfondoNotSelected = Tools.loadImage("resource/notselected.png");

myButton=new MyGraphicHaviButton ("PROGRAMMI TV",430,274,sfondoNotSelected,410,254,210,60);
myButton.setFont(new Font("Tiresias",1,20));
myButton.setVisible(true);
myButton.repaint();

[Flash] http://wonsama.tistory.com/attachment/ck010000000000.swf




1. Sprite를 상속받아 buttonMode를 설정
  <accessor name="buttonMode" access="readwrite" type="Boolean" declaredBy="flash.display::Sprite"/>

2. EventDispatcher에 선언된 addEventListener을 통하여 마우스 클릭 이벤트 등록
<method name="addEventListener" declaredBy="flash.events::EventDispatcher" returnType="void">

3. Array의 reverse와 addChild, removeChild를 이용하여 버튼 등록 해지 작업을 한다.

조금씩 배워가는 느낌? ㅡ,.ㅡ; 아직은 갈길이 멀다...

응용을 하면... Shape대신 무비 클립을 넣어 줘도 될듯 ... 그럼 좀더 화려해 지겠죠 크..

[참조]

  <method name="swapChildren" declaredBy="flash.display::DisplayObjectContainer" returnType="void">
    <parameter index="1" type="flash.display::DisplayObject" optional="false"/>
    <parameter index="2" type="flash.display::DisplayObject" optional="false"/>
  </method>

swapChildren 을 이용하여도 토글 느낌을 줄수 있다.
물론 swapChildren을 이용하려면 2개의 버튼은 동일 위치 동일 크기로 있어야 하며
디스플레이 오브젝트에 포함이 되어 있어야 한다는것을 잊음 안된다.

'기타 > Old' 카테고리의 다른 글

Bitmap 처리속도  (0) 2008.05.02
스크립트를 통한 컴퓨터 재부팅하기  (0) 2008.05.02
동적으로 버튼 만들기  (0) 2008.04.30
Flash Video Sample - Display Object  (0) 2008.04.30
Bitmap Filter 사용예시  (0) 2008.04.30
▶ test.fla에서 작업을 한다고 가정.

1. 버튼에 사용할 4개의 무비클립을 만를어 준다. (마우스 다운, 히트, 평상시, 오버)

사용자 삽입 이미지



















2. 라이브러리 창에서 조금전 생성한 무비클립선택이후 Linkage를 선택하여
Linkage를 아래와 같이 선택한 다음, 클래스 명을 위와 동일하게 바꿔준다.
사용자 삽입 이미지















3. MixButton.as 코딩
SimpleButton을 상속받은 MixButton 클래스를 코딩한다.


4. test.fla 코딩



변영하여 다양한 형태로 발전시켜주길 바랍니다. ㅋㅋ
초보의 손길이 묻어난 동적 버튼 생성이라 나름대로 풋풋하죠...;;
잘 봐주길..

'기타 > Old' 카테고리의 다른 글

스크립트를 통한 컴퓨터 재부팅하기  (0) 2008.05.02
Shape을 이용한 토글 버튼 만들기  (0) 2008.05.02
Flash Video Sample - Display Object  (0) 2008.04.30
Bitmap Filter 사용예시  (0) 2008.04.30
Bitmap 간단 사용 예시  (0) 2008.04.30

+ Recent posts