ActionScript 3.0 :: Reference Parts Of An Array And Keep Both Instances Updated?

Dec 20, 2011

long title i know. This concerns the data handling for a physics engine i'm writing. At the moment, i divide objects in my engine, into three broad groups (2d arrays), which allows me to save on a lot of processing. every object has an array for its records which is held inside one of the three main arrays. however, this division is causing more processing work in other spots, particularly where finding things is concerned.

what i'm wondering is if it would be possible to make a master list, but still keep my three smaller arrays, and for an object's records to be synchronised regardless of whihc place i update it. actually going and synchronising it would be extra work that kind of defeats the point, but what i hope to do is reference object records from the master array, so thst both the master array and the three small arrays hold references to the same data objects

View 1 Replies


Similar Posts:


ActionScript 3.0 :: Loading Certain Parts Of An XML Through An ID Reference?

Sep 30, 2009

I have an XML document with different companies and links to different text sources such as "about" etc for each firm.

Now in my company presentation class I want to send an ID reference so if a user clicks on Microsoft the links point to Microsofts information etc. Im loading all other information through another XML and everything works fine, its just the links I cant seem to figure out.

This is my XML

ActionScript Code:
<?xml version="1.0" encoding="utf-8" ?>
<data>
<company id="1">

[Code]......

View 1 Replies

ActionScript 3.0 :: Flash Updated CS4, Code Returns #1009: Cannot Access A Property Or Method Of A Null Object Reference?

Jun 7, 2010

I have two MC's on stage,

MCmenu is a button array,

MCtext is a collection of text with frame labels. It's labeled as MCtext

The menu buttons tell MCtext to play the frame label as the button clicked. This *used to work*, but Flash was laggy as hell so I updated it. Now the same code returns #1009: Cannot access a property or method of a null object reference. at MCmenu/itemClicked()

