Copy link to clipboard
Copied
http://imageshack.us/a/img201/4767/n9mj.png
http://imageshack.us/a/img443/1867/4797.png
In case you did not see my code in the picture:
var myFormat:TextFormat= new TextFormat();
body_txt.autoSize = TextFieldAutoSize.LEFT;
var lV:String;
var hT:String;
var lV = starting_txt.text
var hT = ending_txt.text
for (var lV:int = 1; lV <= 5; lV++)
{
trace(lV);
}
for (var hT:int = 2; hT <= 6; hT--)
{
trace(hT);
}
round_btn.addEventListener(MouseEvent.CLICK,onClick);
function onClick(event:MouseEvent):void{
addChild(body_txt);
body_txt.text = ""+ lV +""+ hT +""
}
I don't know what to enter in my variable, I've tried to name it different things. I often end up with errors such as "your variables conflict eachother", or something along those lines. I am supposed to display starting - ending numbers with no limit, which leads me to wonder how I am supposed to input a "starting number" considering there are unlimited numbers I could use as a starting number. Thank you for your help!
There are a number of errors with what you are doing.
Assign the values to the textfields before/outside the loops.
Your loops are going to execute immediately when you start the program, not when something gets clicked
You need to assign Strings to the textfields ( "500" ), not numbers ( 500 ).
=> is not a valid operator, >= is
If you want to display the numbers between two values, both of those values should be used in defining your loop... something like this (but not necessarily this)...
...
Copy link to clipboard
Copied
You cannot declare the same variables in the same scope... meaning you cannot have two vars with the same name. If you are supposed to use the values entered in the textfields as loop controls then assign them those values rather than defining them again.
for (var i:int = int(IV); i<= 5; i++)
{
trace(i);
}
for (var j:int = int(hT); j<= 6; j--) // not likely to work with the <= and --
{
trace(j);
}
Copy link to clipboard
Copied
Sorry if I am asking for help too much, I started programming for my first time 3-4 weeks ago. This subject really requires a lot of thinking and trial-and-error, that is for sure:
___
"var body_txt:TextField = new TextField();
body_txt.x = 225;
body_txt.y = 300;
var myFormat:TextFormat= new TextFormat();
var yourStarting:String;
var yourEnding:String;
for (var i:int = int(starting_txt.text = 1); i <= 500; i++)
{
trace(i);
}
for (var j:int = int(ending_txt.text = 500); j => 1; j++)
{
trace(j);
}
round_btn.addEventListener(MouseEvent.CLICK,onClick);
function onClick(event:MouseEvent):void{
addChild(body_txt);
body_txt.text = ""+ starting_txt.text +""+ ending_txt.text +""
}"
___
I keep getting errors no matter what I do, saying "implicit coercion of a value" etc., and I am not sure why; it is, however, somewhat frustrating.
My goal is to imput a starting number and ending number, and get the numbers to show from any number of your choosing.
(e.g., you input -800 for "Starting Number", 500 for "Ending Number". You get all the numbers in between counting by 1s)
I highly doubt what I am doing is correct so far, although I am not sure. It seems simple yet so hard.
Copy link to clipboard
Copied
There are a number of errors with what you are doing.
Assign the values to the textfields before/outside the loops.
Your loops are going to execute immediately when you start the program, not when something gets clicked
You need to assign Strings to the textfields ( "500" ), not numbers ( 500 ).
=> is not a valid operator, >= is
If you want to display the numbers between two values, both of those values should be used in defining your loop... something like this (but not necessarily this)...
for( var i = starting; i<=ending; i++)
Keep trying... struggling is how you will learn.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now