//reset 시에 사용할, 초기값 설정
var raX:Number = rabit_mc.x;
var raY:Number = rabit_mc.y;
var ro:Number = rabit_mc.rotation;
x1_btn.addEventListener(MouseEvent.CLICK, onX1);
function onX1(e:MouseEvent):void{
//화면안에서만 이동하게끔 if문을 사용해 범위를 지정
if(rabit_mc.x <519){
rabit_mc.x += 10;
}
// rabit무비의 x값이 x_txt 텍스트 필드에 도출된다.
//toFixed ==> 소수점 1자리까지만 기재된다.
x_txt.text = String(rabit_mc.x.toFixed(1));
}
x2_btn.addEventListener(MouseEvent.CLICK, onX2);
function onX2(e:MouseEvent):void{
if(rabit_mc.x > 30){
rabit_mc.x -= 10;
}
x_txt.text = String(rabit_mc.x.toFixed(1));
}
y1_btn.addEventListener(MouseEvent.CLICK, onY1);
function onY1 (e:MouseEvent):void{
if(rabit_mc.y <340){
rabit_mc.y += 10;
}
y_txt.text = String(rabit_mc.y.toFixed(1));
}
y2_btn.addEventListener(MouseEvent.CLICK, onY2);
function onY2 (e:MouseEvent):void{
if(rabit_mc.y > 128){
rabit_mc.y -= 10;
}
y_txt.text = String(rabit_mc.y.toFixed(1));
}
alpha1_btn.addEventListener(MouseEvent.CLICK, onAlpha1);
function onAlpha1 (e:MouseEvent):void{
rabit_mc.alpha += 0.1;
alpha_txt.text = String(rabit_mc.alpha.toFixed(1));
}
alpha2_btn.addEventListener(MouseEvent.CLICK, onAlpha2);
function onAlpha2 (e:MouseEvent):void{
if(rabit_mc.alpha > 0.1){
rabit_mc.alpha -= 0.1;
}
alpha_txt.text = String(rabit_mc.alpha.toFixed(1));
}
scaleX1_btn.addEventListener(MouseEvent.CLICK, onScaleX1);
function onScaleX1 (e:MouseEvent):void{
rabit_mc.scaleX += 0.1;
scaleX_txt.text = String(rabit_mc.scaleX.toFixed(1));
}
scaleX2_btn.addEventListener(MouseEvent.CLICK, onScaleX2);
function onScaleX2 (e:MouseEvent):void{
if(rabit_mc.scaleX > 0.1){
rabit_mc.scaleX -= 0.1;
}
scaleX_txt.text = String(rabit_mc.scaleX.toFixed(1));
}
scaleY1_btn.addEventListener(MouseEvent.CLICK, onScaleY1);
function onScaleY1 (e:MouseEvent):void{
rabit_mc.scaleY += 0.1;
scaleY_txt.text = String(rabit_mc.scaleY.toFixed(1));
}
scaleY2_btn.addEventListener(MouseEvent.CLICK, onScaleY2);
function onScaleY2 (e:MouseEvent):void{
if(rabit_mc.scaleY > 0.1){
rabit_mc.scaleY -= 0.1;
}
scaleY_txt.text = String(rabit_mc.scaleY.toFixed(1));
}
rotation1_btn.addEventListener(MouseEvent.CLICK, onRotation1);
function onRotation1 (e:MouseEvent):void{
rabit_mc.rotation += 2;
rotation_txt.text = String(rabit_mc.rotation.toFixed(1));
}
rotation2_btn.addEventListener(MouseEvent.CLICK, onRotation2);
function onRotation2 (e:MouseEvent):void{
rabit_mc.rotation -= 2;
rotation_txt.text = String(rabit_mc.rotation.toFixed(1));
}
reset_btn.addEventListener(MouseEvent.CLICK, onReset);
function onReset (e:MouseEvent):void{
rabit_mc.x = raX;
rabit_mc.y = raY;
rabit_mc.alpha = 1;
rabit_mc.scaleX = 1;
rabit_mc.scaleY = 1;
rabit_mc.rotation = ro;
}
3강. ENTER_FRAME, hasEventListener, removeEventListener (0) | 2010.12.27 |
---|---|
3강. 마우스 & 키보드 이벤트 적용하기 (0) | 2010.12.27 |
2강. 속성값 적용하기 (0) | 2010.12.27 |
2강. Gallery (0) | 2010.12.27 |
2강. addEventListener (0) | 2010.12.24 |