[CS3] 컨텐츠 슬라이딩 내비게이션 수정 Flash&FLEX

contentsSliding_start(cs3).fla
contentsSliding_start(cs3).swf



var cnt:uint = 1;       // 메뉴 카운터
var pos_x;                      // 이동할 x좌표
var pos_y;                      // 이동할 y좌표

// 리스너
for(var yNum:uint=1; yNum<=2; yNum++)
{
        for(var xNum:uint=1; xNum<=2; xNum++)
        {
                this["mm"+cnt].menuNum = [xNum, yNum];
                this["mm"+cnt].addEventListener(MouseEvent.CLICK, clickHandler);
                cnt++;
        }
}

contentSet.addEventListener(Event.ENTER_FRAME, enterFrameHandler);

// 이벤트
function enterFrameHandler(event:Event)
{
        var obj = event.currentTarget;
        
        if(pos_x != null)
        {
                // 클릭 시에 저장된 좌표로 이동
                obj.mcMove(pos_x, pos_y, 0.3);
        }
}

function clickHandler(event:Event)
{
        var obj = event.currentTarget;
        // 버튼에 지정된 menuNum으로 부터 x, y 좌표값을 계산
        pos_x = 400 - (400 * obj.menuNum[0]) + 10
        pos_y = 200 - (200 * obj.menuNum[1]) + 80;
}

MovieClip.prototype.mcMove = function(tgX, tgY, speed)
{
        this.x += (tgX - this.x) * speed;
        this.y += (tgY - this.y) * speed;
}



* 소스는 '플래시 내비게이션 제작 테크닉'에서 발췌했습니다.

트랙백

이 글과 관련된 글 쓰기 (트랙백 보내기)
TrackbackURL : http://chez.egloos.com/tb/1838621 [도움말]

덧글

덧글 입력 영역