Copy link to clipboard
Copied
Hi all, very new to actionscript, so may be very simple and stupid question, but here I go : So just a simple program where the user enters a base and a power i.e : 4^3. My job is to show the user the value of that base to every power smaller and equal to it. So in this example it would show as :
4^0=1
4^1=4
4^2=16
4^3=64
I am able to show the value but only of the power entered by user, my question is how can I loop it so that every value is shown? And so that every different value is beneath the previous one as shown in my example.
If it isn't clear enough feel free to ask additional questions.
Thanks for the help.
Use the appendText method of the TextField - this way you can add to the field instead of replacing it's contents with .text = ""
monMessage.appendText(nouvMessage + "\n");
Copy link to clipboard
Copied
Create a for loop that counts up from 0 to the specified power value...
for (var i:int=0; i<= powerValue; i++){
// calculate using the value of i
}
Copy link to clipboard
Copied
I understand how to do the loop itself, what I am having trouble with is the text displaying, this is what I have so far :
var i:int =1;
var exposantMaleable:int = 1;
while(exposantMaleable <= exposant)
{
nouvMessage="Le chiffre " + base + " exposant " + exposantMaleable + " = " + puissance;
monMessage.text=nouvMessage;
addChild(monMessage);
puissance = Math.pow(base, exposantMaleable);
exposantMaleable ++
nouvMessage="Le chiffre " + base + " exposant " + exposantMaleable + " = " + puissance;
^that is the part I would like to loop, the message itself, so that the loop adds on the right amount of messages, when I run the program it only shows the message once
Copy link to clipboard
Copied
Use the appendText method of the TextField - this way you can add to the field instead of replacing it's contents with .text = ""
monMessage.appendText(nouvMessage + "\n");
Copy link to clipboard
Copied
It always help when you include your code when asking for help with it.
Copy link to clipboard
Copied
Thank You, noted for next time
Find more inspiration, events, and resources on the new Adobe Community
Explore Now