Code:
function itemClicked(butn:Event):void {
parent.MCtext.gotoAndPlay(SomeArray[butn.currentTarget.label);
}

I've tried just using a frame number, but still the same #1009

I've tried the Script Assist to target the MC on the stage:
using root.MCtext... still the same #1009
using this.MCtext... returns a #1010

View 1 Replies

Flex :: Get Updated Array Length?

Mar 13, 2011

I am trying to get the length of an array through mxml (not actionscript). I have the following:

<s:Application
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"

[Code].....

Why does test2 show the correct array length but test1 is stale?

View 2 Replies

ActionScript 2.0 :: Splice The Array Into 2 Parts

Oct 26, 2007

i am loading in and xml file based on the structure below...

[Code]...

So what i am trying to do is to Splice the array into 2 parts, all the question ID's that are A and all that are B for for example are placed into 2 new array's like so:

[Code]...

but i am having problems with the code below trying to splice them and seperate them,

[Code]...

View 4 Replies

Reference Instances Created By A Loop Elsewhere?

Jan 20, 2010

[code]My code will:

- loop through the Grid array and place each tile on the stage

- assign RedBall a random Grid coordinate and places it on the stage at that coordinate

I want to be able to click RedBall, which will create a border around the tile beneath RedBall, and create borders around the tiles above, below, to the left and to the right. BUT, I don't want to reference the tiles by their distance in pixels from RedBall or from each other; I want to reference the tiles by their coordinates in the Grid array. So I want to:

- get the coordinates of RedBall

- use those same coodinates to reference the tile at the same coordinates in the Grid array

- use the tile's coordinates to reference the tiles above/below/left/right

- apply a border to all these tiles

What's the best way to reference an instance of a tile? Should I apply a name to each instance as it's created in the loop? like myTile.name = "tile"+i+"_"+j; ? If so, how do you reference that instance later? Just tile1_3 ? Do you have to prepend it with root, or stage, or the class it was originally created in? Do you have to use getChildByName? OR, can you still reference it later without having given it a name?

View 1 Replies

ActionScript 2.0 :: Reference Instances Inside EmptyMovieClip?

Feb 17, 2009

I am loading an swf file into an EmptyMovieClip container called "container" using loadClip. I cant figure out how to reference the different instances inside the loaded swf.[code]...

View 5 Replies

ActionScript 2.0 :: Nested Movieclips - Reference To The Instances?

Sep 14, 2007

how is the best way to reference to the Instances.

View 2 Replies

ActionScript 3.0 :: Reference Instances Created By A Loop Elsewhere?

Jan 20, 2010

My code will:

- loop through the Grid array and place each tile on the stage
- assign RedBall a random Grid coordinate and places it on the stage at that coordinate

I want to be able to click RedBall, which will create a border around the tile beneath RedBall, and create borders around the tiles above, below, to the left and to the right. BUT, I don't want to reference the tiles by their distance in pixels from RedBall or from each other; I want to reference the tiles by their coordinates in the Grid array.So I want to:

- get the coordinates of RedBall
- use those same coodinates to reference the tile at the same coordinates in the Grid array
- use the tile's coordinates to reference the tiles above/below/left/right
- apply a border to all these tiles

What's the best way to reference an instance of a tile? Should I apply a name to each instance as it's created in the loop? like myTile.name = "tile"+i+"_"+j; ? If so, how do you reference that instance later? Just tile1_3 ? Do you have to prepend it with root, or stage, or the class it was originally created in? Do you have to use getChildByName? OR, can you still reference it later without having given it a name?

View 3 Replies

ActionScript 2.0 :: Dynamically Reference Instances Inside A Movieclip?

Feb 16, 2009

Here is a simple example of what I need to be able to do:I have a movieclip, "main_movie", in the main frame, which has multiple instances inside of it...for example "mc_1", "mc_2", and "mc_3".I am unable to figure out how to dynamically reference them. Please look at the code below and let me know what I'm doing wrong.

for (var i = 1; i <= 3; i++) {
main_movie.mc_[i]._visible = false;
}

View 2 Replies

Loop Through An Array And Use The Array Value To Reference A Variable?

Sep 25, 2009

I want to loop through an array and use the array value to reference a variable.

The Setup:
(For illustration only. Not actual script)
My MCs:
triangle_mc
square_mc

[Code]....

View 1 Replies

ActionScript 3.0 :: Reference Instances From Movie Clips If The Movie Clip Referencing From Is Nested?

Mar 23, 2010

It's me again and I'm running into a problem. So, I have this movie clip that is nested inside multiple movie clips. I want to tell Flash to perform an action when that movie clip hits another movie clip in the main timeline. It's just collision detection for a game using the hitTestObject code. I was thinking of using MovieClip(root), but that won't work since it's nested so much.

View 15 Replies

ActionScript 3.0 :: Add Movieclips From Instances In Array?

Mar 31, 2011

Ive created a array to hold an instance of the Zombie movie clip, the movie is given an instance of "Zombie" + 1, 2, 3..... But now i can't work out how to add the movie clips from the Array to the stage. [code]...

View 3 Replies

As3 :: Flash - Array Loop With Instances?

Jun 22, 2010

There's 3 boxes I'm indexing through with a timer. They disappear in sequence. How do I make them reappear?

boxes disappear in sequence 1-3

var pink:Array = ["","boxInstance1","boxInstance2","boxInstance3"];
var timer:Timer = new Timer(555);
timer.addEventListener(TimerEvent.TIMER, onTimer);

[Code]....

I'm not to particular about the sequence they disappear and appear, but it need to keep going in a loop.

View 3 Replies

ActionScript 2.0 :: Holding Instances In An Array?

Jan 24, 2006

I'm working on a project where I have Multiple instances with the same actions.

Instead of typing out

btn1._visible = false;
btn2._visible = false;
btn3._visible = false;
btn4._visible = false;

Could I store these instances in an array so that I could minimize my code to something like:

btnArray._visible = false;

I've tried to do this but it seems to read the instances as strings instead.

View 11 Replies

ActionScript 3.0 :: Accessing Instances Through An Array?

Apr 9, 2010

I'm setting up some Radio Buttons. The desired effect is when you click a button, it calls a function which loops through an array of the button states, switching them off.

The stumbling block is changing the state of the buttons from on to off. I'm sure it's an issue with the way I'm trying to get the instant name (eg radioBtn1) into the MovieClip Variable 'currentRadioName'.

The error I receive is: TypeError: Error #1034: Type Coercion failed: cannot convert "radioBtn1" to flash.display.MovieClip.

So I'm trying to stick some object into a MovieClip object, which obviously doesn't work.

[Code]....

View 4 Replies

ActionScript 3.0 :: Playing Mc Instances Sequentially In An Array?

Feb 26, 2009

I have a movieclip tweened of a lightbulb bright then fading. 50 or so instances are placed within another movieclip and given instance names of bulb0 to bulb50. I have a stop action on the first frame of this movieclip.

Other animation within the main movieclip is activated on rollover and I have used actionscript to place this main movieclip on the stage and to control the other animation within it.

Within my external as. I have an array as follows:

var bulbclips:Array = new Array();
for (var i:uint; i < 58; i++) {
bulbclips.push("winNav.bulb"+i);

[Code].....

View 7 Replies

ActionScript 3.0 :: Incrementing Through Instances Of Movieclips To Get Them Into An Array?

Jun 2, 2009

the user needs to select an answer from a dropdown list.  I am then creating  an array that will store the answer to each question when the user clicks the submit button.  Each of the drop down menus is named sequentially.  So what I am trying to do is write  a while loop that will increment through and read each of the values into the array so I can process the responses later.  The issue that I am having is writing the syntax to recognize the Instance name of the specific drop down I am trying to reference.
 
Here is the basic code I am using:
 
var Store:Array = new Array(2);
public var Increment:Number;
Increment = 1;

[code]....

So the DropDowns instance names are DropDown1, DropDown2 etc...  It works fine if I manually enter in each instance name (but there are 43 total and I don't want to do each one individually).  
 
I am assuming that I need to setup some sort of variable to temporarily add the increment number to the "DropDown" and then use that as the reference:
 
Increment = 1;
while (Increment <=2){
ItemNumber = "DropDown" + Increment;
Store[Increment] = MovieClip(Scroller2.Form_Scroller.content).ItemNumber.value;
trace(Store);
Increment++;
}
 
But when I do that, I get the following error message:
 
TypeError: Error #1010: A term is undefined and has no properties.
at combotest/submitted()
 
I assume this is because it is looking for an instance of ItemNumber instead of the instance of the value of ItemNumber. 

View 5 Replies

ActionScript 3.0 :: Create Two Instances Of An Array Object?

Jun 30, 2009

My project downloads an array from a MySQL server that has URLs for pictures in it. Part of my script then downloads these pictures and splices the array (removing the URL and replacing it with the bitmap). Now i need to use those bitmaps on the stage but i need two instances of the same bitmap at the same time, and it seems like flash is having a problem with this.
 
How do i create two instances of the same array bitmap?

View 1 Replies

Flash - Add Dynamic Instances Of MovieClips To An Array

Aug 29, 2010

I'm trying to add an instance of a MovieClip inside an array. Inside the House Class is a property called HouseObjects. Inside that array, I created a Comp and a Light class. MovieClips are dynamically placed on the stage, via linkage. The MovieClips also act as "toggle buttons." If the button state is ON, value is 1. If the button state if OFF, value is 0.

If the value is 1, I am trying to add MovieClip instance inside the onList Array. Inside that array will be all the instances that have a button state ON.

I created a property called objSelect.

var objSelect:Object;

That variable holds the currentTarget selected. I'm trying to pass it to function trackItems to either push/pop it in the onList array, based on the button status.

I receive an error for this line:
onList.pop(objSelect);
Incorrect number of arguments. Expected no more than 0.
public class House extends MovieClip
{

[Code]...

View 5 Replies

Actionscript 3 :: Get An Array Of All Instances Of A Class On A Stage?

May 22, 2011

Assume I have the myCircle class all defined and all that. If my code is as follows:

[Code]...

How would I write a function to return an array of [circle1, circle 2, circle3, circle4] automatically?

View 2 Replies

ActionScript 3.0 :: Removing And Adding Instances To Array

Mar 8, 2011

I have a MC called Enemy. It contains a monster that pops out at a random time (a timer with animation inside the MC). It stays on the stage for a few seconds and then hides again. If it hides, I want it to be removed and another enemy be added instead. All the monsters are instances of Enemy MC that are inside enemies[] array.[code]

View 8 Replies

ActionScript 3.0 :: Use An Array To Record Names Of Instances?

Jul 8, 2011

I've continued with it and have hit another hurdle. When I run the loop to load in the XML images, inside the same loop I add instances of a "thumb" movieclip onto the stage. It's just a little graphic that I want to use as thumbnail buttons. So for example, if the XML loads in 3 images, 3 instances of the "thumb" mc also load onto the stage. I currently give then unique names in the loop but that name gets overwritten each time the loop runs. How can I record each name of the instance? I'm guessing an array but how do you populate an array with a loop?

Then, I'm hoping if those names are recorded in an array, then I can reference the different thumb instances (so they can do different things with the images) and also use removeChild on them when I close the gallery and load in the next gallery. Here is my code so far,

[Code]....

View 6 Replies

ActionScript 2.0 :: Removing All Instances Of A String From An Array?

Feb 27, 2007

there an easy way of removing all instances of a string from an array?Say i had, [0] forward, [1] forward, [2] right, [3] crash, [4] crash, [5] crash(this structure will change)How would i remove all "crash" instances? the splice method just doesn't cut it =/

View 8 Replies

ActionScript 3.0 :: Flash Instances In An Array Cannot Be Displayed?

Feb 26, 2011

There isn't any error displaying. I traced the "rectAry[1]" and it's "undefined"

When I change the variable "i" inside the statement to 3 or other values,
the instance will be displayed probably.

Code:
package
{
import flash.display.Sprite;
public class testClass extends Sprite

[Code]....

View 2 Replies

ActionScript 3.0 :: String.split(" ") - Spilt String Into 2 Parts And Save Them Inside An Array

Jul 12, 2011

I have a string that contains a full name input, and I would like to spilt them into 2 parts and save them inside an array, first name and last name. How do I do it with string.split? My current code is myNameArray = str_adminInput.split(" "); This code only works if the names are : Jack Lee, June Poh. This code does not work if the names are: Lee Tok Kong, Tan Beng Seng.

View 7 Replies

ActionScript 3.0 :: Spawning Several Instances Of A Button With A Different Names By Using Array

Mar 4, 2009

where each of my buttons have a dynamic text label.

So this button is a symbol, and the instances are named let say btn1, btn2, btn3. The label tag name inside the symbol is btnName.

How I can make this work if I define my array on top level? How I can make sure that the label btnName will have the correct array name for each btn instances?

found out the benefits of .children usage...

btn1.children.btnName = xArray[0];
btn2.children.btnName = xArray[1];
...

View 5 Replies

ActionScript 2.0 :: Create Array To Hold Some Movieclip Instances?

Feb 3, 2009

I wanted to do something like:

ActionScript Code:
arrayTucano = (tucano1, tucano2, tucano3); // movieclips instances
// Function to drag

[Code]....

But it drags only the last movieclip, tucano3.

Why? How could I make to drag all of them?

View 4 Replies

ActionScript 2.0 :: Unable To Trigger The Instances Form Array

Jul 23, 2006

i got a array which stores some elements, in string form, and these elements actually represent the name of the instances on the stage. now i want to trigger the instance to reset it's alpha value..

eg: i got an array["A"."B"."C"];Instances name available: A,B,C,D....Znow how i should do to make the instance A to got triggered?? i call them by using on button. i try some like _root.name.array[0]=_alpha=0; but not success.

View 10 Replies

ActionScript 3.0 :: Cumulative Add Calls From An Array Of Point Instances?

Feb 28, 2009

I have a source array with simple Point instances in them (just an object with x and y properties). I want to have a resulting array with the cumulative result of calling Point.add() to each of the instances. (e.g. the resulting point object is a result of adding the current point to the total of the points before it in the source array.) is this possible to dynamically do this?

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved