Arrays with Actionscript3











up vote
-2
down vote

favorite












Im relatively new to Actionscript3. I am trying to make a simple calculator that takes different values from the textbox objects on the stage and multiply them to give the result in other text boxes. I am trying this in Flash CS6. Screenshot of the .FLA file. How would I implement the following code using arrays?



    var txtbox:TextFormat=new TextFormat();
txtbox.size = 11;
txtbox.bold = true;

value1.setStyle("textFormat",txtbox);
value2.setStyle("textFormat",txtbox);
value3.setStyle("textFormat",txtbox);
value4.setStyle("textFormat",txtbox);
value5.setStyle("textFormat",txtbox);
multiplier.setStyle("textFormat",txtbox);

result1.setStyle("textFormat",txtbox);
result2.setStyle("textFormat",txtbox);
result3.setStyle("textFormat",txtbox);
result4.setStyle("textFormat",txtbox);
result5.setStyle("textFormat",txtbox);


compute.addEventListener(MouseEvent.CLICK, calBtn);
function calBtn(event:MouseEvent):void
{
var myArray:Array = int(value1),int(value2),int(value3),int(value4),int(value5)];

var m:Number=Number(multiplier.text);

var r1:Number = int((value1*m)*1000)/1000;
var r2:Number = int((value2*m)*1000)/1000;
var r3:Number = int((value3*m)*1000)/1000;
var r4:Number = int((value4*m)*1000)/1000;
var r5:Number = int((value5*m)*1000)/1000;

result1.text=String(r1);
result2.text=String(r2);
result3.text=String(r3);
result4.text=String(r4);
result5.text=String(r5);
}









share|improve this question
























  • Please explain, what did you expect and what exactly doesn't work.
    – Organis
    Nov 21 at 11:57










  • The user has to enter values in the different text boxes in the values column. The number with which these values have to be multiplied is entered in the text box in the multiplier column and the resulting for each value has to be displayed in the respective text boxes in the result column. This works with the code i have posted. But when I use the array it gives me the following error : "1067: Implicit coercion of a value of type fl.controls:TextInput to an unrelated type Number.". P.S. - I mixed up the original code i posted, updated the code i used. My bad, i am sorry.
    – Ankush Laxman
    Nov 22 at 12:54

















up vote
-2
down vote

favorite












Im relatively new to Actionscript3. I am trying to make a simple calculator that takes different values from the textbox objects on the stage and multiply them to give the result in other text boxes. I am trying this in Flash CS6. Screenshot of the .FLA file. How would I implement the following code using arrays?



    var txtbox:TextFormat=new TextFormat();
txtbox.size = 11;
txtbox.bold = true;

value1.setStyle("textFormat",txtbox);
value2.setStyle("textFormat",txtbox);
value3.setStyle("textFormat",txtbox);
value4.setStyle("textFormat",txtbox);
value5.setStyle("textFormat",txtbox);
multiplier.setStyle("textFormat",txtbox);

result1.setStyle("textFormat",txtbox);
result2.setStyle("textFormat",txtbox);
result3.setStyle("textFormat",txtbox);
result4.setStyle("textFormat",txtbox);
result5.setStyle("textFormat",txtbox);


compute.addEventListener(MouseEvent.CLICK, calBtn);
function calBtn(event:MouseEvent):void
{
var myArray:Array = int(value1),int(value2),int(value3),int(value4),int(value5)];

var m:Number=Number(multiplier.text);

var r1:Number = int((value1*m)*1000)/1000;
var r2:Number = int((value2*m)*1000)/1000;
var r3:Number = int((value3*m)*1000)/1000;
var r4:Number = int((value4*m)*1000)/1000;
var r5:Number = int((value5*m)*1000)/1000;

result1.text=String(r1);
result2.text=String(r2);
result3.text=String(r3);
result4.text=String(r4);
result5.text=String(r5);
}









