473,788 Members | 2,713 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Flash is integer

sumaiya
43 New Member
How can I find if a variable is integer in flash ??
Oct 27 '07 #1
1 9038
xNephilimx
213 Recognized Expert New Member
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
1627
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 the version of Flash, the width/height of the movie, etc. Does anyone know if there is any existing code available to do this? Ideally, I would like to not ask for -anything- from the user, except
11
2493
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 White to Yellow and then back to White in about 1 second or so. This is to create something like a 'flash' (or a Pulse) for when a User clicks on 1 of 4 Radio Buttons (which change the Text in the TextBox). So in other words, to get the...
9
8605
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 (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx). On the aspx page I have the object tag as follows:
10
2745
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 background and a few reports. Quite often I lament at the limitations of using forms, in particular how to make something that looks "stylish". This frustration may of course be caused by my own lack of skill/understanding on the subject, but for a...
0
1379
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 following code is run when the form is resized (incl. on load of course): Public Sub CenterControls(ByVal Form As Form) Dim intFrameLeft As Integer
4
21852
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 with database etc. If flash and C# interaction is possbile then, what are the prons and cons of this interaction? As using flash, one can create wonderful UI. But in return I also want it to interact fully with C# components.
115
13339
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 so I can't use the site. What complete losers! When are businesses going to understand that the purpose of a web site is to communicate with customers or business parterns and NOT so your "web master or "web engineer" can show off what they...
8
5912
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 clients (Internet Explorer). My flash content was originally brought in via the “flash satay” method, but I have since used some server-side magic do deliver one <objecttag
2
8091
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 did not understand some parameters totally in the HTML tag. These days when I was surfing the Internet I have found some comprehensive introduction to these two tags. I read it and conclude it with my own words; I think it will be useful to us, so I...
0
9656
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
10175
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10112
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9969
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
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 projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4070
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.