본문 바로가기
  • 오직 예수 그리스도
스위시세상/스위시 고급

스크립트 좌표이동과 마스크 갤러리

by 어린양01 2015. 4. 28.

http://cafe.daum.net/gs1236/DsEW/1617 

 

 

 

 

스크립트 좌표이동과 마스크 갤러리

1. 이미지 20장을 720X540으로 만들어 Content로 모두 불러와 작업
   창으로 모두 불러온다 이름을 a1~a20으로하고 모두선택 Target에
   체크하고 O=X 좌상 X=0 Y=0으로하고 모두선택 무비클립으로 묶
   고 이름 aa로 O=X 좌상 X=0 Y=0에놓고

2. aa복사하여 붙여넣고 ungroup하고 이름을 b1~b20으로 하고 모
   두선택 Target에 체크 됐는지 확인하고 W=30 H=20, O=X 좌상
   X=150 Y=477로 하고 무비클립으로 묶고 이름 btn으로하고 O=X
   좌상 X=150 Y=477로

3. mc불러와 O=X Center X=360 Y=270으로 놓고 다시 좌상에 놓고

4. T툴 클릭하고 글씨체=Arial black, 크기=16, 색=임의, B,로하고
   Dynamic선택하고 T툴 선택 된 채로 사각그려 Wrap text atword
   breaks, 체크 autosize height체크 Width=77.85로, 이름 ls로
   Target에 체크하고 O=X좌상 X=0 Y=0에 놓고

5. Scene_1선택 Rectangle Tool로 사각그려 라인=none Fill color=
   solid, W=720 H=540, O=X Center X=360 Y=270으로하고 이름
   mask로하고 Target에 체크하고 맨 아래로 내려주고 스크립트준다

 

 

 

Scene_1

// 바둑판배열 (x6 * y5 = 30)
function initImg(IMG) {
    mW = _root.mask._width;
    mH = _root.mask._height;
    zX = _root.aa._x;
    zY = _root.aa._y;
    for(var y = 1; y <= 2; y++) {
        for(var x = 1; x <= 10; x++) {
            aK = aa["a"+k];
            aK._x = mW * (x - 1);
            aK._y = mH * (y - 1);
            aK.initX = aK._x - zX;
            aK.initY = aK._y - zY;
            k++;
        }       
    }       
}
// 버튼배열
function initBtn(BTN) {
    mW = 43;
    mH = 28;
    for(var i = 1; i <= 10; i++) {
        aK = _root.btn["b"+i];
        aK._x = mW * (i - 1);
        aK._y = mH * 0;
    }
    for(var i = 11; i <= 20; i++) {
        aK = _root.btn["b"+i];
        aK._x = mW * (i - 11);
        aK._y = mH * 1;
    }       
}
// 버튼활성화 제어
function enaBtn(BTN){
    for(var i = 1; i <= tot; i++) {
        _root.btn["b"+i].enabled = 1;   
    }
    BTN.enabled = 0;
}
// 1~9 한자리숫자는 앞에 + 0 추가
function checkDigits(toCheck) {
    return (toCheck < 10 ? (toCheck = "0" + toCheck) : (toCheck));
}
// prev, next의 조건지정
function goBtn(btn) {
    gotoAndPlay(1);
    galleryBtn = btn;
    galleryBtn == "next" ? (_root.view == tot ? _root.view = 1 : (_root.view = random(tot-1)+1)) : null; //자동=랜덤
    _root.enaBtn(this);
    _root.aa["a"+_root.view].setMask(_root.mc);
    _root["mc"].play();
    _root.aa.onEnterFrame = function() {
        this.SlowDown();// 부드러운움직임 적용하기
    }
}
onSelfEvent(load) {   
    var tot = 20
    var k = 1;
    galleryBtn = "next";
    _root.aa.setMask(_root.mask);
   
    initBtn(this.btn); // 버튼의배열 적용하기
    initImg(this.aa);  // 이미지배열 적용하기
    _root.aa._x = _root.aa["a" + tot].initX;
    _root.aa._y = _root.aa["a" + tot].initY;
   
    _root.view = 1;
    _root.aa["a"+_root.view].setMask(_root.mc);
   
    // 부드러운움직임 제어
    MovieClip.prototype.SlowDown = function() {
        aN = this["a"+_root.view];   
        this._x+=((-aN.initX) - this._x) * 0.2;
        this._y+=((-aN.initY) - this._y) * 0.2;
        if(Math.abs((-aN.initX) - this._x) <= 0.7 && Math.abs((-aN.initY) - this._y) <= 0.7){
            delete this.onEnterFrame;
            this._x =- aN.initX;
            this._y =- aN.initY;           
        }   
                  
    }   
    _root.aa.onEnterFrame = function() {
        this.SlowDown(); // 부드러운움직임 적용하기
    }
}
onSelfEvent (enterFrame) {
    // 버튼제어
    for(var i = 1; i <= tot; i++) {
         _root.btn["b" + i].onRelease = function() {
             _root.view = this._name.slice(1);
             _root.enaBtn(this);
             _root.aa["a" + _root.view].setMask(_root.mc);
             _root["mc"].play();
             _root.gotoAndPlay(1);
            _root.aa.onEnterFrame = function() {
                this.SlowDown();
            }
        }
        Df= new flash.filters.DropShadowFilter(5,45,0x000000,0.50,6,6,1.5,2,false,false,false);
          _root.btn.filters = _root.aa.filters =[Df]; // 그림자필터 적용하기

    }
    // 색인번호 위치및 제어 (좌상 = x10, y10)
    ls._x = 10;
    ls._y = 10;
    ls.text = checkDigits(_root.view) + "/" + checkDigits(tot);
}

// 자동 100프레임
onFrame (100) {
    goBtn(galleryBtn);
}

 

 

 

스크립트 좌표이동과 마스크 갤러리.zip

 

mc.swf

f

 

 

 
mc.swf
0.16MB
스크립트 좌표이동과 마스크 갤러리.zip
6.45MB

'스위시세상 > 스위시 고급' 카테고리의 다른 글

Break & Poem Gallery   (0) 2015.04.28
스크립트 버튼 갤러리  (0) 2015.04.28
Star Button Gallery  (0) 2015.04.28
Button Script Gallery  (0) 2015.04.28
flatten Flat in-Gallery  (0) 2015.04.28