Mod-10 Number Validation Algorithm (modulo 10)
HI!I'm looking for a Mod-10 (modulo 10) validation algorithm writen in actionscript.From a text-field, the user will enter a code and on submit, actionscript will validate if the number is right.Does anyone know this algorithm ?Thanks.
KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 07-22-2005, 06:24 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
A Algorithm Of The Number's Sequence
Hallo everybody,
I met a problem while I am learning the flash actionscript 2.
The question is how to implement this algorithm: I have number (1-100), however, it will return to 0, when it meets 10, likewise 11 returns to 1, 12 to 2...
90 -> 0
91 -> 1
...
Thanks in advance!
A Algorithm Of The Number's Sequence
Hallo everybody,
I met a problem while I am learning the flash actionscript 2.
The question is how to implement this algorithm: I have number (1-100), however, it will return to 0, when it meets 10, likewise 11 returns to 1, 12 to 2...
90 -> 0
91 -> 1
...
Thanks in advance!
Phone Number Validation
Howdy...
I need some help on validating the right form of the phone number...
I have most of the aspects validated and I got into some problems that I cannot solve myself...
1. I am using textfield.restrict = "0-9-"; to restrict the alphabetic characters entered to the text field, and it works fine when I publish the HTML and check it on the web. However, I cannot use any keys like Backspace or Delete keys to erase character within the Flash... Any way I can achieve both???
2. The final format of the phone number will be '123-456-7890'. I have a onEnterFrame handler that checks if the current character length is 3 or 7 to add '-' so that the user do not need to press '-' key... It works fine when I enter the number one by one, but, say, if I hold the '1' longer to get '111-111-1111', I get '111111111111' because it just took the advantage of onEnterFrame handler... Any help on this anybody???
I have attached the FLA file in case you need to take a look...
Thank you for your time...
Help With Form Validation, Phone Number
here is a code below, would anyone help me validate a valid phone number? something like 555-555-5555, or numbers, or anything? right now i have it validate for empty space but little more specific would be nice, thank
__________________________________________________ _______________
fscommand ("allowscale", "false");
fname1.tabIndex = 1;
lname1.tabIndex = 2;
telno1.tabIndex = 3;
email1.tabIndex = 4;
address1.tabIndex = 5;
city1.tabIndex = 6;
state1.tabIndex = 7;
zip1.tabIndex = 8;
pdate1.tabIndex = 9;
ptime1.tabIndex = 10;
ftime1.tabIndex = 11;
passengers1.tabIndex = 12;
comments1.tabIndex = 13;
mailform = "mailform.php";
confirm = "please wait for confirmation ..."
action = "send";
Selection.setFocus("fname");
function validate (address) {
if (address.length>=7) {
if (address.indexOf("@")>0) {
if ((address.indexOf("@")+2)<address.lastIndexOf(".") ) {
if (address.lastIndexOf(".")<(address.length-2)) {
return (true);
}
}
}
}
return (false);
}
function formcheck () {
if ((((email == null)) || (email.length<1)) || (email == "ERROR! Address not valid")) {
email = "ERROR! Address not valid";
action = "";
}
if (!validate(email)) {
email = "Address not valid";
action = "";
}
if ((((fname == null)) || (fname.length<1)) || (fname == "ERROR! Address not valid")) {
fname = "First name required";
action = "";
}
if ((((lname == null)) || (lname.length<1)) || (lname == "ERROR! Address not valid")) {
lname = "Last name required";
action = "";
}
if ((((telno == null)) || (telno.length<1)) || (telno == "ERROR! Address not valid")) {
telno = "Phone # required";
action = "";
}
if ((validate(email)) && (email != "ERROR!") && (fname != "") && (lname != "")) {
action = "send";
loadVariablesNum (mailform, 0, "POST");
gotoAndPlay ("wait");
}
}
stop ();
__________________________________________________ _____________
Phone Number Validation, IndexOf
Hello,
I need some help with validating a phone number. I want to check if the length of the number is ten chars and if the first number is a "0" and the second number a "6".
This is my code so far.
Code:
form.send.onRelease = function() {
yournumber = form.number.text;
if (yournumber == null || yournumber == ""){
trace ("no number");
}
if (yournumber.length !=10|| yournumber.indexOf("0") == -1 || yournumber.indexOf("6") == -1) {
trace ("non existent number");
}
}
This only checks if there is a "0" and a "6", but not if they are the first and second char in the string.
Thanks for your help!
Jerryj.
Modulo(%) ?
Can someone post an example of how to use Modulo(%) in an equation? What is it used for?
I read something somewhere that gave me the vague impression it gives you a way to test for values ranging between a +/- value.
for example:
myNumber %= 100
is telling me what?
I hate myself for ditching Math in high school.
Cakk
Modulo(%) ?
Hi,
I am having an interesting issue with the Modulo(%) operator not returing the full number (all decimals) back.
Here is the code I am using:
b = x%1000;
Everything work fine until x = 10075 and b ends up being 75 instead of 075, which is what i want. See, 10075/1000 returns 10.075. I want the value 075, not 75.
Is there some way to force the full decimal return?
I have tried this:
b = Number(x%1000);
but it did not work either.
Thanks in advance.
nick
% (modulo)
I don't understand what this does. the AS dictionary brings up that is subtracts and divides, but that doesn't make sense.
example
1%5
% Modulo Help Needed
I was looking for a way to make put a menu like..
Item1 Item4 Item 5 Item 6
Item2
Item3
If i look 2 the modulo i can create it like
1 3 5
2 4 6
item._x = Math.floor(i/2)*150;
item._y = starty+30*(i%2);
or
1 4
2 5
3 6
item._x = Math.floor(i/3)*150;
item._y = starty+30*(i%3);
==============================
Some one with a solution ?
Modulo Help Needed
Hello there,
I need to create two lists from myItem.length;
But this length can be variable aswell.
How could i create this list with modulo?
Its something like.
1 5
2 6
3 7
4 8
thnx in advanced.
Modulo Things ( % )
hey guys how to use this modulo things. the one with the "%" .
-------------------------------------
% (modulo)
Syntax
expression1 % expression2
Arguments
expression1, expression2 Numbers, integers, floating-point numbers, or strings that convert to a numeric value.
Description
Operator (arithmetic); calculates the remainder of expression1 divided by expression2. If either of the expression arguments are nonnumeric, the modulo operator attempts to convert them to numbers.
-------------------------
what this text trying to say....
and how this "modulo" thing works..
can somebody tell me?
AS - Modulo And Negative Numbers.
Oooo, my first US2 forum thread.
Does anyone know of a way to use the modulo operator to clamp a number when the value of the number is negative?
I am clamping a number between 0 and 359 and can easily clamp the number when it is positive, but things go pear shaped when a negative number needs to be clamped. At the moment I am doing the following but really want to avoid using a loop for negative numbers...
ActionScript Code:
if( value < 0.0 )
{
while( value < 0.0 )
{
value += 360.0;
}
}
else if( value >= 360.0 )
{
value = value % 360;
}
Any solutions to this?
Strange Output From Modulo Operator
Here is my code:
Code:
var testNum = 18.82;
trace(testNum);
testNum %= 1;
trace(testNum)
testNum *= 10
trace(testNum);
testNum %=1;
trace(testNum);
Here is the Output:
Code:
18.82
0.82
8.2
0.200000000000003
Any Ideas why flash adds the 3 and all the subsequent garbage that comes from that. I was trying to run a while loop (testnum %1 != 0) but of course it never was equal to zero because flash always had a garbage decimal.
Displaying The Modulo % In Dynamic Text
I'm having a problem of loading my dynamic text which contains many modulo signs(%). Strangely, if my text file has the following line:
counter=The cost price is 150%, out of the total
the output will be: The cost price is 150 out of the total
I'm loading the text file and displayed as html under my dynamic text box. Please offer some advice of how do i go around this problem, thanks.
Modulo Curve Confusion Questionable Termination
Hi Everyone--
I'm trying to draw a squiggly line similar to a sine wave.
Have no experience using modulo or arrays, but I think I need them.
I want to use the curveTo function.
If the origin is (0,0) and the control point for the curve would be (10, 20), the next point would be (20, 0) the next curve through (30, -20) and so on...
the x series would be 0, 10, 20, 30, 40, ... or = 10 * i.
the y series alternates between 0, 20, 0, -20. If the numbers equal zero, then they're endpoints of a curve. If they equal either plus twenty or minus twenty, then they're the control points.
//Here's the logic I came up with for separating out
//the coordinates based on iterations of i. It feels clunky.
//Any way to simplify this would be appreciated.
this.createEmptyMovieClip("wiggleLine_mc", 100)
wiggleLine_mc.lineStyle(1,0x333333);
for ( i ; i < 50 ; i++) {
//this returns values 0,1,2,3.
mod4 = i % 4;
//this returns values 0,1.
mod2 = mod4 % 2 ;
//Will need to cycle through the loop twice,
//so I think I'll need this. Will return values 0,1.
mod2i = i % 2;
if (mod2i = 0) {
pointX = 10 * i;
}
else if (mod2i = 1) {
controlX = 10 * i;
}
//this returns whether it's a point or a curve y
//and assigns values.
if (mod2 = 0) {
pointY = 0;
}
else if (mod2 = 1) {
controlY = 20;
}
else if (mod2 = 3) {
controlY = -20;
}
if (mod2i = 1) {
wiggleLine.curveTo(controlX, controlY + 30, pointX, pointY + 30);
}
=======
This is the response I get...
Scene=Scene 1, Layer=Layer 1, Frame=1: Line 6: Statement block must be terminated by '}'
for ( i ; i < 50 ; i++) {
Scene=Scene 1, Layer=Layer 1, Frame=1: Line 34: Syntax error.
}
Why doesn't Flash read the "}" as the termination of the for loop?
Any help would be greatly appreciated.
Thanks,
Lee
AES Algorithm
hi ,
has anyone done any flash applications that requires the usage of advanced encryption standard(AES)?
anyone care to share some examples or provide some reading materials?
Algorithm Help
i need some help on code....
let's say there is an array....
a_lot_of_items = new Array("cap1", "cap2", "cap3", "cap4", "luc1", ...
"pet4", "jim1", "jim2", "jim3", "jim4", "cas1", "cas2", "cas3", "cas4");
i want to randomly select 9 items.... but of the 9 items 3 specific items
MUST be selected(the 3 specific items would be predecided).
can anyone give me a sample code?
oh, and the 9 selected items must not overlap with each other.
thanks in advance.
Pathfinding Algorithm
Hi All
I am working on a game platform in Flash.
I have made a isometric tileset, and made it posible to navigate from one tile to another.
But my problem starts as soon, as i place a object (eg. solid rock). Then my "human", will pass through the rock, as it was air. And that was not the idea.
What i need is a way to calculate the path - awoiding the rock. And going around it instead.
I have seen this done in C++ with pathfinding algorithms a lot of times. But how do i make a simular function in flash ??
I really hope someone can help me
Thanx in advance!
Algorithm Password
I am trying to create an executable flash file that requires a password entry system. The password needs to be generated from some sort of algorithm on the web and then checked against the username in the executable before allowing entry.
Can anyone help!!???
Much appreciated as always!
Calendar Algorithm
i'm trying to make my own unique calendar and need some help on how to
make the correct number of days show up on a particular month of the year.
any helpful links, algorithms, etc. would be greatly welcome.
A-Star Algorithm
Does anybody know where I can find an example or tutorial for an A-Star Algorithm using actionscript?
Ant Algorithm On ActionScript ?
hi every one....
i'm a student college who wants to build a flash application to find the shortest path using ant algorithymn. but i have not the refferrence about that???
does anyone know about that??
please send me the refference link....
thanks,
Dijkstra's Algorithm
Hi everyone,
I'm new to flash and I was wondering how can I put Dijkstra's algorithm to work??
Drawing Algorithm
Hello,
I am a student studying software engineering, I am currently writing my thesis evaluating the silverlight and flash players. One test i am carrying out is player rendering performance. I figured this would be the best place to ask a question regarding the best algorithm.
To get the most accurate test results essentially all i would like is the most efficient algorithm of looping through a base number (which can be modified) and drawing a native graphic to the player.
Also the best way to get the system time for pre and post rendering. I have already done this by the way, but i was hoping that by offering this up to the forum i could get the most accurate results and people could streamline the algorithms used.
my way in a nutshell ...
on button press - start test.
<get system time and store it >
<loop and draw >
<get system time and calculate>
If anyone is interested and willing to help me further in this evaluation thesis i would very much appriciate it. my email is
chiller149 <at> gmail <dot> com
Sorry for that, just to try and avoid the spam.
Thank you in advance,
James
PS. if this is in the wrong forum i opologise in advance
Finding An Algorithm
Hello all.
IU'm trying to create an algorithm so I can find out how many breaks there would be if I had a line wrapping a certain amount of columns.
so lets say I had 7 columns, and I needed to figure out, how many breaks there would be in the line if the lenth of the line was a certain number.
i.e.
length of the line is 7
columns are 7
this should equal 1 (it only takes up one line)
length of line = 13
columsn = 7
this should equal 2 (if it were 14, it should also = 2);
However, this also depends on a starting column.
if length = 7
columns = 7;
and start column = 1 (zero based)
lines should = 2
7 is constant, but could change. the width of each column shouldn't matter, but is constant aswell.
Any help would be appreciated.
Cheers.
Urgent. Need Algorithm
Well, I'm in deep trouble. I need an algorithm to place a number of icons randomly within a given space which is a 3-d simulated view of a floor. In one situation 5 icons, in another situation 50 icons. Can send png files of the views. Anyone?
Algorithm For Mode
hello, i need an algorithm (to be used in the Actions for a button) that will find the mode in a list of numbers (14 for now). i'm using flash pro 8.
Creating A SWF (Algorithm)
Everybody know how to? Not by pressing CTRL+ENTER in Flash, but by using a HEX editor or notepad, or something similar... In other words, What's the algortihm for creating SWF's??
AS To PHP Translation Of Algorithm
Didn't really know where to post this, so i'll start here. I have an algorithm that I used in a project, but I now need the same thing in php and I have no idea how to do it. Do any of you flash/php developers have any idea? thanks :$
ActionScript Code:
for (i=0; i<retArr.length; i++) { var pk:String = retArr[i]; if (this["order"+pk] == undefined) { this["order"+pk] = new Array(); this["order"+pk].push(retArr[i]); orderArr.push(pk); } else { this["order"+pk].push(retArr[i]); } }
It might seem unlogic but I simplified some of the code, because it was irrelevant.
Movement Algorithm
Dear All,
please check: http://www.andreas-burz.com/
Does anyone know where I might find an algorithm similar to that which controls the enlargement and movement of the thumbnails on this site's start page.
thanks in advance.
ash
Motion Algorithm
hi, i'm trying to get some particles moving in a nice random motion style, unfortunatly the only two types of random motion i know are brownian motion and motion you get using perlin noise. It so happens that brownian motion doesnt look that nice, and the as3 perlin noise classes by ron valstar run pretty slow when animating 1000 particles.
so, does anyone know how I could get some pretty random "nice" looking motion, I'm running out of google searches.
thanks
Good Random Algorithm
G'Day all,
I was just wondering if anyone had a good algorithm for getting three random values from list of values, none of these values can be repeated though
Algorithm For Multiplying Colors?
As you probably know, Flash supports alpha-ing one color over another. What I want to do is "multiply" (the way Illustrator and Photoshop does it... it's a filter that's slightly different than alpha).
I don't have to multiply entire images... just huge areas of solid color, so I just need a simple algorithm that does color multiplication. However, I don't know how it works!
For instance, these two colors:
R: 108 G: 161 B: 162
R: 26 G: 9 B: 128
multiplied together makes this color:
R: 18 G: 7 B: 96
It's not really multiplying the values together. What's going on here? Is there a simple way to do this? Does anybody know or know anywhere I can go to find out how to do this?
Thanks in advance,
~jimmy.
Algorithm For Line Curve
I want to come up with an algorithm, preferably in the form of a function where you provide three points, a starting point, a curve point, and an end point, and the function will calculate a curve that starts at the first point in the direction of a second point, and will curve so that it ends at the third point.
an example would be something similar to the interface at http://www.flight404.com/version7/index.html
Any ideas on where to start? or perhaps you could point me in the right direction?
Cheers,
Stwelin
Ease Command Algorithm
Hey Everyone!
Just wondering if anyone knew what the Ease Command's algorithm is. For instance, -80 = x FPS or perhaps it is -80 = x FPS + y (incremental) FPS. I've scoured the Internet looking for this information and still no dice....
Just wondering as I'm using a book that employs use of the Ease Command extensively and would like to change those references to an appropriate number of non-Eased keyframes. I suppose I could just "trial and error" it, but as the source for this command should be, uh, open source, I figure it must be somewhere...perhaps locked in a trunk in someone's attic under a host of books about the Sinclair ZX microcomputer.
Any help would be appreciated.
Spell Check Algorithm
I'm working on a spell checker. I have a basic one that works alright but it is only able to find if words are misspelled. I'm trying to come up with a decent algorithm for making spelling suggestions. Any help for this? I would be grateful for it.
Compression Algorithm In Flash
Hi guys,
Im working on a game where you have to build chains of words. And this game needs a pretty big dictionary to function properly. The dictionary is in plaintext about 1.5mb. I don't want to store all the words on the serverside, since the connection might become slow and in the game you have to be as fast as you can. So i wanted
to either load the file at startup or include it in the swf file(will it also be compressed? and what about the 15kb limit for as files? ).
So my question is, does anyone know an implenetation of some compression algorithm in flash? or maybe a way to solve this problem completely different?
thx for any ideas
-i
Simulation To Sorting Algorithm
hi everyone,i'm new in this forum & new to flashMX also, i need to do a trotorial that explains the "selection sort" algorithm, i need to use an array & variables to pass them to a function sort(); and when a user clicks button start, it starts working
thnx in advance
Porter Stemming Algorithm
I have a question regarding the Porter Stemming Alogorithm (http://www.tartarus.org/~martin/PorterStemmer/) and using it with ActionScript.
I know I should probably be using Actionscript II for this type of thing...but I havent gotten there yet.
Anyhow, the alogorithm is given in both Javascript and PHP (as well as a bunch of other languages). I want to push a word into it from Flash but I would rather not have to deal with other languages if I could port it over into Actionscript.
1. Do you think it would be possible to rewrite the javascript version into actionscript? How hard would this be if I dont know Javascript but do know a bit of code?
2. Or, do you think I should just suck it up and post a word to the PHP version from flash?
Which is the best way to do this and what would be the most efficient?
I'd appreciate any feedback anyone is willing to give on this subject.
THANKS SO MUCH!!!!
Help With Hex Based Entrapment Algorithm
Hi All,
I am working on a chess like game that can be seen here.
http://www.swarmboardgame.com/?q=node/6
At the moment I am getting the game to understand the rules before I try to build the A.I.
So far the game understands all the rules except 'one' rule, that is turning out to be a bit of a challenge to implement.
The rule in question is this...
Quote:
Multiple Piece Encirclement
You can capture any number of opponent pieces, by completely encircling them. In example 3, we see grey player capturing three black Player Pieces. Note how it does not matter that there is an empty space within the circle. Also note that because grey players Queen forms part of the circle, black players Queen is successfully captured (as described in rank capturing privileges below).
Example 3 is here: http://www.swarmboardgame.com/gfx/capture.gif
(I alreay have example 1 & 2 working correctly)
Just to give you a bit of background as to how I have implimented the game so far. I have one large array that is a representation of the board. It looks somethign like this..
ActionScript Code:
_root.board_map[_a1] = ['b1','a2','f1',false,false,false];
_root.board_map[_a2] = ['b2','a3','f2','f1','a1','b1'];
_root.board_map[_a3] = ['b3','a4','f3','f2','a2','b2'];
_root.board_map[_a4] = ['b4','a5','f4','f3','a3','b3'];
(through i8)
Where each element of the array contains a ppointer to a surrounding hex, moving clockwise, starting top right, rotationally ending top left. If an element is false it means its the edge of the board.
Note: This array has no idea of what pieces are on the board, it is just describing the board in memory.
I then have another array that has knowledge of what hex's the pieces are on. The second array looks something like this.
ActionScript Code:
_root.is_on_hex[_a1] = 'q1'; // the queen
_root.is_on_hex[_a2] = 'w1'; // worker 1
_root.is_on_hex[_a3] = false; // nothing on it
When working with the above structures I have an abstracted function that allow me to query/traverse the board structure which looks like so:
ActionScript Code:
function get_adjacent_pieces_to_hex(target_hex)
{
... some code here ..
return adjacent_pieces;
}
The above function returns an six element array that looks somethign like the following...
ActionScript Code:
// Query a hex to see what is surrounding it
adjacent_pieces = get_adjacent_pieces_to_hex('b5');
// The resulting array may look like
adjacent_pieces[0] = Array('c3','rq','red'); // red queen on c3
adjacent_pieces[1] = Array('b6',false,false); // nothing on hex
adjacent_pieces[2] = Array('a5',false,false);
adjacent_pieces[3] = Array('b4',false,false);
adjacent_pieces[4] = Array('c2',false,false);
adjacent_pieces[5] = Array(false,false,false);
Once again 0-5 = the surrounding hexes, moving clockwise, starting top right of the hex in question, rotationally ending top left.
Long story short. I need to use the above structure (and possibly the get_adjacent_pieces_to_hex() function), in some way, to work out if any pieces have been trapped according to the above 'Multiple Piece Encirclement' rule.
Phew! I think that explains it!
Any one got any ideas?!!!
Cheers,
JV
Algorithm For Bacteria Fissiparity
If I wanted to make a FLASH animation showing bacteria fissiparity i.e.
reproduction by division.
I.e. a clip representing a bacterium (shown, say, a s ball) which grows and
when achieving a certain size divides into two small ones and each in turn
grows and devides into two etc - what algorithm can be suggested?
The snag is that each bacterium needs to be independent in the sense that it
moves randomly and independently of all other bacteria. Also it needs to die
(disappear) independently.
Algorithm For Determining Variety...
Hey guys, it's been awhile,
I'm wondering if anybody has any ideas about an algorithm to see how many different variations there are within a set of data... For example, if I had:
1 1 1 1 2 3 3 2 1 1 4
The algorithm could figure that there are 4 different "types". I don't mean 4 numbers, because there are obviously more, but 4 varieties; of course, if I could be given a couple of hints as to how to go about count how many of the different types, that'd be appreciated, too. Thanks in advance.
Button Animation Algorithm In AS3
Hello AS3 GURUS.. need your help.. My logic is not that high for this one, and its very simple.
What I want to do is this..
I have 5 Button movieclips, each with different states, (OVER, OUT, and ACTIVATED)
Obviously when you rollover the button, itll play the over animation, itll also apply for the rollout event of the button. When you click the button, itll go to the activated state.
Here's my question...
What condition will i use so that when a certain button is activated and i click on a different button, the activated button will play its rollout state before going to its idle state.. What's happening to me is itll just quickly go to its idle state without playing his roll out animation. Thanks GUYS!!!
Interesting Algorithm Needed..
i am making an event timeline. it's based on years. negative indicates BC, so -300 == 300BC.
the algorithm i'd like to come up with would be as to how to place the events on the timeline dynamically. for example you could define a timeline of length 2000 pixels and then fit a set of say 40 events on that timeline.
the tough part is that some may be very far apart and then on the other hand you have clumps of 10+ over a short period. so how do you dynamically distribute them in a nice way?
i am doing a history timeline and our first dates are 3000BC, 400AD, 1776, 1820, 1840, etc..
as you can see it needs to accepts big dates. and you can see the pattern above where it begins to shorten out in terms of years between.
you want to see the close clumps at a more magnified time level.
thanks
|