ActionScript 3.0 :: Array Syntax Object Reference In Loop Takes 4 Seconds To Run?
Nov 9, 2010
Can anyone tell me why the following is taking 4 seconds for Flash to execute:
_moleHoles = new Array();
var countingMoleHoles:Boolean = true;
var holeCount:int = 0;
[Code].....
There are 9 object on the stage (but this number could go up or down, that is why I'm dynamically grabbing these this way). So in my test case, this loop runs 10 times.
I have narrowed it down to something to do with the following line:
if (this['moleHole' + holeCount])
Is using dynamic (array syntax) object lookup that much of a performance hit?
var myData = new Array(); myData["name"] = "John"; myData["Age"] = 35;
What is the syntax to loop through and get the key and value? I have tried for each and for in but they just give me the value of "John" or "35", how can I get the key e.g. "Name" and "Age"?
I've got this loop and can't get it to work. It won't read the trace so I know the array call in my function statement is wrong but I can't see it at the moment. What am I doing wrong here? The rollover works when I write it out repetitively for the four buttons.
var btnAction:Array = new Array (oneBut, twoBut, threeBut, fourBut); for (var i=0; i<btnAction.length; i++) { this.menuMC.btnAction[i].onRollOver = this.menuMC.btnAction[i].onDragOver = function() {
I've got this loop and can't get it to work. It won't read the trace so I know the array call in my function statement is wrong but I can't see it at the moment. What am I doing wrong here? The rollover works when I write it out repetitively for the four buttons.
var btnAction:Array = new Array (oneBut, twoBut, threeBut, fourBut); for (var i=0; i<btnAction.length; i++) { this.menuMC.btnAction[i].onRollOver = this.menuMC.btnAction[i].onDragOver = function() { trace("anything"); } };
My flex app has a call in it to navigateToURL(new URLRequest(_rURL),'_self');
But it takes about 3-5 or even more seconds before it will leave the current page.
If I omit the '_self' the new window opens immediately and the page loads immediate...but only when I set it to _self I get a few seconds of a delay before it loads...I have no idea why but it is annoying.. I am wondering if anyone might have any idea why this is happening or anything I can do?
I am trying to connect to the Flash media servers from behind a customer's firewall.From behind this firewall the time taken for a response (its usually success) is around 20-25 seconds.The following is the code I am using to make the connection and listen to the events
var nc = new NetConnection(); nc.addEventListener(NetStatusEvent.NET_STATUS,netStatusHandler); var time1:String = (new Date()).toTimeString();[code]........
The delay between time1 and time2 is always 20-25 seconds. From other firewalls and non firewalled networks its usually 3-4 seconds.What could be the reason for this huge delay for a response in this case. I have noticed that the first response is always a "NetConnection. Connect.Success".We are looking to deploy around 20-30 media servers if we can get this thing to work and appreciate any prompt response in this regard.
I send to the function a movie clip that I use for drag and drop, so when I drop this function is called. The problem is that of the three rectangles that I use for contain the others, only the last senses the drop target.
I'm working with Flash Builder 4.5 on an Actionscript project. I've created the following classes:
package { public class ComplexNumber {
[Code]....
but the code inside this loop generates the following run time error: "ReferenceError: Error #1056: Cannot create property 0 on ComplexArray." Thus, my code for "BXFN_complex[ii] = ~" is incorrect. Anyone know how to achieve what I'm trying to do? Basically, ComplexDivide.v1p0 returns two numbers, and BXFN_complex is an object containing two number arrays, and I want to assign the ComplexDivide two numbers into the ii'th element of arrays in BXFN_complex.
I have been getting this Type Error 1009 at the following Loop: ActionScript Code: private function Loop(e:Event):void { for(var i:int=0; i<walls.length; i++) { if(hitTestObject(walls[i]) && hits > 0) { explodeX = this.x; explodeY = this.y; [Code] .....
ActionScript Code: parent.removeChild(this); But that doesn't work. Still get the error
In the code below, i create an object and stick it in an array, then I make a duplicate of that array. I loop though the duplicate and change the value of one of the props of the object in the duplicated array. Doing this however unintentionally changes the prop value of an object in the original array. I'm assuming that the objects in the duplicated array are mere references to the objects in the original array. Is this correct? And if so, how do i make unique copies of those objects in the original array, so that changes made to the objects in the new, duplicated array are exclusive to those objects?
I know that i could probably make a new object when duplicating the array, and then recreate each prop, assigning values from the original objects.. but this is a simplified example. The project im working on has many props for each object, so, id rather just make copies if at all possible.
Code: var testObj:Object = new Object(); testObj.prop1 = "hello"; // var testArr:Array = new Array();
I'm having trouble with my code. I keep getting this error TypeError: Error #1009: Cannot access a property or method of a null object reference. at Test_fla::MainTimeline/frame1() I believe it has something to do with the array, considering it works when I remove the array stuff. What I'm trying to do is to be able to move objects through an array with my gravitate() function in the Grav Class.
stage.addEventListener(Event.ENTER_FRAME,onLoop, false, 0, true); for(var i:uint=0; i < numParticles; i++){ var p:Grav = new Grav(5, 0xff0000, Math.random()*250, Math.random()*250); addChild(p); particles.push(p); } function onLoop(evt:Event):void { //for(var i:uint=0; i < numParticles; i++){ //particles[i].gravitate(1,1); //}}
I keep getting the #1009 error coming up, i checked that everything was on my stage and was named correctly.This is the error message that comes up:TypeError: Error #1009: Cannot access a property or method of a null object reference.at Videogame_fla::MainTimeline/loop()Here is my code:
var carrot:Number = Math.floor(Math.random() * 460) +0; var carrot1:Number = Math.floor(Math.random() * 460) +0; var carrot2:Number = Math.floor(Math.random() * 460)+0;
I've got a for loop and some fuctions working, but can't get one line of code to work. The red line below is what I'm having a hard time with. I'm calling a function called "moveit". If I insert moveit(x1, y1); then it works, and my movieclip is moved to the x and y positions that I specified for item #1. Though I want it to work for 10 items (I only have coordinates for two here, and will add the rest later).
I've searched my ActionScript book and just can't figure out what the syntax should be for calling that function.
I have put all button inside movieClip called "container" and I have added "container." inside for loop and now I am getting errors. for (i=8; i<15; i++){ container.this["button" + btns[i].name.replace("btn","")].mouseEnabled = false; }
what I'm trying to do is access the data of several movies clips, that are inside of several other movie clips: MC1.insideMC._visible=false (which works, but isn't dynamic) but dynamically with a FOR loop. I've tried: For(bullet=1; bullet<5; bullet++){ "MC"+bullet.insideMC1._visible=false (this does not work) } Does anyone know the dot notation or another way to do this?
One strange thing happened at application, connection to the fms server takes few milliseconds but shared object takes few second (more then 20) to connect.
I am creating a flash animation using flashEFF animation components. The animation isn't looping like it's supposed to be at the end of the animation, so I would like to hard-code a replay after 20 seconds. How would I use AS3 to loop reset to the beginning after 30 seconds?
I've imported a flv video (flvPlayer, instance name) to loop with the following script: var myLis:Object = new Object; myLis.complete = function(){ flvPlayer.play(); } flvPlayer.addEventListener("complete", myLis); I would like the flv to pause for 3 seconds before looping again...
_xml.group1..image[i] _xml.group2..image[i] _xml.group3..image[i] _xml.group4..image[i] _xml.group5..image[i] Im trying to reference each object thus: _xml.group[myVariable]..image[i]
I'm trying to create a loop of a phone that rings every 5 seconds using the Timer Class. The problem I have is when it gets to function stopRing and noRingTimer.start(); it goes backs to function onTimerComplete not the start.