it leader

 

 

 

 

유저에 반응하는 이벤트 <==> InteractiveEvent

 

FocusEvent

MouseEvent

 

유저와 무관하게 동작하는 이벤트 <==> 시스템 이벤트

 

 

Event.ENTER_FRAME : 계속 렌더링을 반복하는 것

 

물고기가 오른쪽으로 움직이는 애니메이션

 

var fish:MovieClip =fish_mc;

 

fish.addEventListener( Evnet.ENTER_FRAME, onEvent);

 

function OnEvent( e: Event ) : void

{

fish.x = fish.x + 1;

}

 

 

 

 

무비 클립 속성( 특징)

 

x,y                   ( 가로, 세로 )

width, height     ( 넓이 , 높이 ) 음수 불가능

rotation             ( 회전 )

alpha                ( 투명도 )

scaleX, scaleY  ( 가로, 세로 % 길이 ) 1 ( 100%), 2( 200% ), 0.5 ( 50% ), -1 ( 좌우대칭 )

visible               true / false

currentFrame    

tootalFrame

 

 

 x,y

  가로 세로

 width / height

 넓이, 높이 ( 음수 불가능 )

 rotation

 회전

 alpha

 투명도

 scaleX / scale Y

 가로 세로 길이(%) 1 ( 100%), 2( 200% ) -1 ( 좌우대칭 )

 visible

 true / false

 currentFrame

 

 totalFrame

 

 

 

 

무당벌레를 컨트롤러로 상하좌우, 대각선으로 움직이는 애니메이션 ( 8방향 컨트롤러 )

 

필요한 객체 :

무당벌레

 

8방향 키

up 버튼

upRight 버튼

right 버튼

downright 버튼

down  버튼

downleft 버튼

left 버튼

upleft 버튼

 

시작버튼

 

var bug:MovieClip = bug_mc;

var up:MovieClip = up_mc;

var upright:MovieClip = upleft_mc;

var right:MovieClip = right_mc;

var downright:MovieClip= downright_mc;

var down: MovieClip = down_mc;

var dowlleft: MovieClip = downleft_mc;

var left: MovieClip= left_mc;

var upleft: MovieClip= uplef_mc;


var home: MovieClip = home_mc; // 처음 시작 자리로 가는 버튼

 

var xHome:Number = bug_mc.x;       //  버그의 시작 좌표, 로테이션 값 변수 저장

var yHome:Number = bug_mc.y;

var rHome:Number = bug_mc.rotation;


/* var stagePoint.Point = new Point(200,200);

 

bug.x = stagePoint.x;

bug.y = stagePoint.y;

 */


up.addEventListener( MouseEvent.CLICK, onUp);

 

function onUp ( e: MouseEvent ) : void

{

bug.rotation=0;

bug.y = bug.y - 20;

 

}

 

upright.addEventListener( MouseEvent.CLICK, onUpRight);

 

function onUpRight ( e: MouseEvent ) : void

{

bug.rotation = 45;

bug.x= bug.x+ Math.sqrt(800);   //대각선 20 속도의 백터 방식 표현 루트 

bug.y= bug.y- Math.sqrt(800);

}

 

right.addEventListener( MouseEvent.CLICK, onRight ) ;

 

function onRight( e: MouseEvent ) : void

{

bug. rotation = 90;

bug.x = bug.x + 20;

}

 

downright.addEventListener( MouseEvent.CLICK , onDownRight ) ;

 

function onDownRight ( e: MouseEvent ) : void

{

bug.rotation : 135;

bug.x = bug.x + Math.sqrt(800);

bug.y = bug.y + Math.sqrt(800);

 

}

 

down.addEventListener( MouseEvent.CLICK, onDown);


function onDown ( e: MouseEvent ) : void

{

bug.rotation = 180;

bug.y = bug.y +20;


}


downleft.addEventListener ( MouseEvent.CLICK, onDonwLeft ) ;


function onDownLeft ( e : MouseEvent ) : void

{

bug.rotation = 225;

bug.x = bug.x - Math.sqrt(800);

bug.y = bug.y +Math.sqrt(800);


}


left.addEventListener(MouseEvent.CLICK, onLeft);


function onLeft ( e:  MouseEvent ) : void

{

bug.rotation = 270;

bug.x =bug.x -20;


}


upleft.addEventListener ( MouseEvent.CLICk, onUpLeft);


function onUpLeft ( e : MouseEvent ) : void

{

bug.rotation = -45;

bug.x = bug.x - Math.sqrt(800);

bug.y = bug.y - Math.sqrt(800);


}


home.addEventListener ( MouseEvent.CLICK, onHome);


function onHome ( e: MouseEvent ) : void

{

bug_mc.x = xHome;

bug_mc.y = yHome;

bug_mc.rotation = rHome'; 


}

 

 

 

 

profile

it leader

@dev__pixui

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!