share|improve this question
























  • Please explain, what did you expect and what exactly doesn't work.
    – Organis
    Nov 21 at 11:57










  • The user has to enter values in the different text boxes in the values column. The number with which these values have to be multiplied is entered in the text box in the multiplier column and the resulting for each value has to be displayed in the respective text boxes in the result column. This works with the code i have posted. But when I use the array it gives me the following error : "1067: Implicit coercion of a value of type fl.controls:TextInput to an unrelated type Number.". P.S. - I mixed up the original code i posted, updated the code i used. My bad, i am sorry.
    – Ankush Laxman
    Nov 22 at 12:54















up vote
-2
down vote

favorite









up vote
-2
down vote

favorite











Im relatively new to Actionscript3. I am trying to make a simple calculator that takes different values from the textbox objects on the stage and multiply them to give the result in other text boxes. I am trying this in Flash CS6. Screenshot of the .FLA file. How would I implement the following code using arrays?



    var txtbox:TextFormat=new TextFormat();
txtbox.size = 11;
txtbox.bold = true;

value1.setStyle("textFormat",txtbox);
value2.setStyle("textFormat",txtbox);
value3.setStyle("textFormat",txtbox);
value4.setStyle("textFormat",txtbox);
value5.setStyle("textFormat",txtbox);
multiplier.setStyle("textFormat",txtbox);

result1.setStyle("textFormat",txtbox);
result2.setStyle("textFormat",txtbox);
result3.setStyle("textFormat",txtbox);
result4.setStyle("textFormat",txtbox);
result5.setStyle("textFormat",txtbox);


compute.addEventListener(MouseEvent.CLICK, calBtn);
function calBtn(event:MouseEvent):void
{
var myArray:Array = int(value1),int(value2),int(value3),int(value4),int(value5)];

var m:Number=Number(multiplier.text);

var r1:Number = int((value1*m)*1000)/1000;
var r2:Number = int((value2*m)*1000)/1000;
var r3:Number = int((value3*m)*1000)/1000;
var r4:Number = int((value4*m)*1000)/1000;
var r5:Number = int((value5*m)*1000)/1000;

result1.text=String(r1);
result2.text=String(r2);
result3.text=String(r3);
result4.text=String(r4);
result5.text=String(r5);
}









share|improve this question















Im relatively new to Actionscript3. I am trying to make a simple calculator that takes different values from the textbox objects on the stage and multiply them to give the result in other text boxes. I am trying this in Flash CS6. Screenshot of the .FLA file. How would I implement the following code using arrays?



    var txtbox:TextFormat=new TextFormat();
txtbox.size = 11;
txtbox.bold = true;

value1.setStyle("textFormat",txtbox);
value2.setStyle("textFormat",txtbox);
value3.setStyle("textFormat",txtbox);
value4.setStyle("textFormat",txtbox);
value5.setStyle("textFormat",txtbox);
multiplier.setStyle("textFormat",txtbox);

result1.setStyle("textFormat",txtbox);
result2.setStyle("textFormat",txtbox);
result3.setStyle("textFormat",txtbox);
result4.setStyle("textFormat",txtbox);
result5.setStyle("textFormat",txtbox);


compute.addEventListener(MouseEvent.CLICK, calBtn);
function calBtn(event:MouseEvent):void
{
var myArray:Array = int(value1),int(value2),int(value3),int(value4),int(value5)];

var m:Number=Number(multiplier.text);

var r1:Number = int((value1*m)*1000)/1000;
var r2:Number = int((value2*m)*1000)/1000;
var r3:Number = int((value3*m)*1000)/1000;
var r4:Number = int((value4*m)*1000)/1000;
var r5:Number = int((value5*m)*1000)/1000;

result1.text=String(r1);
result2.text=String(r2);
result3.text=String(r3);
result4.text=String(r4);
result5.text=String(r5);
}






actionscript-3 actionscript flash-cs6






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 at 12:56

























asked Nov 21 at 11:31









Ankush Laxman

12




