編集
あなたの.flaを見た後、ここに欠けている/置き忘れられているものがあります:
フラッシュのレイヤーは、zオーダー/深度以外の意味ではありません。コードでレイヤーを操作することはできません。すべてのアニメーションは同じタイムライン上にあるため、常に一緒に再生されます。個々のアイテムを他のアイテムなしでアニメーション化する場合は、(レイヤーだけでなく)独自のタイムラインでアニメーションを作成する必要があります。あなたはそれをダブルクリックすることによってあなたのシンボル自身のタイムラインにアクセスします-そこであなたのアニメーションをしてください。
ステージ上にあるアイテムを参照するには、それらにインスタンス名を付ける必要があります。これを行うには、ステージ上にあるアイテムをクリックします。次に、プロパティパネルに、インスタンス名を入力できるフィールドがあります。以下のコードを機能させるには、それぞれ「a」、「b」、「c」、「d」、「e」のインスタンス名を付ける必要があります。これは、ライブラリのシンボル名とは異なります(同じ名前でもかまいません)。
これを行う1つの方法:
var btns:Vector.<MovieClip> = new Vector.<MovieClip>(); //create an array of all your buttons
btns.push(a,b,c,d,e); //add your buttons to the array
for each(var btn:MovieClip in btns){
btn.addEventListener(MouseEvent.MOUSE_OVER, btnMouseOver); // listen for mouse over on each of the buttons
btn.addEventListener(MouseEvent.MOUSE_OUT, btnMouseOut);
}
function btnMouseOver(e:Event):void {
for each(var btn:MovieClip in btns){ //loop through all your buttons
if(btn != e.currentTarget){ //if the current one in the loop isn't the one that was clicked
btn.play();
try{
btn.removeEventListener(Event.ENTER_FRAME,moveBackwards); //this will stop the backwards animation if running. it's in a try block because it will error if not running
}catch(err:Error){};
}
}
}
function btnMouseOut(e:Event):void {
for each(var btn:MovieClip in btns){ //loop through all your buttons
if(btn != e.currentTarget){ //if the current one in the loop isn't the one that was clicked
goBackwards(btn);
}
}
}
タイムラインを逆方向に再生する良い方法はありませんが、それを行う方法はあります。そのような方法の1つ:
//a function you can call and pass in the item/timeline you want played backwards
function goBackwards(item:MovieClip):void {
item.stop(); //make sure the item isn't playing before starting frame handler below
item.addEventListener(Event.ENTER_FRAME, moveBackwards); //add a frame handler that will run the moveBackwards function once every frame
}
//this function will move something one frame back everytime it's called
function moveBackwards(e:Event):void {
var m:MovieClip = e.currentTarget as MovieClip; //get the movie clip that fired the event
if(m.currentFrame > 1){ //check to see if it's already back to the start
m.prevFrame(); //if not move it one frame back
}else{
m.removeEventListener(Event.ENTER_FRAME,moveBackwards); //if it is (at the start), remove the enter frame listener so this function doesn't run anymore
}
}