[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.2

AS3: class related questions and IF statment

Asked by Madkhali in ActionScript, Adobe Flash, Adobe Creative Suite

Tags: actionscript 3

i am reading and practicing an exercise, while typing it many times trying to figure out what is the problem, i failed. please see the code below.

i commented some of the code to explain and remember what is it, and there is WHY questions, please help to understand

thanks
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
package 
{
 
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
 
	public class Main extends MovieClip
	{
		//why i have to declare these vars outside the Main function?
 
		//this var is for user, he can guesses the number
		// at the same time the program use it to compare in the (if) statment
		var currentGuess:uint;
		var startMessage:String;
 
		// this is the number stored and the user try to guess it
		var mysteryNumber:uint;
 
		public function Main ()
		{
			init ();
 
			function init ()
			{
				//trace ("Hello, from the init method!");
 
				//initialize variable
				startMessage = "I am thinking of a number between 1 and 100";
				mysteryNumber = 50;
 
				//initialize text field
				output_txt.text = startMessage;
				
				// why i have to define or give the input_txt empty value?
				input_txt.text = "";
				input_txt.backgroundColor = 0xffcccc;
				input_txt.restrict = "0-9";
 
				//why this command does not work
				stage.focus = input_txt;
 
				// add an event listener to a button
				guessButton_btn.addEventListener (MouseEvent.CLICK, onGuessButtonClick);
			}
 
			function onGuessButtonClick (e:MouseEvent):void
			{
				//assigning the input from the text field to the currentGuess var
 
				/*Its very easy to convert data types in AS3.0. All you need to do is
				surround the data you want to convert in parentheses and then add 
				the name of the type you want to convert it to.*/
				currentGuess = input_txt.text as uint;
 
				//when i type from 0 - 49, it says: That's too high 
				//but when i type 50 or above 50, it does not give me the
				//defined messege i specified
				if (currentGuess > mysteryNumber)
				{
					output_txt.text = "That's too high";
				}
				else if (currentGuess < mysteryNumber)
				{
					output_txt.text = "That's too low";
				}
				else
				{
					output_txt.text = "You got it";
				}
			}
		}
	}
}
[+][-]07/04/09 07:21 PM, ID: 24778636Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: ActionScript, Adobe Flash, Adobe Creative Suite
Tags: actionscript 3
Sign Up Now!
Solution Provided By: Iklu
Participating Experts: 1
Solution Grade: A
 
[+][-]07/10/09 10:29 PM, ID: 24829170Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091118-EE-VQP-93 - Hierarchy / EE_QW_3_20080625