Draw Multiple Buttons
is possible use loop create 3 buttons on stage , add text them? have been working creates 1 button , not sure why. can help? ( have added button[j] of them , error when referenceerror: error #1069: property 1 not found on flash.display.sprite , there no default value.) thanks.
code ex.
function drawbuttons():void
{
var textlabel:textfield = new textfield();
for (var j:number = 1; j<4; j++)
{
button.graphics.clear();
button = new sprite();
button.graphics.beginfill(0x000000);
// purple color;
button.graphics.drawroundrect(0, 0, 80, 25, 10, 10);
// x, y, width, height, ellipsew, ellipseh;
button.graphics.endfill();
button.x = 725;
//button[j].y = 275;
this.addchild(button);
button.buttonmode = true;
button.usehandcursor = true;
button.mousechildren = false;
textlabel.textcolor = 0xffffff;
textlabel.x = 10;
textlabel.selectable = false;
textlabel.defaulttextformat = textformat;
this.button.addchild(textlabel);
if (j == 1)
{
trace(j);
button.y = 275;
textlabel.text = "a";
textlabel.y = 5;
//add answer button listner
button.addeventlistener(mouseevent.mouse_down, answera_mousedown);
}
if (j == 2)
{
trace(j);
button.y = 300;
textlabel.text = "b";
textlabel.y = 5;
//add answer button listner
button.addeventlistener(mouseevent.mouse_down, answerb_mousedown);
}
if (j == 3)
{
trace(j);
button.y = 325;
textlabel.text = "c";
textlabel.y = 5;
//add answer button listner
button.addeventlistener(mouseevent.mouse_down, answerc_mousedown);
}
}
}
remove clear(), make sure you're calling drawbuttons , make sure stage large enough (esp width) see buttons.
More discussions in ActionScript 3
adobe
Comments
Post a Comment