stage.addEventListener(MouseEvent.MOUSE_DOWN,makeObj);
function makeObj(e:MouseEvent):void {
var obj_mc:Obj=new Obj();
obj_mc.x=e.stageX;
obj_mc.y=e.stageY;
var scale:Number=0.8+3*Math.random();
obj_mc.scaleX=obj_mc.scaleY=scale;
addChild(obj_mc);
}
A LIFE LESS ORDINARY BOY
2010年7月7日水曜日
クリックすると丸が100px右に移動する
maru1.addEventListener(MouseEvent.CLICK,move);
function move(e:MouseEvent):void {
maru1.x+=100;
}
function move(e:MouseEvent):void {
maru1.x+=100;
}
2010年6月30日水曜日
6/30 ボールが跳ね返る方法
ball1.addEventListener(MouseEvent.CLICK, gourl);
function gourl(e:MouseEvent):void {
var url:String = "http://www.google.co.jp";
var urlReq:URLRequest = new URLRequest(url);
navigateToURL(urlReq, "_blank");
}
ball2.addEventListener(MouseEvent.ROLL_OVER, onRollover);
ball2.addEventListener(MouseEvent.ROLL_OUT, onRollout);
function onRollover(e:MouseEvent):void {
var target_mc:MovieClip = e.target as MovieClip;
target_mc.scaleX=target_mc.scaleY=2.0;
}
function onRollout(e:MouseEvent):void {
var target_mc:MovieClip = e.target as MovieClip;
target_mc.scaleX=target_mc.scaleY=1.0;
}
ball1.speedX=3+Math.random()*5;
ball2.speedX=3+Math.random()*5;
ball3.speedX=3+Math.random()*5;
ball1.speedY=3+Math.random()*5;
ball2.speedY=3+Math.random()*5;
ball3.speedY=3+Math.random()*5;
ball1.scaleX=ball1.scaleY = 0.6+Math.random() * 0.3;
ball2.scaleX=ball2.scaleY = 0.6+Math.random() * 0.3;
ball3.scaleX=ball3.scaleY = 0.6+Math.random() * 0.3;
ball1.addEventListener(Event.ENTER_FRAME, onEnterframe);
ball2.addEventListener(Event.ENTER_FRAME, onEnterframe);
ball3.addEventListener(Event.ENTER_FRAME, onEnterframe);
function onEnterframe(e:Event):void {
var mc:MovieClip=e.target as MovieClip;
if (((mc.x-mc.width/2)<0)||((mc.x+mc.width/2)>stage.stageWidth)) {
mc.speedX*=-1;
}
function gourl(e:MouseEvent):void {
var url:String = "http://www.google.co.jp";
var urlReq:URLRequest = new URLRequest(url);
navigateToURL(urlReq, "_blank");
}
ball2.addEventListener(MouseEvent.ROLL_OVER, onRollover);
ball2.addEventListener(MouseEvent.ROLL_OUT, onRollout);
function onRollover(e:MouseEvent):void {
var target_mc:MovieClip = e.target as MovieClip;
target_mc.scaleX=target_mc.scaleY=2.0;
}
function onRollout(e:MouseEvent):void {
var target_mc:MovieClip = e.target as MovieClip;
target_mc.scaleX=target_mc.scaleY=1.0;
}
ball1.speedX=3+Math.random()*5;
ball2.speedX=3+Math.random()*5;
ball3.speedX=3+Math.random()*5;
ball1.speedY=3+Math.random()*5;
ball2.speedY=3+Math.random()*5;
ball3.speedY=3+Math.random()*5;
ball1.scaleX=ball1.scaleY = 0.6+Math.random() * 0.3;
ball2.scaleX=ball2.scaleY = 0.6+Math.random() * 0.3;
ball3.scaleX=ball3.scaleY = 0.6+Math.random() * 0.3;
ball1.addEventListener(Event.ENTER_FRAME, onEnterframe);
ball2.addEventListener(Event.ENTER_FRAME, onEnterframe);
ball3.addEventListener(Event.ENTER_FRAME, onEnterframe);
function onEnterframe(e:Event):void {
var mc:MovieClip=e.target as MovieClip;
if (((mc.x-mc.width/2)<0)||((mc.x+mc.width/2)>stage.stageWidth)) {
mc.speedX*=-1;
}
ball1.scaleX=ball1.scaleY = 0.6+Math.random() * 0.3;
ball2.scaleX=ball2.scaleY = 0.6+Math.random() * 0.3;
ball3.scaleX=ball3.scaleY = 0.6+Math.random() * 0.3;
ball1.addEventListener(Event.ENTER_FRAME, onEnterframe);
ball2.addEventListener(Event.ENTER_FRAME, onEnterframe);
ball3.addEventListener(Event.ENTER_FRAME, onEnterframe);
function onEnterframe(e:Event): void {
var mc:MovieClip = e.target as MovieClip;
if ((mc.y - mc.height/2)> stage.stageHeight){
mc.y =- mc.height/2;
}else {
mc.y+=mc.height * 0.2;
}
}
ball2.scaleX=ball2.scaleY = 0.6+Math.random() * 0.3;
ball3.scaleX=ball3.scaleY = 0.6+Math.random() * 0.3;
ball1.addEventListener(Event.ENTER_FRAME, onEnterframe);
ball2.addEventListener(Event.ENTER_FRAME, onEnterframe);
ball3.addEventListener(Event.ENTER_FRAME, onEnterframe);
function onEnterframe(e:Event): void {
var mc:MovieClip = e.target as MovieClip;
if ((mc.y - mc.height/2)> stage.stageHeight){
mc.y =- mc.height/2;
}else {
mc.y+=mc.height * 0.2;
}
}
2010年6月23日水曜日
ActionScript3.0-キーボードイベントで動くムービークリップ
IME.enabled = false;
stage.addEventListener(KeyboardEvent.KEY_DOWN, moveObj);
function moveObj(e:KeyboardEvent):void{
var d:uint= 10;
var dx:int;
var dy:int;
switch(e.keyCode){
case Keyboard.RIGHT:
dx = d;
break;
case Keyboard.LEFT:
dx=d*-1;
break;
case Keyboard.UP:
dy= d* -1;
break;
case Keyboard.DOWN:
dy=d;
break;
}
mc1.x += dx;
mc1.y += dy;
}
stage.addEventListener(KeyboardEvent.KEY_DOWN, moveObj);
function moveObj(e:KeyboardEvent):void{
var d:uint= 10;
var dx:int;
var dy:int;
switch(e.keyCode){
case Keyboard.RIGHT:
dx = d;
break;
case Keyboard.LEFT:
dx=d*-1;
break;
case Keyboard.UP:
dy= d* -1;
break;
case Keyboard.DOWN:
dy=d;
break;
}
mc1.x += dx;
mc1.y += dy;
}
登録:
投稿 (Atom)