12












  • Please explain, what did you expect and what exactly doesn't work.
    – Organis
    Nov 21 at 11:57










  • The user has to enter values in the different text boxes in the values column. The number with which these values have to be multiplied is entered in the text box in the multiplier column and the resulting for each value has to be displayed in the respective text boxes in the result column. This works with the code i have posted. But when I use the array it gives me the following error : "1067: Implicit coercion of a value of type fl.controls:TextInput to an unrelated type Number.". P.S. - I mixed up the original code i posted, updated the code i used. My bad, i am sorry.
    – Ankush Laxman
    Nov 22 at 12:54




















  • Please explain, what did you expect and what exactly doesn't work.
    – Organis
    Nov 21 at 11:57










  • The user has to enter values in the different text boxes in the values column. The number with which these values have to be multiplied is entered in the text box in the multiplier column and the resulting for each value has to be displayed in the respective text boxes in the result column. This works with the code i have posted. But when I use the array it gives me the following error : "1067: Implicit coercion of a value of type fl.controls:TextInput to an unrelated type Number.". P.S. - I mixed up the original code i posted, updated the code i used. My bad, i am sorry.
    – Ankush Laxman
    Nov 22 at 12:54


















Please explain, what did you expect and what exactly doesn't work.
– Organis
Nov 21 at 11:57




Please explain, what did you expect and what exactly doesn't work.
– Organis
Nov 21 at 11:57












The user has to enter values in the different text boxes in the values column. The number with which these values have to be multiplied is entered in the text box in the multiplier column and the resulting for each value has to be displayed in the respective text boxes in the result column. This works with the code i have posted. But when I use the array it gives me the following error : "1067: Implicit coercion of a value of type fl.controls:TextInput to an unrelated type Number.". P.S. - I mixed up the original code i posted, updated the code i used. My bad, i am sorry.
– Ankush Laxman
Nov 22 at 12:54






The user has to enter values in the different text boxes in the values column. The number with which these values have to be multiplied is entered in the text box in the multiplier column and the resulting for each value has to be displayed in the respective text boxes in the result column. This works with the code i have posted. But when I use the array it gives me the following error : "1067: Implicit coercion of a value of type fl.controls:TextInput to an unrelated type Number.". P.S. - I mixed up the original code i posted, updated the code i used. My bad, i am sorry.
– Ankush Laxman
Nov 22 at 12:54














2 Answers
2






active

oldest

votes

















up vote
0
down vote



accepted










The error you are getting is telling you that you're using a TextInput like it's a Number.



Looking through your code, we can see that is indeed what is happening:



int(value1)  //value1 presumably is a TextInput, and can't be converted to an int

