-
Textbox Problem
I have created the coding below:
var color:Number;
var ElloRec:String = "rect";
var ellipse:String = "ellipse";
var rect:String = "rect";
var Nh:TextField = new TextField();
Nh.x = 10;
Nh.y = 55;
Nh.width = 30;
Nh.height = 20;
Nh.border = true;
Nh.background = true;
Nh.type = TextFieldType.INPUT;
Nh.restrict = "0-9"
Nh.maxChars = 2
addChild(Nh);
var Nw:TextField = new TextField();
Nw.x = 10;
Nw.y = 80;
Nw.width = 30;
Nw.height = 20;
Nw.border = true;
Nw.background = true;
Nw.type = TextFieldType.INPUT;
Nw.restrict = "0-9"
Nw.maxChars = 2
addChild(Nw);
ellipse_btn.addEventListener(MouseEvent.CLICK, Elli);
rectangle_btn.addEventListener(MouseEvent.CLICK, Tangle);
function Elli(e:MouseEvent):void {
ElloRec = ellipse;
}
function Tangle(e:MouseEvent):void {
ElloRec = rect;
}
red_btn.addEventListener(MouseEvent.CLICK, pickRed);
green_btn.addEventListener(MouseEvent.CLICK, pickGreen);
blu_btn.addEventListener(MouseEvent.CLICK, pickBlue);
function pickRed(e:MouseEvent):void {
color = 0xFF0000;
}
function pickGreen(e:MouseEvent):void {
color = 0x00FF00;
}
function pickBlue(e:MouseEvent):void {
color = 0x0000FF;
}
//....to here
stage.addEventListener(MouseEvent.MOUSE_DOWN, startDrawing);
stage.addEventListener(MouseEvent.MOUSE_UP, stopDrawing);
function startDrawing(e:MouseEvent):void {
stage.addEventListener(MouseEvent.MOUSE_MOVE, makeShapes);
}
function stopDrawing(e:MouseEvent):void {
stage.removeEventListener(MouseEvent.MOUSE_MOVE, makeShapes);
}
//the shapes are from the custom classes created in the
//external ActionScript files Ellipse.as & Rect.as
function makeShapes(e:MouseEvent):void {
if (ElloRec == ellipse) {
var shape1:Ellipse = new Ellipse(10, 10, color);
addChild(shape1);
shape1.x = mouseX;
shape1.y = mouseY;
}
else if (ElloRec == rect) {
var shape2:Rect = new Rect(10, 10, color);
addChild(shape2);
shape2.x = mouseX;
shape2.y = mouseY
}
}
The two textboxes are used by the user to decide what height (Nh) and what width (Nw) the shape should be, but I do not know how to connect the users choices (the user-created text within each textbox) with the numbers in bold in the code
I have tried adding Nh and Nw in place of the numbers in bold, eg.
var shape1:Ellipse = new Ellipse(Nh, Nw, color);
But this does not work. How can I remedy this problem?
-
try this:
PHP Code:
var shape1:Ellipse = new Ellipse(parseInt(Nh.text), parseInt(Nw.text), color);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|