私は ActionScript3 と Flash の初心者です。ボタン インスタンス (upState、overState、および downState に関連する Up、Over、Down、および Clicked フレームがある) に他のフレームを追加して、同じメソッドで呼び出すことができるかどうかはわかります。
私はこのようなものが必要です:
if(...){
Button.upState = Button.MyOwnFrame;
}
前もって感謝します!
私は ActionScript3 と Flash の初心者です。ボタン インスタンス (upState、overState、および downState に関連する Up、Over、Down、および Clicked フレームがある) に他のフレームを追加して、同じメソッドで呼び出すことができるかどうかはわかります。
私はこのようなものが必要です:
if(...){
Button.upState = Button.MyOwnFrame;
}
前もって感謝します!
さまざまな状態、、、およびSimpleButton
に any を割り当てることができるので、クラスを調べることをお勧めします。DisplayObject
upState
overState
downState
hitTestState
Adobe の API リファレンスの例を次に示します。
package {
import flash.display.Sprite;
public class SimpleButtonExample extends Sprite {
public function SimpleButtonExample() {
var button:CustomSimpleButton = new CustomSimpleButton();
addChild(button);
}
}
}
import flash.display.DisplayObject;
import flash.display.Shape;
import flash.display.SimpleButton;
class CustomSimpleButton extends SimpleButton {
private var upColor:uint = 0xFFCC00;
private var overColor:uint = 0xCCFF00;
private var downColor:uint = 0x00CCFF;
private var size:uint = 80;
public function CustomSimpleButton() {
downState = new ButtonDisplayState(downColor, size);
overState = new ButtonDisplayState(overColor, size);
upState = new ButtonDisplayState(upColor, size);
hitTestState = new ButtonDisplayState(upColor, size * 2);
hitTestState.x = -(size / 4);
hitTestState.y = hitTestState.x;
useHandCursor = true;
}
}
class ButtonDisplayState extends Shape {
private var bgColor:uint;
private var size:uint;
public function ButtonDisplayState(bgColor:uint, size:uint) {
this.bgColor = bgColor;
this.size = size;
draw();
}
private function draw():void {
graphics.beginFill(bgColor);
graphics.drawRect(0, 0, size, size);
graphics.endFill();
}
}