//and later...
int((value1*m) //value1 is a TextInput, and can't be multiplied


What you need to do, is convert the text property of the TextInput into a Number first, then do your math. (just like you're currently doing with the multiplier text box)



int(value1.text) * m


There are few other issues with your code though, like how you're creating your array.
Here is a potential refactoring



var txtbox:TextFormat = new TextFormat();
txtbox.size = 11;
txtbox.bold = true;

//put all the text inputs and in an array so you don't have to repeat the same code so much
var textInputs:Array = [value1,value2,value3, value4, value5];
var textOutputs:Array = [result1, result2, result3, result4, result5];

//set the style in a for loop
for(var i:int=0;i<textInputs.length;i++){
textInputs[i].setStyle("textFormat",txtbox);
}

multiplier.setStyle("textFormat",txtbox);

compute.addEventListener(MouseEvent.CLICK, calBtn);

function calBtn(event:MouseEvent):void
{
var m:Number=Number(multiplier.text);
//make sure the multiplier is a valid number
if(isNaN(m)){
//do something here to tell the user they entered something invalid
return; //don't keep going in this function
}

//loop through each text input
for(var i:int=0;i<textInputs.length;i++){
//convert text input value to number
var num:Number = int(textInputs[i].text);

//check if the input is valid
if(!isNaN(num)){
textOutputs[i].text = String( (num * 1000) / 100 );
}else{
textOutputs[i].text = "Invalid Number";
}
}
}





share|improve this answer





















  • Thank you very much for all your help, i managed to solve the problem!!! I did not use if statements to check if only numbers are entered in the boxes as i restricted the properties of all the input boxes in the property panel of each box to "0-9 ." So only numbers can be entered and the input boxes wont accept any other input, so there was no need to code checking for the type of input.
    – Ankush Laxman
    Nov 23 at 14:56


















up vote
0
down vote













This problem is now solved. I have posted the code here so that others with a similar problem can use it as reference. I have also posted a screenshot of the result here.



var txtbox:TextFormat=new TextFormat();
txtbox.size = 11;
txtbox.bold = true;

var textInputs:Array = [value1,value2,value3,value4,value5];
var textOutputs:Array = [result1,result2,result3,result4,result5];

for (var i:Number=0; i<textInputs.length; i++)
{
textInputs[i].setStyle("textFormat",txtbox);
}

multiplier.setStyle("textFormat",txtbox);

for (var j:Number=0; j<textOutputs.length; j++)
{
textOutputs[j].setStyle("textFormat",txtbox);
}

compute.addEventListener(MouseEvent.CLICK, calBtn);
function calBtn(event:MouseEvent):void
{
var m:Number=Number(multiplier.text);

for (var i:Number=0;i<textInputs.length;i++)
{
var num:Number = Number(textInputs[i].text);
textOutputs[i].text = String(int((num*m)*1000)/1000);
}
}





share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53411170%2farrays-with-actionscript3%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote



    accepted










    The error you are getting is telling you that you're using a TextInput like it's a Number.



    Looking through your code, we can see that is indeed what is happening:



    int(value1)  //value1 presumably is a TextInput, and can't be converted to an int

    //and later...
    int((value1*m) //value1 is a TextInput, and can't be multiplied


    What you need to do, is convert the text property of the TextInput into a Number first, then do your math. (just like you're currently doing with the multiplier text box)



    int(value1.text) * m


    There are few other issues with your code though, like how you're creating your array.
    Here is a potential refactoring



    var txtbox:TextFormat = new TextFormat();
    txtbox.size = 11;
    txtbox.bold = true;

    //put all the text inputs and in an array so you don't have to repeat the same code so much
    var textInputs:Array = [value1,value2,value3, value4, value5];
    var textOutputs:Array = [result1, result2, result3, result4, result5];

    //set the style in a for loop
    for(var i:int=0;i<textInputs.length;i++){
    textInputs[i].setStyle("textFormat",txtbox);
    }

    multiplier.setStyle("textFormat",txtbox);

    compute.addEventListener(MouseEvent.CLICK, calBtn);

    function calBtn(event:MouseEvent):void
    {
    var m:Number=Number(multiplier.text);
    //make sure the multiplier is a valid number
    if(isNaN(m)){
    //do something here to tell the user they entered something invalid
    return; //don't keep going in this function
    }

    //loop through each text input
    for(var i:int=0;i<textInputs.length;i++){
    //convert text input value to number
    var num:Number = int(textInputs[i].text);

    //check if the input is valid
    if(!isNaN(num)){
    textOutputs[i].text = String( (num * 1000) / 100 );
    }else{
    textOutputs[i].text = "Invalid Number";
    }
    }
    }





    share|improve this answer





















    • Thank you very much for all your help, i managed to solve the problem!!! I did not use if statements to check if only numbers are entered in the boxes as i restricted the properties of all the input boxes in the property panel of each box to "0-9 ." So only numbers can be entered and the input boxes wont accept any other input, so there was no need to code checking for the type of input.
      – Ankush Laxman
      Nov 23 at 14:56















    up vote
    0
    down vote



    accepted










    The error you are getting is telling you that you're using a TextInput like it's a Number.



    Looking through your code, we can see that is indeed what is happening:



    int(value1)  //value1 presumably is a TextInput, and can't be converted to an int

    //and later...
    int((value1*m) //value1 is a TextInput, and can't be multiplied


    What you need to do, is convert the text property of the TextInput into a Number first, then do your math. (just like you're currently doing with the multiplier text box)



    int(value1.text) * m


    There are few other issues with your code though, like how you're creating your array.
    Here is a potential refactoring



    var txtbox:TextFormat = new TextFormat();
    txtbox.size = 11;
    txtbox.bold = true;

    //put all the text inputs and in an array so you don't have to repeat the same code so much
    var textInputs:Array = [value1,value2,value3, value4, value5];
    var textOutputs:Array = [result1, result2, result3, result4, result5];

    //set the style in a for loop
    for(var i:int=0;i<textInputs.length;i++){
    textInputs[i].setStyle("textFormat",txtbox);
    }

    multiplier.setStyle("textFormat",txtbox);

    compute.addEventListener(MouseEvent.CLICK, calBtn);

    function calBtn(event:MouseEvent):void
    {
    var m:Number=Number(multiplier.text);
    //make sure the multiplier is a valid number
    if(isNaN(m)){
    //do something here to tell the user they entered something invalid
    return; //don't keep going in this function
    }

    //loop through each text input
    for(var i:int=0;i<textInputs.length;i++){
    //convert text input value to number
    var num:Number = int(textInputs[i].text);

    //check if the input is valid
    if(!isNaN(num)){
    textOutputs[i].text = String( (num * 1000) / 100 );
    }else{
    textOutputs[i].text = "Invalid Number";
    }
    }
    }





    share|improve this answer





















    • Thank you very much for all your help, i managed to solve the problem!!! I did not use if statements to check if only numbers are entered in the boxes as i restricted the properties of all the input boxes in the property panel of each box to "0-9 ." So only numbers can be entered and the input boxes wont accept any other input, so there was no need to code checking for the type of input.
      – Ankush Laxman
      Nov 23 at 14:56













    up vote
    0
    down vote



    accepted







    up vote
    0
    down vote



    accepted






    The error you are getting is telling you that you're using a TextInput like it's a Number.



    Looking through your code, we can see that is indeed what is happening:



    int(value1)  //value1 presumably is a TextInput, and can't be converted to an int

    //and later...
    int((value1*m) //value1 is a TextInput, and can't be multiplied


    What you need to do, is convert the text property of the TextInput into a Number first, then do your math. (just like you're currently doing with the multiplier text box)



    int(value1.text) * m


    There are few other issues with your code though, like how you're creating your array.
    Here is a potential refactoring



    var txtbox:TextFormat = new TextFormat();
    txtbox.size = 11;
    txtbox.bold = true;

    //put all the text inputs and in an array so you don't have to repeat the same code so much
    var textInputs:Array = [value1,value2,value3, value4, value5];
    var textOutputs:Array = [result1, result2, result3, result4, result5];

    //set the style in a for loop
    for(var i:int=0;i<textInputs.length;i++){
    textInputs[i].setStyle("textFormat",txtbox);
    }

    multiplier.setStyle("textFormat",txtbox);

    compute.addEventListener(MouseEvent.CLICK, calBtn);

    function calBtn(event:MouseEvent):void
    {
    var m:Number=Number(multiplier.text);
    //make sure the multiplier is a valid number
    if(isNaN(m)){
    //do something here to tell the user they entered something invalid
    return; //don't keep going in this function
    }

    //loop through each text input
    for(var i:int=0;i<textInputs.length;i++){
    //convert text input value to number
    var num:Number = int(textInputs[i].text);

    //check if the input is valid
    if(!isNaN(num)){
    textOutputs[i].text = String( (num * 1000) / 100 );
    }else{
    textOutputs[i].text = "Invalid Number";
    }
    }
    }





    share|improve this answer












    The error you are getting is telling you that you're using a TextInput like it's a Number.



    Looking through your code, we can see that is indeed what is happening:



    int(value1)  //value1 presumably is a TextInput, and can't be converted to an int

    //and later...
    int((value1*m) //value1 is a TextInput, and can't be multiplied


    What you need to do, is convert the text property of the TextInput into a Number first, then do your math. (just like you're currently doing with the multiplier text box)



    int(value1.text) * m


    There are few other issues with your code though, like how you're creating your array.
    Here is a potential refactoring



    var txtbox:TextFormat = new TextFormat();
    txtbox.size = 11;
    txtbox.bold = true;

    //put all the text inputs and in an array so you don't have to repeat the same code so much
    var textInputs:Array = [value1,value2,value3, value4, value5];
    var textOutputs:Array = [result1, result2, result3, result4, result5];

    //set the style in a for loop
    for(var i:int=0;i<textInputs.length;i++){
    textInputs[i].setStyle("textFormat",txtbox);
    }

    multiplier.setStyle("textFormat",txtbox);

    compute.addEventListener(MouseEvent.CLICK, calBtn);

    function calBtn(event:MouseEvent):void
    {
    var m:Number=Number(multiplier.text);
    //make sure the multiplier is a valid number
    if(isNaN(m)){
    //do something here to tell the user they entered something invalid
    return; //don't keep going in this function
    }

    //loop through each text input
    for(var i:int=0;i<textInputs.length;i++){
    //convert text input value to number
    var num:Number = int(textInputs[i].text);

    //check if the input is valid
    if(!isNaN(num)){
    textOutputs[i].text = String( (num * 1000) / 100 );
    }else{
    textOutputs[i].text = "Invalid Number";
    }
    }
    }






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 22 at 16:53









    BadFeelingAboutThis

    14.1k22636




    14.1k22636












    • Thank you very much for all your help, i managed to solve the problem!!! I did not use if statements to check if only numbers are entered in the boxes as i restricted the properties of all the input boxes in the property panel of each box to "0-9 ." So only numbers can be entered and the input boxes wont accept any other input, so there was no need to code checking for the type of input.
      – Ankush Laxman
      Nov 23 at 14:56


















    • Thank you very much for all your help, i managed to solve the problem!!! I did not use if statements to check if only numbers are entered in the boxes as i restricted the properties of all the input boxes in the property panel of each box to "0-9 ." So only numbers can be entered and the input boxes wont accept any other input, so there was no need to code checking for the type of input.
      – Ankush Laxman
      Nov 23 at 14:56
















    Thank you very much for all your help, i managed to solve the problem!!! I did not use if statements to check if only numbers are entered in the boxes as i restricted the properties of all the input boxes in the property panel of each box to "0-9 ." So only numbers can be entered and the input boxes wont accept any other input, so there was no need to code checking for the type of input.
    – Ankush Laxman
    Nov 23 at 14:56




    Thank you very much for all your help, i managed to solve the problem!!! I did not use if statements to check if only numbers are entered in the boxes as i restricted the properties of all the input boxes in the property panel of each box to "0-9 ." So only numbers can be entered and the input boxes wont accept any other input, so there was no need to code checking for the type of input.
    – Ankush Laxman
    Nov 23 at 14:56












    up vote
    0
    down vote













    This problem is now solved. I have posted the code here so that others with a similar problem can use it as reference. I have also posted a screenshot of the result here.



    var txtbox:TextFormat=new TextFormat();
    txtbox.size = 11;
    txtbox.bold = true;

    var textInputs:Array = [value1,value2,value3,value4,value5];
    var textOutputs:Array = [result1,result2,result3,result4,result5];

    for (var i:Number=0; i<textInputs.length; i++)
    {
    textInputs[i].setStyle("textFormat",txtbox);
    }

    multiplier.setStyle("textFormat",txtbox);

    for (var j:Number=0; j<textOutputs.length; j++)
    {
    textOutputs[j].setStyle("textFormat",txtbox);
    }

    compute.addEventListener(MouseEvent.CLICK, calBtn);
    function calBtn(event:MouseEvent):void
    {
    var m:Number=Number(multiplier.text);

    for (var i:Number=0;i<textInputs.length;i++)
    {
    var num:Number = Number(textInputs[i].text);
    textOutputs[i].text = String(int((num*m)*1000)/1000);
    }
    }





    share|improve this answer

























      up vote
      0
      down vote













      This problem is now solved. I have posted the code here so that others with a similar problem can use it as reference. I have also posted a screenshot of the result here.



      var txtbox:TextFormat=new TextFormat();
      txtbox.size = 11;
      txtbox.bold = true;

      var textInputs:Array = [value1,value2,value3,value4,value5];
      var textOutputs:Array = [result1,result2,result3,result4,result5];

      for (var i:Number=0; i<textInputs.length; i++)
      {
      textInputs[i].setStyle("textFormat",txtbox);
      }

      multiplier.setStyle("textFormat",txtbox);

      for (var j:Number=0; j<textOutputs.length; j++)
      {
      textOutputs[j].setStyle("textFormat",txtbox);
      }

      compute.addEventListener(MouseEvent.CLICK, calBtn);
      function calBtn(event:MouseEvent):void
      {
      var m:Number=Number(multiplier.text);

      for (var i:Number=0;i<textInputs.length;i++)
      {
      var num:Number = Number(textInputs[i].text);
      textOutputs[i].text = String(int((num*m)*1000)/1000);
      }
      }





      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        This problem is now solved. I have posted the code here so that others with a similar problem can use it as reference. I have also posted a screenshot of the result here.



        var txtbox:TextFormat=new TextFormat();
        txtbox.size = 11;
        txtbox.bold = true;

        var textInputs:Array = [value1,value2,value3,value4,value5];
        var textOutputs:Array = [result1,result2,result3,result4,result5];

        for (var i:Number=0; i<textInputs.length; i++)
        {
        textInputs[i].setStyle("textFormat",txtbox);
        }

        multiplier.setStyle("textFormat",txtbox);

        for (var j:Number=0; j<textOutputs.length; j++)
        {
        textOutputs[j].setStyle("textFormat",txtbox);
        }

        compute.addEventListener(MouseEvent.CLICK, calBtn);
        function calBtn(event:MouseEvent):void
        {
        var m:Number=Number(multiplier.text);

        for (var i:Number=0;i<textInputs.length;i++)
        {
        var num:Number = Number(textInputs[i].text);
        textOutputs[i].text = String(int((num*m)*1000)/1000);
        }
        }





        share|improve this answer












        This problem is now solved. I have posted the code here so that others with a similar problem can use it as reference. I have also posted a screenshot of the result here.



        var txtbox:TextFormat=new TextFormat();
        txtbox.size = 11;
        txtbox.bold = true;

        var textInputs:Array = [value1,value2,value3,value4,value5];
        var textOutputs:Array = [result1,result2,result3,result4,result5];

        for (var i:Number=0; i<textInputs.length; i++)
        {
        textInputs[i].setStyle("textFormat",txtbox);
        }

        multiplier.setStyle("textFormat",txtbox);

        for (var j:Number=0; j<textOutputs.length; j++)
        {
        textOutputs[j].setStyle("textFormat",txtbox);
        }

        compute.addEventListener(MouseEvent.CLICK, calBtn);
        function calBtn(event:MouseEvent):void
        {
        var m:Number=Number(multiplier.text);

        for (var i:Number=0;i<textInputs.length;i++)
        {
        var num:Number = Number(textInputs[i].text);
        textOutputs[i].text = String(int((num*m)*1000)/1000);
        }
        }






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 23 at 14:53









        Ankush Laxman

        12




        12






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53411170%2farrays-with-actionscript3%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Trompette piccolo

            Slow SSRS Report in dynamic grouping and multiple parameters

            Simon Yates (cyclisme)