I recently got a free version of Flash Builder from Adobe, which is something they offer to students and unemployed persons. I am fairly new to Flash Builder, I have had the program for about 2 weeks now. I have decided to start a text-based adventure game project, as part of getting my feet wet in Action Script coding.
As part of the text game concept, I have decided to make a class that you can send a uint plus 6 strings, and it will make up to 6 buttons plus up to 6 labels and place them on the screen as a single sprite. I also plan to make a remover function, so that the multi button UI can be called and dismissed easily.
Every time I run this I get errors, Error 1006 is most common, I copy and paste the error into a search engine, and I crawl through various blogs, forums, etc. trying different things in order to make this work. Every time I fix an issue, a new one appears, and I am ready to admit I probably need help from someone who actually understands Action Script. I have more or less been winging it off of prior C++ programing class and web tutorials - Adobe's "flex in a week" and some others.
package
{
import flash.display.Shape ;
import flash.display.SimpleButton ;
import flash.display.Sprite ;
import flash.events.MouseEvent ;
import flash.text.TextField ;
public class MakeUI extends Sprite {
public var _button0 : SimpleButton ; public var _button1 : SimpleButton ; public var _button2 : SimpleButton ;public var _button3 : SimpleButton ; public var _button4 : SimpleButton ;public var _button5 : SimpleButton ;
public var _label0 : TextField ; public var _label1 : TextField ; public var _label2 : TextField ; public var _label3 : TextField ; public var _label4 : TextField ;public var _label5 : TextField ;
public var _cornerx : uint ; public var _buttonQty : uint ;public var i : uint ;
//Might have to make seperate variable for each button shape (up, down, over)
public function MakeUI(_buttonQty : uint, label1 : String, label2 : String, label3 : String, label4 : String, label5 : String, label6 : String) {
var _buttonSet : Sprite = new Sprite ()
for (i = 0; i < _buttonQty; i ++) {
this["_button" + i] = new SimpleButton () ;
_cornerx = ((480 / 96)(50 - (7 * _buttonQty)) + (14 * i)) ;
var _upbutton : Shape = new Shape () ;
_upbutton.graphics.beginFill (0x000000) ; _upbutton.graphics.drawRect(_cornerx, 310, 60, 30) ;
_upbutton.graphics.endFill () ;
var _overbutton : Shape = new Shape () ;
_overbutton.graphics.beginFill (0x333333) ; _overbutton.graphics.drawRect(_cornerx, 310, 60, 30) ;
_overbutton.graphics.endFill () ;
var _downbutton : Shape = new Shape () ;
_downbutton.graphics.drawRect(_cornerx, 310, 60, 30) ; _downbutton.graphics.beginFill (0xFFFFFF)
;_downbutton.graphics.endFill () ;
this["_button" + i].upState = _upbutton ;
this["_button" + i].overState = _overbutton ;
this["_button" + i].downState = _downbutton ;
this["_button" + i].hitTestState = _upbutton ;
this["_label" + i] = new TextField() ;
var _label : TextField = new TextField() ;
this["_label" + i].text = this["_label" + i] ; this["_label" + i].width =50 ; this["_label" + i].height=30 ; this["_label" + i].x = _cornerx ; this["_label" + i].y = 340 ;
_buttonSet.addChild (this["_button" + i]) ; _buttonSet.addChild (this["_label" + i]) ;
}
addChild (_buttonSet);

New Topic/Question
Reply


MultiQuote



|