Menu

 

 

이번에는 이미지 대신 글자로..
아래것과 액션스크립트도 다릅니다.


 

 

 

mousetrailer-2에 들어가는 액션
---------------------------------------------------------
Scene_1
-------
onFrame (4,afterPlacedObjectEvents) {
    startDragUnlocked("char0");
    _root.control1.gotoAndPlay(2);
}
onFrame (6,afterPlacedObjectEvents) {
    stop();
    //gotoAndPlay(5);
}
onEnterFrame(includingFirstFrame) {
    char0._x= _xmouse+12;
    char0._y= _ymouse+22;
    //       startDragUnlocked("char0");
    //   control1.gotoAndPlay(2);
}

------------------------------------------------------
calc1
----------
onFrame (1,afterPlacedObjectEvents) {
    tan = "0";
    stop();
    targetx=0;
    targety = 0;
    x=1;
    y=1;
}
onFrame (3,afterPlacedObjectEvents) {
    setLabel("init");
    if (Number(x)>Number(targetx)) {
        if (Number(y)<Number(targety)) {
            // quadrant1
            gegenkathete = x-targetx;
            ankathete = targety-y;
            baseangle = 0;
        } else {
            // quadrant4
            gegenkathete = y-targety;
            ankathete = x-targetx;
            baseangle = 90;
        }
    } else {
        if (Number(y)<Number(targety)) {
            // quadrant2
            gegenkathete = targety-y;
            ankathete = targetx-x;
            baseangle = 270;
        } else {
            // quadrant3
            gegenkathete = targetx-x;
            ankathete = y-targety;
            baseangle = 180;
        }
    }
    tan = gegenkathete/ankathete;
    // stop();
}
onFrame (5,afterPlacedObjectEvents) {
    setLabel("tan_to_angle");
    if (Number(tan)>1) {
        if (Number(tan)>2.41) {
            if (Number(tan)>5.03) {
                if (Number(tan)>10.15) {
                    angle = 90;
                } else {
                    angle = 84.375;
                }
            } else {
                if (Number(tan)>3.3) {
                    angle = 78.75;
                } else {
                    angle = 73;
                }
            }
        } else {
            if (Number(tan)>1.496) {
                if (Number(tan)>1.87) {
                    angle = 67.5;
                } else {
                    angle = 61.875;
                }
            } else {
                if (Number(tan)>1.22) {
                    angle = 56.25;
                } else {
                    angle = 50.625;
                }
            }
        }
        // ****** end of left branch
    } else {
        if (Number(tan)>0.41) {
            if (Number(tan)>0.67) {
                if (Number(tan)>0.82) {
                    angle = 45;
                } else {
                    angle = 39.375;
                }
            } else {
                if (Number(tan)>0.534) {
                    angle = 33.75;
                } else {
                    angle = 28.125;
                }
            }
        } else {
            if (Number(tan)>0.198) {
                if (Number(tan)>0.3) {
                    angle = 22.5;
                } else {
                    angle = 16.875;
                }
            } else {
                if (Number(tan)>0.098) {
                    angle = 11.25;
                } else {
                    angle = 5.625;
                }
            }
        }
        // ****** end of right branch
    }
    angle = Number(angle)+Number(baseangle)-180;
    stop();
}

-------------------------------------------------------------
control1
----------
onFrame (1,afterPlacedObjectEvents) {
    stop();
}
onFrame (2,afterPlacedObjectEvents) {
    // this frame is for init stuff (only called once)
    n = 8;
    Xacc = 4.1;
    Yacc = 4.0;
    Xswing = 1.9;
    Yswing = 1.80;
    loop = 1;
    while (Number(loop)<=Number(n)) {
        set("/char" add loop add ":deltax", 0);
        set("/char" add loop add ":deltay", 0);
        loop = Number(loop)+1;
    }
    loop = 0;
    while (Number(loop)<=Number(n)) {
        setProperty("/char" add loop, _X, _xmouse + (Number(loop) * 12) );
        setProperty("/char" add loop, _Y, _ymouse );
        loop = Number(loop)+1;
    }
    loop = 0;
    while (Number(loop)<=Number(n)) {
        set("/char" add loop add ":Xpos", getProperty ("/char" add loop,_x));
        set("/char" add loop add ":Ypos", getProperty ("/char" add loop,_y));
        loop = Number(loop)+1;
    }
    loop = 1;
    while (Number(loop)<=Number(n)) {
        set("/char" add loop add ":hor_dist", (eval("/char" add loop add ":Xpos"))-eval("/char" add (loop-1) add ":Xpos"));
        set("/char" add loop add ":vert_dist", (eval("/char" add loop add ":Ypos"))-eval("/char" add (loop-1) add ":Ypos"));
        loop = Number(loop)+1;
    }
}
onFrame (3,afterPlacedObjectEvents) {
    "/char0:Xpos" = getProperty("/char0", _x);
    "/char0:Ypos" = getProperty("/char0", _y);
    loop = 1;
    while (Number(loop)<=Number(n)) {
        set("/char" add loop add ":deltax", ((eval("/char" add loop add ":hor_dist") - eval("/char" add loop add ":Xpos") + eval("/char" add (loop-1) add ":Xpos"))/Xacc + eval("/char" add loop add ":deltax"))/Xswing);
        set("/char" add loop add ":deltay", (eval("/char" add loop add ":vert_dist") + eval("/char" add (loop-1) add ":Ypos") - eval("/char" add loop add ":Ypos"))/Yacc + (eval("/char" add loop add ":deltay"))/Yswing);
        set("/char" add loop add ":Xpos", eval("/char" add loop add ":Xpos")+eval("/char" add loop add ":deltax"));
        set("/char" add loop add ":Ypos", eval("/char" add loop add ":Ypos")+eval("/char" add loop add ":deltay"));
        loop = Number(loop)+1;
    }
    // capture new 'mouse positions'
    "/char0:Xpos" = getProperty("/char0", _x);
    "/char0:Ypos" = getProperty("/char0", _y);
    loop = 1;
    while (Number(loop)<=Number(n)) {
        // calculate tangens and angle
        set("/calc1:x",  eval("/char" add (loop-1) add ":Xpos"));
        set("/calc1:y",  eval("/char" add (loop-1) add ":Ypos"));
        set("/calc1:targetx",  eval("/char" add loop add ":Xpos"));
        set("/calc1:targety",  eval("/char" add loop add ":Ypos"));
        call("/calc1:init");
        call("/calc1:tan_to_angle");
        // avoid mc flipping
        if (eval("/char" add loop add ":deltay") > -.05  and eval("/char" add loop add ":deltay") < .05) {
            _root.calc1.angle = 90;
        }
        // Set new properties for each mc
        setProperty("/char" add loop, _x, eval("/char" add loop add ":Xpos"));
        setProperty("/char" add loop, _y, eval("/char" add loop add ":Ypos"));
        setProperty("/char" add loop, _rotation, eval("/calc1:angle")-90);
        //setProperty("/char" add loop, _xscale, 100);
        //setProperty("/char" add loop, _yscale, 100);
        loop = Number(loop)+1;
    }
}
onFrame (4,afterPlacedObjectEvents) {
    gotoAndPlay(3);
}


 

'Swish study' 카테고리의 다른 글

mask-slide  (0) 2016.05.26
마우스에서 벌레가..  (0) 2016.05.26
마우스를 따라다니는 물고기  (0) 2016.05.26
Random-Motion  (0) 2016.05.26
Image-revealer  (0) 2016.05.26