Flash :: Array That Holds An Object And A Related Value?
Dec 12, 2011
I'm writing a game that involves cargo, and I plan to have a large number of cargo types. Currently I have a Cargo class, and a ship carrying cargo has an array of the Cargos it is holding. I'd really rather not have each ship with a bunch of objects when all I really want to know is how much of which cargoes each ship has. Especially when these ships will be created and discarded a lot.
I'm sure the thing I'm looking for is so basic I'll look dumb for even asking, but I know there's something similar to an array that holds an object and a related value. I want to use that to reference the Cargo type from the static array, and hold the quantity.
What's it called? How would I use it (ie what are common functions used for it)? Some code snippets and terminology would be ideal.
View 2 Replies
Similar Posts:
Apr 7, 2010
I have an array which holds objects. The objects have properties called cat and title. The cat property can hold values like:
Cat 1
Cat 2
Cat 3
And the title property can hold values:
Title 1
Title 2
Title 3
So that you wind up with something that looks like
Cat 1
Title 1
Cat 1
Title 2
Cat 2
Title 3
etc.
Now, I want to sort these, but we all know that Array.sortOn(["cat", "title"]) will produce results like:
Cat 1
Cat 10
Cat 11
Cat 2
Cat 3
What's the most efficient method of sorting these properly (so the number component sorts like a number and not like a string)? I can request users pad their entries (yes, other people will be entering this data), but that's both a little bit ugly and not very user friendly.
View 2 Replies
Aug 30, 2006
have this code that's supposed to return the an array that holds the values that were contained within an XML node.
[Code]...
for some reason, the code won't return anything. the output just says "undefined". Would a good workaround consist of putting the return function within a setInterval method?
View 3 Replies
Dec 5, 2005
I initialize the "point" object like:
point = {x:'209', y:'270'};
trace(point.x);
this is working fine, But I have to initialize the "point" object with a string variable which holds the initialization properties like:
[Code]...
I know this is not working. Is there any method to initialize the object with a string variable which holds the initialization properties (without parsing the text) ?
View 7 Replies
Dec 5, 2007
I don't know if this is even possible, or if I'm going the right way about this.Here's what I've got:
ActionScript Code:
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, imageProgressHandler);
function imageProgressHandler(event:ProgressEvent):void {
[code]......
View 3 Replies
Oct 24, 2009
i'm trying to get randomly moving objects to scale up as they move further away from their point of origin, I'm haveing trouble with this. I've attached the current random movement code below:[code]
View 0 Replies
May 30, 2007
I have created a class and I would like each object of this class to be related to a movieclip which I would be able to move around the scene.But I have to admit I don't really know how to do that.
The best would be that each of my objects have a movieclip called "graphical_representation"
[Code]...
View 1 Replies
Jun 17, 2010
I'm trying to create a game and have come across something that I have never really played with and am not sure if it is what I need to use in this instance or if it's as powerful of a resource as I am hoping.I have a movieClip that is an animated man. I can move him around my stage by clicking on him and then clicking where I want him to go. But I'm eventually going to need to store information about him. Such as his x and y position on the stage, attributes about him that are custom to my game.Real Quick: The man represents an army and when the user clicks on him, I want to display things like, Military Units in this army, number of men remaining in each unit, experience and so on. If you have ever played any of the "Total War" games you will know what I'm talking about.
View 1 Replies
Jul 24, 2011
Does anybody knows how to use the XML as a holder for the values that will be given by the user for example. Parent's name: _. then whatever the user's input i should move that and hold that by the xml. i just dont how. i read lot of books but i can't find any answer. This is for my senior project.URL...
View 2 Replies
Dec 24, 2011
I've been reading a lot about the benefits of Object Pooling. Found some "tutorials" online, all above my skill level. Can anyone please show me an extremely simple example of an Object Pool. What my game does is creates Ball objects when the user holds down the mouse, stops when user lifts up mouse. I need to store these Ball objects in an array(or Vector), and hit test them with other objects, removing them from the stage when the hit another object. I'd like to create a pool of say 20 of so, created once, and recycle them.
[Code]...
View 1 Replies
Dec 1, 2010
how to add a movie clip to the stage from the library but i'm strugling to do it when the I need to load a movie clip from the library when the name of the movie clip is held in a variable.
for(var i:Number = 0; i < 64; i++)
{
var blueIconS:blueIcon = new blueIcon();
addChild(blueIconS);
[Code]....
The above code works for adding the blueIcon but I have a variable in that loop which tells which icon to load.
sectorsMCs[jewelsIDs[i]]
The above will tell me what MC name to load but how do I load a MC from library by that variable value?
View 1 Replies
Jul 13, 2010
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?
View 1 Replies
Aug 4, 2009
Is flash (actionscript 2.0) secure enough to use for a website that holds personal info, password, restricted areas, ect. How can I make it secure enough if it's possible.
View 1 Replies
Dec 8, 2009
how to copy one xml object values from one xml object to another empty xml object.
I have one xml object from the xml array and need to copy that to another xml object. How can i copy xml from one object to another
if am parsing the XML object with for loop and i get the nodes
var myXML:xml = new xml();
for(...)
if(xmlObj.product[i].name == 'myproduct'){
[Code]...
View 2 Replies
Apr 2, 2012
What I would like to do is to use ASP.NET impersonation to authenticate a Flash app as a user in IIS so that the file dependencies related to the flash file ( XML config files, and PHP API calls ) are not anonymously accessible when users try to access them directly through the URL. So, instead of displaying the contents of an XML config file, it should tell the unauthenticated user they do not have permission to view the file.
Is this possible? Right now I'm looking into request headers and the settings in IIS for authentication.
So I found out how to use Basic Authentication through help posted here. The problem I'm running into is that even though the flash app sends the appropriate request. Which is handled fine in FF, Chrome, and Safari. It still displays the login pop-up box for Opera and IE. Does anyone know why IE and Opera behave differently with Basic Authentication?
View 1 Replies
Apr 10, 2010
I am facing a problem while using textAreacomponent in Flash cs4.I set the text of this component at run time with coding i.e dynamic text and after that i am rotating this component with -2.After rotation it dosen't show the text why is it so?
View 1 Replies
Dec 10, 2011
I haven't been here for a while but as a resource of excellent ideas I am back to ask something that I feel you guys would know about.I am a teacher thinking of going self employed and I want to set up an online business charging for access to resources I create myself online to any students that would be interested.I can figure out how to set up password protected areas on my website where access is given when payment is made.
Of course this is for a limited period, say a week and then the password would automatically and randomly change.
I would give the password to those that had paid for access for the agreed period for access.As I aim to have more than one person at a time, this needs to be self regulating. Is this at all possible?Online teaching resource not exactly flash related!
View 3 Replies
Jun 11, 2010
I have a small flash project. I created a SWF from the flash sources.Unfortunately all my flash sources related to the project are deleted.
I left with the SWF file. Is there any way that I can retrieve all the flash source files from the swf file ?
View 1 Replies
Nov 13, 2009
im creating a library that holds a bunch of myObjects. I 'register' these objects and give them a label(String) so I can access them later. There's 2 ways I can do this easily:
[AS]var libraryictionary = new Dictionary();
//set reference (takes MyObject)
library[myObject.label] = myObject;
//get refernce (takes string, returns myObject)
return library["label"][/AS]
[Code]...
View 1 Replies
Dec 5, 2011
I've done some googling for the past hour, but I can't seem to find what I need.Maybe I'm overlooking something.I want a very simple, basic thing. But I have no clue how to do this.I have an external XML file which holds a list of names.I want these names to be pushed/added to an array so I can access it based on it's position in the array. (A for loop is used to read a different XML file and the child[i] is named after the same array spot, childName[i]
View 10 Replies
Dec 13, 2011
I was editing a very basic mobile Flex project, and after I debugged the master (application) mxml file, Design View stopped working (blank screen displayed, no Design View errors) for all files. Creating new projects, either mobile or else, or testing old, working projects, doesn't work either. Out of the related issues I've found info on, most concern earlier versions of the IDE, and deal with either Design View errors (got none), use of certain functions or custom components (I get the error even on a new project), or are solved by changing styles back-and-forth (tried already, to no avail).
I can't drag and drop components to the design area, either (a "prohibited" symbol appears and nothing happens when I drop); so I'm pretty sure it's not code-related or a bug, but probably something stupid, like a configuration issue, so I definitely need someone to take a fresh look at it.
View 1 Replies
Jan 12, 2010
I am trying to remove an object from an array. but from some reason its not working. I am under the impression that a splice accepts 2 parameters. the position of the array. and for parameter 2 , how many to delete from then on out.I just want to delete one array so I am doing this array. splice (i,0);but it isn't working. can someone tell me what i am doing wrong. enlighten me on how it suppose to work.
View 3 Replies
Feb 23, 2011
how do you find an object's index / position within an array in flash actionscript 3? I am trying to set a conditional up in a loop where, if an object's id is equal to the current_item variable, I can return its position within the array.
View 1 Replies
Apr 1, 2011
Im creating a kids drag and drop game and want the 6 words to change place each time it is played. ive got a box which i want them to move about in. create an array of some kind to possible do this, but i'm stuck in actually creating it. also ive managed to drag and sound clip onto my first frame and cannot delete it so any help with it would be helpful (pig oinking isnt needed when u load the game )
View 1 Replies
Jul 7, 2010
I have been trying for an hour to clone an array, It seems that nobody has a true reference on how to do it. Two arrays - movieClipArray 1 and movieClipArray2 I want to duplicate movieClipArray1 entirely so that when I addChild(movieClipArray2[0]), it doesn't take away from movieClipArray1 or reference it in any way.
[Code]...
View 3 Replies
Dec 19, 2009
Do you ever have a question that has been asked all over the Internet...with nothing but shitty answers? This seems to be one of those questions: What's the best way to continuously scroll text while a user holds the mouse button down? (By the way, I'm not using the timeline, so don't waste your time telling me to use EVENT.ENTER_FRAME.)
View 1 Replies
Jun 18, 2009
I am trying to use the following code to convert an object read in from a ByteArray to an Array and store it:
var data:Object = ba.readObject();
var invObjects:Array = data as Array;
In debugging, I find that 'data' is indeed populated with the correct data and takes up memory and is in an Array friendly format. However, invObjects is NULL. How does merely saying 'data as Array' make the holding variable suddenly null?
View 3 Replies
Feb 22, 2012
How do I find an object's index in an array
I have an array of objects similar to[code]...
After chatting with my coworkers, they have suggested I enumerate this into a large array of indexed values with references to which index they are associated with, for instance [code]...
View 2 Replies
Dec 13, 2010
i would like to place various instances of the same library object on the stage.
the different instances (0,1,2,...) are meant to be containers for their individual content. hence, each instance (0,1,2,...) is one container and each containter embeds different placeholders (textfields- and image-instances) in itself.
[Code].....
View 7 Replies
Mar 24, 2012
For days now I have been trying to get this hit test to work and which ever way I try it, it always comes back to the same result. I get a hit on the last item I pushed into my array but none on the previous items I pushed in. Also if I put a .sort() on the array it only gives a hit on the last item of the array, no matter which one I push in.
The idea is that I want to drag and drop objects onto the stage, they may not overlap so I need a hit test on the objects so I can make them undroppable when the hit test is true.
This is the part I have for dragging the objects to the stage, and adding them to arrays for the hit test.
Code:
private function onClickDragBuilding1ToGameField(e:MouseEvent):void{
building1Placeholder.x = mouseX-25;
building1Placeholder.y = mouseY-25;
[Code]...
Now if I run this I can add the object to the stage just fine no errors or other issues but the hit test only works on the last object I added to the stage/array and not the previous object I added to the stage/array.
Sso I drag the first object to the stage. (no other object are available yet so nothing happens, this is as it should be) Then I drag a second object to the stage, this reacts to the first object and returns the hit test as true. (Also great and working as it should.) Then I drag a 3th object to the stage, this reacts to the 2nd object I dragged just fine and return a true value, but it does not react to the 1 object I dragged onto the stage. Then when I drag a 4th object to the stage it will react to the 3th object I added, but not the 1st ad 2nd object.
View 4 Replies