ActionScript 3.0 :: Using IndexOf Is Faster Than Using A For Loop?
Jun 23, 2010Does anyone know if using indexOf is faster than using a for loop?
View 14 RepliesDoes anyone know if using indexOf is faster than using a for loop?
View 14 RepliesI have a function that finds the smallest five numbers out of an array of values and returns their index numbers. Here's a block of code from that function[code]...
The whole thing is slow, but I imagine that indexOf() is probably the worst offender. Is there any more efficient way to correlate a series of minimum values with their indexes without having to use indexOf()?
The values don't necessarily have to be stored in _elements, but they're pulled from a multidimensional array so I figure that it's the most efficient I can get at the moment.
I'm wondering which is faster in AS3:
array.forEach( function(v:Object, ...args):void
{ ... } );
Or
var l:int = array.length;
for ( var i:int = 0; i < l; i++ ) { ... }
My question is, does a better, faster CPU necessarily equal faster SWF compile times? Or does it rely on something else (OS, memory, etc). I only use AS3 and some of my projects take a while to compile. If certain hardware can guarantee me a faster compile time, it'd be worth including those things in my shopping list.
View 2 RepliesI can make a normal preloader, with a bar and percent shown and so on... But I want to make a little thing in the middle of the preloader that rotates faster and faster when the percent loaded goes up. This is what I thought would work:
[Code].....
[code]in my original code..function "test" will change the x axis of the images by Timer..I wanna the x axis of the images can be changed after every two seconds..but when I run it..it's obvies faster and faster every time when the Timer dispatch the TimeEvent the delay always shorter than the last time.
View 7 RepliesWhen trying to do indexOf on a "static" array, it works, doing the same thing on an array populated with xml, i always get the result = -1Static Way
var myarray:Array = new Array("Pub Pepsi","Shadow E-Bike","Icon Air Craft","Test","La page 4","La page 5","La page 6","La page 7");
var myresult:* = myarray.indexOf("Icon Air Craft");
[code].....
I can't get it two work. If I replace mySide with a hard coded movieclip name it works, but not with the variable. Am I missing something or just barking up the wrong tree?
var dots:Array = [north_mc.dot1, north_mc.dot2, east_mc.dot1, east_mc.dot2, west_mc.dot1, west_mc.dot2, south_mc.dot1, south_mc.dot2,];
var mySide:String = event.currentTarget.parent.name + "." + event.currentTarget.name;
[code].....
In ActionScript3 i wanted to get the text between 2 quotes from some HTML using a input index value where i would simply increase the 2nd quote characters value by 1. This would be very simple however i have now noticed using indexOf does not seem to work correctly with quotes and other special characters.[code]...
View 1 RepliesI have a list object and I'm adding items to it with addItem through the dataProvider.Before adding an item to the list I want to make sure it's not a duplicate. I've tried using indexOf on the dataProvider and it returns null. I've tried casting it to an array and it works, but always returns -1 even if the element exists in the dataProvider.The only method I've been able to use seems a little hacky and I'd like to know if there is a better way to find an element in a dataProvider.
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" styleName="plain" applicationComplete="init()">
<mx:Script>
<![CDATA[[code]............
I'm trying to serach for the following string "Type/Pages" in long external files and am using the follwoing code which works: indexOf("Type/Pages");
However, sometimes it appears in the file as "Type /Pages" - with the extra space
As the files can be VERY long, I don't want to search twice - is there anyway to search with or without the space?
I've tried all sorts of cominations with s* but to no avail
I'm using the indexOf method to search for a substring in a String variable in Actionscript 3. The indexOf method allows you to specify a second, optional parameter - the starting position for the search. However, I'm not sure whether the position returned by indexOf is relative to the very beginning of the string, or to this optional parameter.
View 1 RepliesI 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".[code]This only checks if there is a "0" and a "6", but not if they are the first and second char in the string.
View 4 RepliesI have a XML searcher thingy made and for the results in it I want to only display, lets say 50 characters to either side of the word that is searched. I am reading from a XML file and I am using indexOf to ge the current location of the word.
View 2 RepliesIs there a way to make IndexOf not case sensitive?
View 5 RepliesIf i have an associative array like this for example:
Code:
var arr:Array = new Array();
arr.push({name:"John", last:"Doe"});
[code].....
I am embedding the sowpods dictionary into an array in AS3 then submit searches using indexOf() to verify existence of the word. When I load a smaller text file it seems to work but not the larger. Since the file is embedded during compile, there shouldn't be an event for loading to listen to right?
Code:
package {
import flash.display.MovieClip;
public class DictionaryCheck extends MovieClip {
[code]....
I`m trying to set-up a script that changes the color of a movie clip, depending on the current url of the page... My code is:
Code:
var link = "http://localhost/v-v/indexSRP.php?kategorija=";
var link2 = "http://localhost/v-v/index.php?kategorija=";
if (_root._url.indexOf(link + "3") == 0) {
[Code].....
is there a way to find the index of the return character inside a dynamic text field?here is what i am trying for this example i have a dynamic text box on the stage with instance name "distractor_txt"
Code:
stop();
var str:String = "this is my string
with a return";
distractor_txt.text = str;
[Code]...
"what if i want to find all the what's in this sentence full of what's?" i cant do this with indexOf, and it wont work either with lastIndexOf, since there are 3... i'm trying to do a simple htmlText editor and got stuck in the part where i cant check the selected word's position only with indexOf...
View 5 Repliesvar asdf:Array = [ [1,1] ];
trace( asdf.indexOf( [1,1] ) ); // -1
Why can't indexOf() find the [1,1] array?
I am making a flash game and I am trying to make it as efficient as possible. I need to set a timer and then do something after the timer runs out.So, that being said I am wondering which method would be faster (or more efficient):Making a timer object and listening to the TimerEvent.TIMER_COMPLETE or in the ENTER_FRAME event of the game checking a Boolean (time) and then if it is true, incrementing a variable until that variable is equal to x, then performing the operations.
[Code]...
so as my title says. I'm wondering if specifying the datatype in actionscript 3 on variables actually makes code run faster
View 1 RepliesWhat is faster Flash or Silverlight? So I mean there is working Flash quake and Silverlight quake (not totally working yet)
So what is faster after all? Or Are they all same speed?
really need to know to get an idea on what it's better to start my cool programming project.
On a button click I would like to accelerate at a specific moment the movie (from 24 frames per second to 60) and then slow it down again to 24 frames per second.
View 2 RepliesI've created a flash interface with action script and the whole shebang for the web. It takes hours to load and I've seen sites with even more pictures and information load faster. I've compressed all my pictures and implemented various UI loaders to spread the load time out but it still takes a while. Does anybody have any tips and tricks to make my flash load faster?
View 1 RepliesI'm working on a project which draws circles continuously at framerate and animates them around the stage and I'm running into performance issues.
I'm already converting all objects to bitmapData as soon as they become static. My question is, will converting the circles to bitmapData as soon as they are drawn increase performance? In other words, is animating say, 200 bitmaps (with transparency) faster than 200 vector circles?
Are there any drawbacks to this technique? (I'm thinking opacity problems maybe?)
If they were more complex shapes than circles would the answer be different?
Compared to native apps, my Flex application runs like a hog born by a snail, especially on mobile devices. What tricks can I employ to optimize it's performance
View 3 RepliesI am using sendAndLoad to query a database that returns over 30,000 records. While the query itself is executed in 0.43 seconds (says phpmyadmin) the sendAndLoad takes some 15 seconds to be executed in AS2. I am wondering if there is a faster alternative to this method.
View 2 Repliesi've been kinda notified about loading external SWF's into a main time line and then some how positioning them where they are suppose to be. But heres my problem. My site is set up much more different then the typical flash website. the
ActionScript Code: gotoAndPlay(50) to go the certain links isn't on the main time. Its actually in a movie clip on the main page that when you click expands out and you can hover over/out of the links and all they do is show a little bit of content. I'e looked at what has the most MB's and it is my background. Just because it is very large. like 22 INches large. (It is scrollable with the mouse) But the background stays constantly there through out the whole time the user is on my website. How would I make this site load much faster. It takes like 5 mins to load my website.