flash on 2009-5-22
import As.*;
import flash.filters.DropShadowFilter;
import flash.display.MovieClip;
import flash.utils.*;
/**
* Copyright muu ( http://wonderfl.net/user/muu )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/7Dnh
*/
package{
import flash.display.Sprite;
import flash.text.TextField;
//import As.*;
//import flash.filters.DropShadowFilter;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.*;
//import flash.display.MovieClip;
import flash.utils.setInterval;
import flash.utils.Timer;
import flash.events.TimerEvent;
//import flash.utils.*;
import flash.geom.Point;
public class Main extends Sprite {
public function Main() {
//**********************************************************
//初期設定
//**********************************************************
stage.scaleMode = StageScaleMode.NO_SCALE; //スケールモード変更
stage.align = StageAlign.TOP_LEFT; //座標基準を左上に
var cnt:int = 5; //最大MC数
var w : int = stage.stageWidth;
var h : int = stage.stageHeight
var sp:int = 5;
var mm:Array = new Array();
var xx:Array = new Array();
var cc:Array = new Array();
cc[0] = "0xaa2233";
cc[1] = "0xaa5566";
cc[2] = "0xaa7788";
cc[3] = "0xaa99aa";
cc[4] = "0xaabbcc";
//メインMC生成----------------------------------------------
var base:Sprite = new Sprite();
stage.addChild(base);
base.addEventListener(MouseEvent.ROLL_OUT , mcOut);
for(var i:int = 0 ; i < cnt ; i++){
var mc:Sprite = new Sprite();
mm[i] = mc;
base.addChild(mm[i]);
mm[i].y = 100;
mm[i].graphics.beginFill(cc[i]);
mm[i].graphics.drawRect(0, 0, 400, 200);
mm[i].graphics.endFill();
mm[i].addEventListener(MouseEvent.ROLL_OVER , mcOn);
xx[i] = i*100;
}
//--------------------------------------------------------
function mcOn(event:Event):void {
if (event.target == mm[0]){
xx[1] = 350;
xx[2] = 380;
xx[3] = 410;
xx[4] = 440;
}else
if (event.target == mm[1]){
xx[1] = 30;
xx[2] = 380;
xx[3] = 410;
xx[4] = 440;
}else
if (event.target == mm[2]){
xx[1] = 30;
xx[2] = 60;
xx[3] = 410;
xx[4] = 440;
}else
if (event.target == mm[3]){
xx[1] = 30;
xx[2] = 60;
xx[3] = 90;
xx[4] = 440;
}else
if (event.target == mm[4]){
xx[1] = 30;
xx[2] = 60;
xx[3] = 90;
xx[4] = 120;
}
}
function mcOut(event:Event):void {
for(var i:int = 0 ; i < cnt ; i++){
xx[i] = i*100;
}
}
base.addEventListener(Event.ENTER_FRAME , function():void{
for(var i:int = 0 ; i < cnt ; i++){
moveMc(mm[i], xx[i]);
}
});
function moveMc(mc:Sprite , tx:int):void{
if ( (Math.round(mc.x) !== tx) ){
mc.x += (tx - mc.x) / sp;
}
}
}
}
}