Actionscript 3 :: Flash - How To Compare Alphabetically Two Strings
Dec 1, 2010I used strcmp(x,y) in C++. Do you know how to do that in as3?
I used strcmp(x,y) in C++. Do you know how to do that in as3?
How can I get the previous focus/be able to compare strings?
View 2 RepliesI want to compare two strings from two text boxes and see if one string in a text box matches the other. Been looking at RegExp but not having a lot of luck getting it to work.
View 2 RepliesI work on AS3 one week, and then take a break for a few weeks, then work on it a day, take a break, etc.. So I forget some of the basics, and need refreshers. I think I need to stop taking breaks.
Problem: I push multiple strings into an array, and some of the strings are the same.
Code:
var myArray = new Array();
myArray.push (Snivvle);
myArray.push (Kirupa);
myArray.push (Snivvle);
I want to find out which element positions "Snivvle" hogs up. We can see that it would be using element 0 and 2, and if we do an "indexOf" we would only get to see element 0, and doing a "lastIndexOf" we would only see element 2. How do I find out ALL of the element positions "Snivvle" is located in, so that it returns: element 0, element 2.
i have a combobox with instance name fonts and this code on frame 1:
Code:
fontAr = new Array
fontAr = TextField.getFontList()
[code]......
i have a combobox with instance name fonts and this code on frame 1:
Code:
fontAr = new Array
fontAr = TextField.getFontList()
[Code].....
it simply populates the combobox with all the fonts on your system...
but it is not very user friendly....
it would appear it orders them in order of date, which were last installed/made....
but if i am to actually USE this it would actually have some use if it were alphabetical...
so my question is this:
how can i re-arrange an array in alphabetical order?
I'm generating an XML file within a class I'm writing. Let's say this was the starting XML:[code]I want to add additional <element>'s. The first order of sorting is by "type", then "x", then "y". So if I add a new "type" of <element>, let's say type "Text", I want Text to be inserted after any "Image" <element>'s.[code]The basic idea is to keep the list sorted as I add more <element>'s to each <container>.The numeric sorting is simple enough, but I can't figure out a clean way to sort alphabetically.The only thing I can think of is to get the types into an Array. Add the "new type", sort and call indexOf()... the number SHOULD be the current position I should insert before?
View 2 RepliesI want to sort items in the datagrid alphabetically by name.The order should be:
1) The name should first check for upeercase of the name if it is not then it should look for lowercase for the same letter alphabetically.
For example : if i have array of items say{Apple,boy,ant,Bat) then after sorting the list shld be
Apple
ant
Bat
boy
In an alphabetically sorted array, I want to jump from one letter to another. So, when Im with a word beginning with a, I want to jump to the next item beginning with etc
Ive set up this simple script, which simply look at the first character of the current item, then loop in the (sorted) array until it finds a different first character It works very well hen descending! But when ascending, the script sees that there is character change but this is not the first item beginning with that letterbut the last one (since we are coming from bottom to top)
And of course I would like the script to give me the very first item beginning with a new letter.
(So, to summarize, I want to browse an array alphabetically, up & down, so that each time I press on the UP arrow key, I go up in the alphabet.and when I press the DOWN arrow key, I go down in the alphabet)
[Code]....
I didn't find any clear explanation how list in ComboBox could be sorted alphabetically. It's very annoying that this ComboBox takes data from array (label/data) in random order.
View 2 RepliesThe dictionary use strict equals(===) for key comparison, how to change the comparison, so I can use my standard for comparison, for example, I have a class named Student:
class Student{
var id:int;
var name:String;[code]....
I want Dictionary use id to compare if the two keys are equal, not use strict equal(===) to compare if the key is the same.
I have xml data that I can load into my flex app; however, I need to sort it by node.I'm trying to create a combobox or listbox that can display a list of locations sorting them either alphabetically or by the category they are in...
I can't get my head around how to format the xml or how to code the flash file to sort according to location name alphabetically and then press a button that will sort it by category 1st and second by name alphabetically.
Should I format the xml like this:
<POIs>
<location>
<name>Barbaras Bagels</name>
[code].....
I need to compare two arrays to see if they are identical.
var _array1:Array = new Array();
var _array2:Array = new Array();
_array1.push(1,2,3,4,5);
[Code]....
I'm wondering if there is a better way to approach this than my current solution...
I have a list of items, I then retrieve another list of items. I need to compare the two lists and come up with a list of items that are existing (for update), a list that are not existing in the new list (for removal) and a list of items that are not existing in the old list (for adding).
Here is what I'm doing now - basically creating a lookup object for testing if an item exists.
[Code]...
Why first trace prints out not second one whereas I set label in property panel to "hello"?
public function OnClick(event:MouseEvent) {
trace(event.target.label.toString());
if (event.target.label.toString() == "hello") {
[code].....
Comparison of number or string is understandable. But how come when in flash AS3.0, we do :
var a:TextField = new TextField();
var b:TextField = new TextField() ;
[Code]....
Is their some Application-wide ID, that flash gives to each component instance. Or is it compairson of the strings ( comparing the whole path of each component )
I have this textfile with a lot of words in it. One word on each line.
How can I compare a flash string to the lines in the textfile? I want to know if the string matches any of the lines in the file.
in php I could do:
$prices['ford']['mondeo']['2005'] = 4500;
$prices['ford']['mondeo']['2006'] = 5500;
$prices['ford']['mondeo']['2007'] = 7000;
[code].....
I have this code that activates when rollover, rollout, and release. I functions for rollover and rollout works, but the release function does not. I'm trying to pass some strings with url's to the function within a loop.
var url1:String = "http://www.google.com";
var url2:String = "http://www.google.com";
var url3:String = "http://www.google.com";
[Code].....
I have an external interface call which I need to pass several values to. Each value has an indentifier string and the value itself.
Code: ExternalInterface.call("submitIUR", answers +"promo", promo+ "url", nextUrl); The problem is that when I pass this through to the javascript function, flash concatenates the identifier strings. So for example if promo is 12345 when passed through the "url" indentifier gets tacked on the end so I get 12345url.
Is there an easy way to separate out the variables being passed through to stop the strings being tacked on to the variables?
I have an array of strings. Each string is a name of a class. How can I call the library item with the class name that corresponds to the string in the array?
View 1 RepliesI am working with a function that converts csv data to a multi-dimentional array. I am then going through the characters to find specific situations in the way the strings are handled in the array. One example is if I have a string like - "this is a string, yeah" - then I make sure not to count the comma in the string because it is between quotes from that string. Anyhow In the following function I have some how lost my spaces in the results.Instead of getting "this is AS3" I am getting "thisisAS3". Spaces seem to only be available in the strings that have quotes.
function CSVtoArray(csv:String):Array {
var inQuotes:Boolean = false;
var field:String = "";
[code].....
I have a Flash file which contains some dynamic text boxes. ActionScript is being used to fill these boxes using strings. However, I can't seem to get Chinese characters to appear properly. I've tried the actual unicode character as well as their unicode-escaped equivalent but when I export the movie, nothing shows up (blank - it was assumed that the characters are not even present).
View 3 RepliesHow would I achieve the following in AS3 or AS2.0. You have 5 sentences, you can select any of them with click button, they get stored somewhere in your flash file then you move on to something else like a movie playing and at the end of the movie you are presented with a screen showing the sentences you selected before...
View 2 RepliesI have an idea for something at work. I want to have stars hanging by strings from the top of my flash document. if the user mouses over these stars I want the star to lightly swing in the direction the mouse went over at. Almost as if you had a cardboard star hanging from the ceiling and you tapped it with your hand. I know this probably includes friction but my tests don't seem to work out the way I want. Does anyone know how to achieve this?
View 8 RepliesI've just developed a function to ring frequencies, but I can't make it sound like a guitar string, I can only change it's frequency. Is there some way to change other parameters of a generated sound?
function sineGenerateSound(event:SampleDataEvent):void
{
for (var i:int=0; i<4092; i++)
[code].....
How does one Compare Dates, as in
If (sampleDate is before TodaysDate) {
do something
}elseif (sampleDate is after TodaysDate) {
do something else
}
Is there any simple way to compare two arrays. i.e.; I have two arrays (a,b,c,d,e) and (b,c,d) after comparison I would like to get an array (a,e).
View 5 RepliesI've two Combo Box(cbFirst & cbSecond). I want to compare the value that has been selected by the user and based on the result, output is displayed. In both Combo Box I've provided the value.Here is my code:
var a:Number;var b:Number;
function First(evt:Event):void{ a = evt.target.value; trace(a); }cbFirst.addEventListener(Event.CHANGE, First);
[code]......
How to compare two audio files to see the difference of them.
View 4 Replies