I'm doing a little weather web app in flash.So i read an xml feed and copose an array of data from it.[code]Now what i would like to do is to find and trace the entry in mydate array which have a a value that approach the most to "currenthour" variable (which is my current time i'm getting upper).For exemple if currenthour = 11.In the case that i have myhour array equal to 5 , 10 , 14 , 20.The best match will be myhour[1].
Why code below traces "False". I am nearly sure that it has to be "True". Code: var a1:Array = new Array(1,2,3); var a2:Array = new Array(1,2,3); trace(a1 == a2);
I have a small problem with my script, and its due to the dates in the array. I have tried writing the dates in a different way, and that works well. However I need the dates as they are now, because of an other function later on.[code]...
I'm trying to figure out how to determine if the 2nd array contains the same number of items, and all correct, as the first array:Code://For my purposes, if the user selects answer "B" they get an incorrect response//but if they don't select "A", "C" and "D" together, they also get an incorrect response// Need to know which item of arrayA is missing from arrayBArray.prototype.filter = function(arr) {
I have 2 arrays that contain the same values but in a different order. i'd like to reorder the first array like the second one but i have no ideas how to do that easily.
WHY would I use this pattern to hold variables accessible to other swfs throughout the project when I can just keep them in the container movie and access them as desired.Is there any advantage like optimization, security, ease of use etc..how I access a varibale in a parent mc unless answered here too as it is in the same category.Is it best to access a varibale in the parent using
1. MovieClip(parent.parent).variableTargeted OR import com.parentAsDocument; And then access the variable
I'm trying to cut down the amount of code I type to complete a project. Using things like ?: and &&= over the typical if statements. Is there a way to compare a single variable to a group of variables? example...
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 am building a quiz game. I generate a random number. I then compare the number to an array of questions already asked. If a question has been asked, I need to generate another random number and check again if this questions has been asked, until I find a question that has not been asked. I am getting lost in all these loops.
var completedQuestions:Array=new Array(); function getQuestion() { var qnumber=randomNumber(0,numberOfQuestions-1); //I did not include the randomNumber function as this is not the problem
I'm looking to compare the lengths of several arrays in a conditional loop to make sure they all have the same length. At the moment there are only three arrays which can be bodged with an && operator in the conditional, but I want something more elegant and expandable.
I initially tried this, but found to my suprise that it doesnt work:
I am trying to compare a user inputted string to a variable already created. When I do this with int it works fine but when I try changing it to strings I can't get it to work.
I am working on a project in which I am suppose to maintain an array of movieclips, and I can also convert the movieclips into bitmap data. So I would like to know which one is the best to use either maintaining movieclip array or bitmap data array.
I need to compare a number with a element in a Array(curModeDisplay), I can trace the element and see it without problem. But when I try to compare the inside element with a String, it didn't work. Why?
ActionScript Code: curModeDisplay = new Array(); \this is the Array I need for (var tvM:XMLNode = tv.firstChild; tvM!=null; tvM=tvM.nextSibling){ curModeDisplay.push(tvM.childNodes); \received element fine here } trace(curModeDisplay); \ This works fine. Array displays correctly
When I need those elements from the Array(curModeDisplay) and try to make some comparison work, it did not work:
ActionScript Code: function DigitCompare():Void{ for(var index in curModeDisplay){ if(curModeDisplay[index]=="11265"){ //it seems didn't work here
[code]....
Is that because the element in the Array is reference to the XML node, and "11265" is String. If so, how should I fix this problem. The "11265" will be changed to any named String type variable in the future.
Assume I have an array with references to different display objects on the stage. The display objects do not have any other explicit references except for the array indexes. How do I evaluate if a certain index of the array is a reference to a certain display object?Some code to clarify:
I am creating a card game application in that dynamic movieclips created on stage and inside those movieclips different cards can drop, which have some values.
If one movieclip contains one card and another movieclip contained two cards and all the other movieclips 3rd,4th,5th.. etc contains some cards then, if i want to go back and want to drop another card at the top of the old one, than how i can do this, because when i go back and drop a new card inside movieclip than it replaces the old one. i don't want to create a new array for each movieclip.
How to compare a string with strings inside an array for a match? I have a file in which each sentence (or word) (generally string) is present in a new line. Opened the file and read the contents to a string.
Code: private function readHandler(event:Event):void{ _str = _readStream.readUTFBytes(_readStream.bytesAvailable); _strArray = _str.split(" "); //contains each string that appears in a new line _length = _strArray.length; [Code] .....
But this doesn't work. Seems like if(_input == _strArray[i]) never gets executed even if they are equal. What might be the problem. Is there some better way to so it?
I have a text file called testa.txt,In it it reads simply var2=value1When I test the code the text file loads properly.I have two dynamic text boxes. (This is all in a single frame for the whole movie on one layer)One text box dyn_text displays what it should: value1The second text box dyn_texta is supposed to tell me if what the value of dyn_text = value1 or not (is true) (YES or NO)dyn_texta is always telling me NObut I can't get it to work.Could you please tell me how to fix this?Code here:
Code: myData = new LoadVars(); myData.onLoad = function(){
i have 2 set of textbox, 1 set of the text box contain 6 textbox and the other set of text box contain 12 textbox. how do i make it like for the first set of textbox to compare with the second set of textbox? eg. 1textbox1.text = 2textbox1.text and the first set of textbox right, each of the 6 textbox have to compare with second set of textbox which is 12 textbox.
The 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'm going to post the full code of the two functions, disregard the "fluff" unrelated to the two functions as it is all working flawless, I've tested this HEAVILY and cannot understand why it keeps setting the entire array to undefined!
Code: // processReplace Function function processReplace(transferFiles) { var processArray:Array = transferFiles.slice();
[Code]....
Basically it's supposed to check to see if the file exists and return as true if it does and add it to a replace array, then the replace array is processed into a single string and put into a dialog box through the flash wrapper prompting them to "replace the files or not".
It makes the replace array just fine, it actually even has the right "count" in it but it's setting all the "filenames" to undefined because of the exists = processSearch function.
I even tried to make a new array and run the search just from that one and set the values from the old one and it's still failing.
Is it because of the "break" or can anyone figure it out? Iknow it's hard because you can't use the code
I want to change the value of a variable listed in an array using the array. for example:
Code: var theVariable:Number = 15; var theArray:Array = [theVariable]; now if I try this
Code:
theArray[0] = 20;
I just get an array with 1 value of 20 in it and it no longer references theVariable what i want to do is change the value of theVariable with out removing it from the array but referencing it from the array in a loop or something.