473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Flash is integer

sumaiya
43
How can I find if a variable is integer in flash ??
Oct 27 '07 #1
1 9032
xNephilimx
213 Expert 100+
Hi sumaiya! How are you doing?
In AS3 or AS2? in AS2 there's no integer type, in AS3 there is the new "int" data type, though if you ask a typeof, even if it is an integer, it still will return "number" as the type.
In AS3, however, you can use the "is" operator as follows:

trace(thenumber is int);

that will trace true if "thenumber" is an integer, and false if it isn't. You also have the new datatype uint, that covers only the positive integers (int covers both, positive and negative integers):

trace(thenumber is uint);

Anyway, in AS2 there's no int or uint data type, so I think one thing you could do is convert it to a string and search for a dot, if there's a dot it is not an integer. You can make it a function like this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. function isInt(n:Number):Boolean {
  3.     return !(n.toString().indexOf(".") != -1);
  4. }
  5.  
  6. trace(isInt(3));
  7. //traces: true;
  8.  
  9. trace(isInt(2.4));
  10. //traces: false;
  11.  
  12.  
Or prototype it to the Number object:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Number.prototype.isInt = function():Boolean {
  3.     return !(this.toString().indexOf(".") != -1);
  4. }
  5.  
  6. var somevar:Number = 1;
  7.  
  8. trace(somevar.isInt());
  9. //traces: true;
  10.  
  11. var somevar:Number = 0.25;
  12.  
  13. trace(somevar.isInt());
  14. //traces: false;
  15.  
Best regards!
The_Nephilim

How can I find if a variable is integer in flash ??
Oct 28 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: LL2000 | last post by:
Hello! I'd like to allow users to upload Flash movies to my website and have them displayed in a page. There are certain things that I either need in order to display them correctly, such as...
11
by: Mr. B | last post by:
While at first this may seem a simple tast, it has plagued me for a while... What I want to do is to have the background colour of something like a TextBox to change from (say) White to Yellow to...
9
by: Keith Rowe | last post by:
Hello, I am trying to reference a Shockwave Flash Object on a vb code behind page in an ASP.NET project and I receive the following error: Guid should contain 32 digits with 4 dashes...
10
by: Scott | last post by:
I have written an Access application that our employees use on a daily basis to enter information. It's comprises of a series of forms, a few data integrity check queries that run in the...
0
by: jesse.hartwick | last post by:
Hi all. I'm designing a program that has to run on multiple resolutions and I'm having trouble with moving contols on the form. The way I have it now, the form is maximized on load, and the...
4
by: vivek | last post by:
I am new to flash and want someone to guide me, Is it possible to create a UI entirely in Flash and that will inetract with C# components (backend) and these components will in return interact...
115
by: post2google | last post by:
I was thinking about where to go for lunch the other day, so I went to hardees.com to see what the menu looked like these days. What comes up is a big note that my flash version is not new enough...
8
by: Neo Geshel | last post by:
Greetings. BACKGROUND: My sites are pure XHTML 1.1 with CSS 2.1 for markup. My pages are delivered as application/xhtml+xml for all non-MS web clients, and as text/xml for all MS web...
2
dream party
by: dream party | last post by:
Inserting a Flash (SWF, FLV) file into HTML web page is already an old and familiar thing to all of us. It is a rather non-flexible thing that just to edit some options in the template. However, I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.