>> 네비게이션1
var yTarget:Number = -300;
_mc.addEventListener(Event.ENTER_FRAME, onEnter);
function onEnter(e:Event):void{
//부드러운 움직임공식
//움직일 위치 = 현재위치 +(목표값 - 현재위치)*속도계수;
//시작하자마자 목표값으로 올라감
_mc.y = _mc.y + (yTarget - _mc.y)*0.2;
}
s_mc.addEventListener(MouseEvent.CLICK,onClick);
function onClick(e:MouseEvent):void{
if(s_mc.currentFrame ==1){
yTarget = 0;
s_mc.gotoAndStop(2);
}else{
yTarget = -300;
s_mc.gotoAndStop(1);
}
}
//--------------------------------------------------------------------------------------
>> 네비게이션 2
var xTarget:Number = -100;
var startX:Number = -180;
for(var i:int=0; i<2;i++){
this["m"+i].addEventListener(Event.ENTER_FRAME, onEnter);
}
function onEnter(e:Event):void{
for(var i:int=0;i<2;i++){
if(this["m"+i].hitTestPoint(mouseX,mouseY,true)){
this["m"+i].x += (xTarget - this["m"+i].x)*0.1;
}else{
this["m"+i].x +=(startX - this["m"+i].x)*0.1;
}
}
}
//--------------------------------------------------------------------------------------
>> 네비게이션 3
//타겟값
var yTarget:Number = 200;
back_mc.addEventListener(Event.ENTER_FRAME, onBack);
function onBack(e:Event):void{
if(back_mc.hitTestPoint(mouseX,mouseY,true)){
yTarget = 250;
}
}
_mc.addEventListener(Event.ENTER_FRAME, onEnter);
function onEnter(e:Event):void{
//부드러운움직임
_mc.y = _mc.y + ( yTarget- _mc.y)*0.2;
}
m0_btn.addEventListener(MouseEvent.ROLL_OVER, onOver0);
function onOver0(e:MouseEvent):void{
yTarget = 200;
m0_btn.gotoAndPlay(2);
}
m1_btn.addEventListener(MouseEvent.ROLL_OVER, onOver1);
function onOver1(e:MouseEvent):void{
yTarget = 165;
m1_btn.gotoAndPlay(2);
}
m2_btn.addEventListener(MouseEvent.ROLL_OVER, onOver2);
function onOver2(e:MouseEvent):void{
yTarget = 130;
m2_btn.gotoAndPlay(2);
}
m3_btn.addEventListener(MouseEvent.ROLL_OVER, onOver3);
function onOver3(e:MouseEvent):void{
yTarget = 95;
m2_btn.gotoAndPlay(2);
}
//-----------------------------------------------------------------------------------
>> 갤러리 1
var yTarget:Number = 480;
_mc.addEventListener(Event.ENTER_FRAME, onEnter);
function onEnter(e:Event):void{
_mc.y = _mc.y + (yTarget - _mc.y)*0.1;
}
for(var i:int =0;i<4;i++){
this["b"+i+"_btn"].no = i;
this["b"+i+"_btn"].addEventListener(MouseEvent.CLICK, onClick);
}
function onClick(e:MouseEvent):void{
var id:Number = e.currentTarget.no;
//trace(id);
yTarget = 480-120 * id;
}
//-------------------------------------------------------------------------------------
>>갤러리 2
//타겟값
var xTarget:Number = 0;
var yTarget:Number = 0;
_mc.addEventListener(Event.ENTER_FRAME, onEnter);
function onEnter(e:Event):void{
_mc.x = _mc.x + (xTarget - _mc.x)*0.2;
_mc.y = _mc.y + (yTarget - _mc.y)*0.2;
}
b0_btn.addEventListener(MouseEvent.CLICK, onClick);
function onClick(e:MouseEvent):void{
xTarget = 0;
yTarget = 0;
}
b1_btn.addEventListener(MouseEvent.CLICK, onClick1);
function onClick1(e:MouseEvent):void{
xTarget = -150;
yTarget = 0;
}
b2_btn.addEventListener(MouseEvent.CLICK, onClick2);
function onClick2(e:MouseEvent):void{
xTarget = -300;
yTarget = 0;
}
b3_btn.addEventListener(MouseEvent.CLICK,onClick3);
function onClick3(e:MouseEvent):void{
xTarget = 0;
yTarget = -100;
}
b4_btn.addEventListener(MouseEvent.CLICK,onClick4);
function onClick4(e:MouseEvent):void{
xTarget = -150;
yTarget = -100;
}
b5_btn.addEventListener(MouseEvent.CLICK,onClick5);
function onClick5(e:MouseEvent):void{
xTarget = -300;
yTarget = -100;
}
6강. 일차함수를 이용한 갤러리 (0) | 2011.01.13 |
---|---|
6강. 1차함수 예제 (0) | 2011.01.13 |
5강. 부드러운 움직임을 이용, 마우스 포인터 만들기 (0) | 2011.01.13 |
5강. 네비게이션 (0) | 2011.01.13 |
4강. 윈도우창 제어하기 (0) | 2010.12.27 |