Highlighted

Need help to understand how to complete my program with functions listed. AdobeAnimateC++

Community Beginner ,
Jul 23, 2018

Copy link to clipboard

Copied

I am given a problem where I must complete the following code under each function. I attempted the the first function called "function getData()" where you simply put txtinput for global variable named num to define it. However, I am not understanding the rest of the other functions. Seems complicated. I have listed below where the functions are. Your explanations would be much appreciated.

// Name:

// Date:

// Purpose: To convert any number from 10 - 99 to its word representation

// This line makes the button, btnConvert wait for a mouse click

// When the button is clicked, the convertNumber function is called

btnConvert.addEventListener(MouseEvent.CLICK, convertNumber);

// These lines make the textinputs wait for a mouse click

// When any of these components are clicked, the clearLabels function is called

txtinNumber.addEventListener(MouseEvent.CLICK, clearLabels);

// Declare Global Variables

var num:int;         // number from 10 - 99

var tensDigit:int;   // the tens digit

var onesDigit:int;   // the ones digit

// This is the convertNumber function

// e:MouseEvent is the click event experienced by the button

// void indicates that the function does not return a value

function convertNumber(e:MouseEvent):void

{

getData();

if (num < 10 || num > 99){

lblOutput.text = "Invalid number. Enter a number between 10 and 99 inclusive.";

}

else{

lblOutput.text = "";

if (num >= 20) {

tensDigit = Math.floor(num / 10);

onesDigit = num % 10;

tens();

ones();

}

else{

tensDigit = Math.floor(num / 10);

onesDigit = num % 10;

teens();

}

}

}

// This is the getData function

// It gets the number from the user

function getData()

{

// complete the code here

num = int(txtinNumber.text);                       <---------------- Over here which I attempted. not entirely sure if correct.

// This is the tens function

// It outputs the word representation of 20, 30, 40,..,90

function tens()

{

//write the code here

tensdigit = int(txtintensDigit.text);                   <--------------Not understanding this one, I put txtinput for the variable tensdigit because I am aware that you have to define it

}

// This is the ones function

// It outputs the word representaion for any number from 1 - 9 inclusive

function ones()

{

// write the code here

onesdigit = int(txtinonesDigit.text);                <------------Did the same for this one as the one above

}

// This is the teens function

// It outputs the word representation for any number from 10 - 19 inclusive

function teens()

{

// write the code here                       <--------------And this one is just confusing, do not know how to work around this one with the function teens()

}

// This is the clearLabels function

// e:MouseEvent is the click event experienced by the textInput

// void indicates that the function does not return a value

function clearLabels(e:MouseEvent):void

{

     lblOutput.text = "";

}

Here is the program I made. Sorry if its small. You type in a number between 10 - 99, and the number turns into the word. ex 12 = twelve.

TOPICS
Discussions

Views

47

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Need help to understand how to complete my program with functions listed. AdobeAnimateC++

Community Beginner ,
Jul 23, 2018

Copy link to clipboard

Copied

I am given a problem where I must complete the following code under each function. I attempted the the first function called "function getData()" where you simply put txtinput for global variable named num to define it. However, I am not understanding the rest of the other functions. Seems complicated. I have listed below where the functions are. Your explanations would be much appreciated.

// Name:

// Date:

// Purpose: To convert any number from 10 - 99 to its word representation

// This line makes the button, btnConvert wait for a mouse click

// When the button is clicked, the convertNumber function is called

btnConvert.addEventListener(MouseEvent.CLICK, convertNumber);

// These lines make the textinputs wait for a mouse click

// When any of these components are clicked, the clearLabels function is called

txtinNumber.addEventListener(MouseEvent.CLICK, clearLabels);

// Declare Global Variables

var num:int;         // number from 10 - 99

var tensDigit:int;   // the tens digit

var onesDigit:int;   // the ones digit

// This is the convertNumber function

// e:MouseEvent is the click event experienced by the button

// void indicates that the function does not return a value

function convertNumber(e:MouseEvent):void

{

getData();

if (num < 10 || num > 99){

lblOutput.text = "Invalid number. Enter a number between 10 and 99 inclusive.";

}

else{

lblOutput.text = "";

if (num >= 20) {

tensDigit = Math.floor(num / 10);

onesDigit = num % 10;

tens();

ones();

}

else{

tensDigit = Math.floor(num / 10);

onesDigit = num % 10;

teens();

}

}

}

// This is the getData function

// It gets the number from the user

function getData()

{

// complete the code here

num = int(txtinNumber.text);                       <---------------- Over here which I attempted. not entirely sure if correct.

// This is the tens function

// It outputs the word representation of 20, 30, 40,..,90

function tens()

{

//write the code here

tensdigit = int(txtintensDigit.text);                   <--------------Not understanding this one, I put txtinput for the variable tensdigit because I am aware that you have to define it

}

// This is the ones function

// It outputs the word representaion for any number from 1 - 9 inclusive

function ones()

{

// write the code here

onesdigit = int(txtinonesDigit.text);                <------------Did the same for this one as the one above

}

// This is the teens function

// It outputs the word representation for any number from 10 - 19 inclusive

function teens()

{

// write the code here                       <--------------And this one is just confusing, do not know how to work around this one with the function teens()

}

// This is the clearLabels function

// e:MouseEvent is the click event experienced by the textInput

// void indicates that the function does not return a value

function clearLabels(e:MouseEvent):void

{

     lblOutput.text = "";

}

Here is the program I made. Sorry if its small. You type in a number between 10 - 99, and the number turns into the word. ex 12 = twelve.

TOPICS
Discussions

Views

48

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 23, 2018 0
Adobe Community Professional ,
Aug 21, 2020

Copy link to clipboard

Copied

Can you ask the person requesting you do this for them for clarification? 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 21, 2020 0