1

代替テキスト
(ソース: flickr.com )

みなさん、こんにちは:)今日は、基本的にボタンのロールオーバーに単純なグロー効果を作成しようとしています。私は物事を複雑にしすぎているかもしれませんが、これについて私が行っている方法は、2 つの movieClips (デフォルト状態とオーバー状態) を持つことです。

最初にデフォルト状態をステージに追加し、次にロールオーバー状態をステージに追加しますが、深度は 0 で、アルファも 0 に設定します。ここで、rollOver 状態の深度をデフォルト状態と交換し、TweetLite クラスを使用して完全なアルファまでアニメートするようにしたいので、スムーズな遷移が得られます。

現在エラーが発生していますが、私のコードは次のとおりです。

import gs.TweenLite;
import fl.motion.easing.*;
import flash.display.MovieClip;


var shopButton:MovieClip;
var shopButtonRoll:MovieClip;
var maxIndex:Number = this.numChildren - 1;

// Button - places the default state onto the stage
shopButton = new ShopButton();
shopButton.name = "shopButton";
shopButton.x = 262;
shopButton.y = 207;
shopButton.stop();
thumbsMov.addChild(shopButton);

// Button Glow - places rollOver state under the default and with 0 alpha
shopButtonRoll = new ShopButtonRoll();
shopButtonRoll.name = "shopButtonRoll";
shopButtonRoll.x = 262;
shopButtonRoll.y = 207;
shopButtonRoll.alpha = 0;
thumbsMov.addChildAt(shopButtonRoll, 0);

// Listeners

shopButton.addEventListener(MouseEvent.MOUSE_UP, shopClick);
shopButton.addEventListener(MouseEvent.ROLL_OVER, sendToTop);
shopButton.addEventListener(MouseEvent.ROLL_OUT, shopOff);
shopButtonRoll.addEventListener(MouseEvent.ROLL_OVER, shopOver);

// Button Actions 
// shopOver should bring rollOver to top and animate to 100%

function shopOver(event:MouseEvent):void
{
     TweenLite.to(shopButtonRoll, 1, {alpha:1});
}
function shopOff(event:MouseEvent):void
{
     // Code to animate back to 0 then change depth of rollOver to 0
}
function shopClick(event:MouseEvent):void
}
     trace("You clicked Shop");
}

// sendToTop Function
// Sent to top - depth change
function sendToTop(e:Event):void
{
     //this.setChildIndex(ShopButton(e.target), maxIndex);
     this.setChildIndex(e.currentTarget as MovieClip, maxIndex);
}

ロールオーバーで発生するエラー:(

ArgumentError: エラー #2025: 指定された DisplayObject は呼び出し元の子でなければなりません。flash.display::DisplayObjectContainer/setChildIndex() で test_fla::MainTimeline/sendToTop() で

提供された DisplayObject が呼び出し元の子でなければならないというエラーの意味がわかりません。

4

1 に答える 1

1

達成しようとしていることに基づいて、深さを管理する必要はありません。基本的に、shopButton 内にロールオーバー エフェクトを追加し、shopButton をロールオーバーすると、グローをアニメーション化できます。私はあなたのコードを次のように更新しました:

import gs.TweenLite;
import fl.motion.easing.*;
import flash.display.MovieClip;


var shopButton:MovieClip;
var shopButtonRoll:MovieClip;

// Button - places the default state onto the stage
shopButton = new ShopButton();
shopButton.name = "shopButton";
shopButton.x = 262;
shopButton.y = 207;
shopButton.stop();
thumbsMov.addChild(shopButton);

// Button Glow - places rollOver state under the default and with 0 alpha
shopButtonRoll = new ShopButtonRoll();
shopButtonRoll.name = "shopButtonRoll";
shopButtonRoll.alpha = 0;
shopButton.addChild(shopButtonRoll);


// Listeners
shopButton.buttonMode = true;
shopButton.addEventListener(MouseEvent.MOUSE_UP, shopClick);
shopButton.addEventListener(MouseEvent.ROLL_OVER, shopOver);
shopButton.addEventListener(MouseEvent.ROLL_OUT, shopOff);

// Button Actions 
// shopOver should bring rollOver to top and animate to 100%

function shopOver(event:MouseEvent):void
{
     TweenLite.to(shopButtonRoll, 1, {alpha:1});
}
function shopOff(event:MouseEvent):void
{
    TweenLite.to(shopButtonRoll, 1, {alpha:0});
     // Code to animate back to 0 then change depth of rollOver to 0
}
function shopClick(event:MouseEvent):void
}
     trace("You clicked Shop");
}
于 2009-09-10T17:08:38.553 に答える