다음 문제/버그가 있습니다 :버튼이 작동하지 않습니다.
버튼이 정의 된 사용자 정의 버튼 클래스 (CustomBlitButton)를 만들었습니다. 버튼의 롤 오버 상태는 CustomScreen 클래스 내부에서 정의됩니다. 이는 사용자 정의 화면에 하나 이상의 버튼이 있기 때문입니다. CustomScreen 클래스의 createButton 함수를 사용할 때 버튼을 만들 수 있습니다.
그래서 즉, 메뉴, 여러 버튼을 화면을 만들고 싶어 나는 (이것은 단지 발췌 한 것입니다) 그런 다음을 수행하십시오!
private var buttonOff:ButtonOff = new ButtonOff(0, 0);
private var buttonOver:ButtonOver = new ButtonOver(0, 0);
private var buttonOff2:ButtonOff = new ButtonOff(0, 0);
private var buttonOver2:ButtonOver = new ButtonOver(0, 0);
private var creditsButton:CustomBlitButton;
private var settingsButton:CustomBlitButton;
titleScreen = new CustomScreen(FrameWorkStates.STATE_SYSTEM_TITLE, stageWidth, stageHeight, 0, 0, testPic,
false, 0x000000);
titleScreen.createButton(creditsButton, buttonOff, buttonOver, "Credits", new Point(centerX - 50, stageHeight/2 + 25), 100, 20,
screenButtonFormat, 2);
titleScreen.createButton(settingsButton, buttonOff2, buttonOver2, "Settings", new Point(centerX - 50, stageHeight/2 + 50), 100, 20,
screenButtonFormat, 2);
그러나 그것은 작동하지 않습니다 :(화면에 표시 몇 개의 버튼과 각 버튼에는 고유 한 eventListener가 있지만 마우스로 움직이면 마지막으로 만든 버튼 만 색을 바꿉니다. 다른 버튼은 마우스로 움직일 때 색상이 변하지 않습니다.
, 누군가가이 문제로 나를 도울 수 있습니까? 감사합니다. :)
사용자 정의 단추의 롤오버 상태가있는 사용자 정의 화면이 정의되는 코드입니다.
package com.framework_mod.src
{
import flash.display.*;
import flash.text.*;
public class CustomBlitButton extends Sprite
{
public static const OFF:int = 1;
public static const OVER:int = 2;
private var offBackGroundBD:BitmapData;
private var overBackGroundBD:BitmapData;
private var imageBg:BitmapData;
private var positionOffset:Number;
private var tempText:TextField = new TextField();
private var buttonBackGroundBitmap:Bitmap;
private var buttonTextBitmapData:BitmapData;
private var buttonTextBitmap:Bitmap;
public function CustomBlitButton(imageOff:BitmapData, imageOver:BitmapData, x:Number, y:Number, width:Number,
height:Number, text:String, textformat:TextFormat, positionOffset:Number = 0)
{
this.positionOffset = positionOffset;
this.x = x;
this.y = y;
offBackGroundBD = imageOff;
overBackGroundBD = imageOver;
buttonBackGroundBitmap = new Bitmap(offBackGroundBD);
tempText.embedFonts = true;
tempText.blendMode = BlendMode.LAYER;
tempText.autoSize = TextFieldAutoSize.LEFT;
tempText.defaultTextFormat = textformat;
tempText.selectable = false;
tempText.setTextFormat(textformat);
tempText.text = text;
buttonTextBitmapData = new BitmapData(tempText.textWidth + positionOffset, tempText.textHeight
+ positionOffset,true,0x00000000);
buttonTextBitmapData.draw(tempText);
buttonTextBitmap = new Bitmap(buttonTextBitmapData);
buttonTextBitmap.x = ((buttonBackGroundBitmap.width - int(tempText.textWidth))/2)-positionOffset;
buttonTextBitmap.y = ((buttonBackGroundBitmap.height - int(tempText.textHeight))/2)-positionOffset;
addChild(buttonBackGroundBitmap);
addChild(buttonTextBitmap);
this.buttonMode = true;
this.mouseChildren = false;
this.useHandCursor = true;
}
public function changeBackGroundColor(typeval:int):void
{
if (typeval == CustomBlitButton.OFF)
{
buttonBackGroundBitmap.bitmapData = offBackGroundBD;
}
else
{
buttonBackGroundBitmap.bitmapData = overBackGroundBD;
}
}
}
}
내가 여기에 누군가가 코드 및 디버그 위에 갈 의향이 될 것입니다 의심한다. 숙제를해야합니다 :). 문제를 찾을 수 없지만 범위를 좁힐 수 있어야합니다. 간단한 구성으로 몇 가지 테스트를 수행하고 작동하는 기본 상황을 얻은 다음 중단 될 때까지 추가하십시오. 희망이 도움이됩니다. – PatrickS
믿거 나 말거나, 코드가 많아도 도움이되는 사람도 있습니다. 그리고 이것은 많은 코드가 아닙니다. 어떤 사람들은 당신이 거의 코드를 게시하지 않을 때 불평하고 어떤 사람들은 그것이 "너무 많이"라고 불평을합니다. 항상 오래된 이야기입니다. – drpelz
나는 혼자서 문제를 해결하려고 노력할 것이다. 어쨌든 고마워. – drpelz