I have this code which tests if another grass instance is next to the current one. So far so good. The trace statement correctly outputs when it finds an instance nearby. The first time this will say: "instance1 100,100 found instance3 97,100 nearby" which is correct. But further down the code when I do the hitTestPoint, the wrong instance is in the array. Instead of saying "testing instance3 97,100 97,100 true" it has instance1 in the array and says "testing instance1 100,100 97,100 false". How can that be when I put instance3 in?[code]
I've got two rather large arrays which I put a bunch of movieclips into and I'm just stumped on how I can possibly track if a specific movieclip in the array is right or wrong. Determing right/wrong is something I need to be able to set and then check again later when a function getItem is called.
I've got two rather large arrays which I put a bunch of movieclips into and I'm just stumped on how I can possibly track if a specific movieclip in the array is right or wrong. Determing right/wrong is something I need to be able to set and then check again later when a function getItem is called.
I just quickly made this example code because the actual file's code is much longer and contains a bunch of other code that is irrelevant to this issue.
Code: Select allvar mcArray:Array = new Array(); mcArray = [movieClip01, movieClip02, movieClip03]; button.addEventListener(MouseEvent.CLICK, getItem); function getItem(e:MouseEvent):void {
Bumped into a problem and don't understand why this is happening. I got _root timeline, there I placed mc.map (movieclip), inside it I got a button, and on that button I placed this code:
Code: on (press) { trace(this._name); }
And in the output window I see the name of the movieclip instance ("map"). Why? I need it to refer to that button...
I am curious if this is an okay implementation of the Array.filter() method.
[Code]...
I was not able to figure out an implementation of the callback function for the filter() method, where the callback was outside of the getGallery() function. I wonder if there is a way to get the isGallery function outside of the getGallery scope?
Does creating a new instance of an Object that uses an identical name to an older instance, delete the previous instance? Or should the original instance be deleted first? The code uses a ridiculous amount of XML vars. Isn't it less memory intensive to parse the XML and save the properties to an Object, and then delete the XML Object, rather than keep the XML Object around and reference it's child nodes directly? Is it better form to break up a huge XML file (>600lines/3200vars) into smaller chunks?
I have some movieclips on stage each with an instance name like this: 101, 102,103,104.. etc.When I click one of them, it's istance name is added in an array:[code]I've got a button on stage too and I want when this button is clicked to change the Y of all the selected movieclips:[code]
I have a bunch of buttons on stage, and i want to place all of those buttons names in an array so i can assign an event listener to them easier. What i have is:
Code: var btnArray = new Array["btn1","btn2","btn3","etc...."]; for(var c=0; c<btnArray.length; c++) { btnArray[c].addEventListener(MouseEvent.MOUSE_OVER, doSomething); }
This should be simple but I can't come up with or find the answer anywhere. All I want to do is create a series of Arrays with instance names generated on the fly. I then want to reference these later. I have a "for" loop with a variable "count" that I want to add to a base name of rowArray and use the result to create an Array. I would think that it would look something like this:
I'm making a tile based game in AS3. Now I need to check a collision between the player and each tile (which are created in an array with 300-something instances). I want to do that in my Main class. The player is in a class called Level and the tileArray is in another class. When I execute, I get the classic #2007 error - "Parameter hitTestObject must be non-null".
MAIN
public function checkCollision():void{ if(_level._tileSetBMP._tileArray[0] == null){ _level._tileSetBMP._tileArray[0] as flash.display.DisplayObject;
[Code].....
What can I do to make a hitTest with each of the [0]-instances of the array?
I have just started actionscript after a long break, I am creating a crossword and each box is an 'Input Text' field. Since there are a lot of text fields, I do not want to have to create variables for each text box,I wanted to do something like this:
ActionScript Code: var inputs:Array = new Array( "_1a", "_1b", "_1c" .. ); for( var i:int = 0; i < inputs.length; i++ ) {
How do you pass instance names into arrays? I've got a bunch of movieClips of states.
They all have instance names.. alabama, arkansas, delaware, florida, georiga, etc..
I am trying to send them all to an array because I need to be able to disable the movieClips all at once and I don't want to call each one separately. I setup an array and a "for" loop, and it properly gets each value in the array:
ActionScript Code: states = new Array(alabama, arkansas, delware, florida, georgia); stateslength = states.length;
I am creating movieclips into which I want to load thumbnails which are to be loaded dynamically. I'm not sure if the solution I am trying to build is the more effective way to do this; I'm still quite a noobie.
Each movieclip container which I will use hold the thumbnails is of a size to hold 16 thumbs, so the number of holder movieclips required is calculated at the time the xml loads; with the movieclips then being created, named and stored in an array. (The idea is to then move between these movieclips (and so the thumbs) using previous and next buttons) - however, I'm not at that stage yet!
However, when I call each movieclip to place the loaded thumbs in, the code throws the "#1010: A term is undefined and has no properties" Error. I think this is a problem with the array; and possibly the mc not being defined properly. However, I am not sure where my problem is.
I created an Array of lrgIcons that contains several MovieClips, they are then positioned within a second MC and pushed to a second array of lrgIconsOnStage, they are enabled as buttons and assigned an event listener (all of this works fine). Problem is, I want to know which lrgIcon is selected and react to it with an if statement. When I trace the array of lrgIconsOnStage I get [object amazonLrgIcon],[object emailLrgIcon],[object gmailLrgIcon],[object messagesLrgIcon],[object missedCallsLrgIcon] and when I trace e.target I get [object amazonLrgIcon] (depending on which item I selected, which in my mind, should trigger the code correctly, but it does nothing, Why?
Code: var currButton:String; var lrgIcons:Array = new Array(amazonLrgIcon,emailLrgIcon,gmailLrgIcon,messagesLrgIcon,missedCallsLrgIcon); var lrgIconsOnStage:Array = new Array(); var lrgIconPosY:int = 69; var lrgIcon:MovieClip; [Code] .....
Code: var enemyArrayOneA:Array = new Array(); for (var i = 1; i <= 84; i++) { /*
[code]...
I try to use race("mc.main1.a_0" + i + ".x = " + enemyArrayOne[i].x); and it doesn't work...I'm trying to find out if I can store instance names of movie clips inside an array and retrieve the movie clip's x and y positions.
I'm trying to keep track of several movie clips with an array, but I'm running into some issues. I'm making a shooter game that requires hitTesting a list of projectiles and removing the projectiles from the list when they leave the screen or hit stuff. I've got the projectiles being added to the stage with this:
[Code]...
At first that appeared to work fine, but the bullets aren't always removed in the order they were created, so when I remove one from the array in this manner, it shifts the index numbers for all the ones that came after it back one, thus making their "num" variable no longer correspond to their index number; so when they try to splice themselves, they end up splicing the wrong ones. (Like, if I removed [3], the bullet that was in [4] is now in [3], but it doesn't know that, so it tries to splice [4], which now refers to whatever was in [5], and so on.) What's the correct way to handle this kind of situation? I feel like I must be missing something obvious, but I haven't been able to figure out a solution.
Is it possible to return the index of the first instance of a specified value within an array? Similar to:
Code: var my_string = "string"; var index = my_string.indexOf("g");
/*Outputs:
1 */
Basically, I have two arrays, each with 10 values (in slots 0-9 of the arrays). So I need to see if an array has a specified value in it, but then I have to see if the other array has a certain value in it, in the same spot as the first instance of what I search for in the first array.
I worked again on a new Project and stumbled while trying Arrays. I have two cubes(cube_mc, cube2_mc) in my scene.
My code: var gy:Number = 0; var gravity:Number = .2 var moving:Array = new Array(cube_mc, cube2_mc); this.addEventListener(Event.ENTER_FRAME, gravityFUNC); function gravityFUNC(event:Event):void{ gy+=gravity; moving.y+=gy; };
I was trying to put both cubes into the array, and then affecting the whole Array with gravity. When I test it nothing happens, and it shows no errors.
i have four buttons instances (of same object) on the stage first_btn,second_btn...fourth_btn). i created an array (btnArray) and stored buttons instance name in it. After this i created an timer event to cycle through all the button for certain interval.the code is:-
function timerListener(e:TimerEvent): void { while ( i <= (btnArray.length - 1)) { trace(btnArray[i]);
Alright, so really I am having 2 difficulties here.
1) When a bullet hits an enemy, if 2 zombies are beside eachother, the bullet hits them both -- How can I make it so the bullet can only hit one?
2) When an enemy has health of 0, it dies, I am trying to get the enemy to be removed from the array that the bullet searches through so it will no longer be affected by the enemy, but it doesnt seem to work, the bullet still hits where the enemy was, as if the enemy is invisible.