Does Flash Actionscript Have List And Dictionary Equivalents
Feb 19, 2011Does Flash Actionscript have List and Dictionary equivalents? I've only found the documentation for the Array.
View 2 RepliesDoes Flash Actionscript have List and Dictionary equivalents? I've only found the documentation for the Array.
View 2 RepliesI'm on the brink of finishing the first iteration of my first game ever o/ and of course the last item I need to complete is the hardest. I am making a simple word game, and all details aside, the task at hand is a conditional block to determine whether the word the user has entered is real, and in order to do this I need to somehow compare it to a dictionary list.
1 hour of research has quickly opened up an entire universe of data structures, open source xml documents, people willing to take my money for spell checkers, and of course RegExp which I have no experience using (but am willing, and wanting, to learn!). One of the main problems Google is giving me is the addition of the Dictionary class in AS3, which "lets you create a dynamic collection of properties, which uses strict equality (===) for key comparison on non-primitive object keys..." So finding previous literal dictionary uses is tough.
I soon found taking a dictionary txt file (118619 lines) and converting it line by line into an array takes 3 minutes on my beast of a laptop gaming rig (Asus W90), and while I knew this was a bad idea, it was a nice learning experience (to give me a gauge of processing abilities).
I am wondering whether using XML is an appropriate alternative, or if there is a way to externally access a dictionary somewhere online. Looking at the XMLList Class available I see text() and toString() methods; yet I still see heavy iterations in accessing the dictionary.
Which brings up the next point: easiest way to find a String match. I understand that comparing each word one by one would be tedious for the program, so maybe splitting up the list by letter (or maybe string length, looking at the file), or first and last letter.
I need to know the best method to find an item inside a list (Vector, Array, Dictionary, whatever is faster) of complex type (extensions of Objects and Sprites).I've used "Needle in Haystack" method, but it seems that it isn't fast enough.
E.g.Suppose that I have a collection of Sprites (a pool, in fact).Each sprite will be added to the stage and perform some action. After that, it will die.I don't want to pay the cost to dispose it (garbage collect) and create another (new) one every time so I'll keep the dead sprites in a collection.
Sometimes times I'll call a method that will add a sprite to the stage.This sprite can be a old one, if it is already dead, or a new one, if the pool don't have any free sprite.
One of the scenarios that pushed me to this question was a Particle System.A "head" particle leaving a "trail" of particles every frame and exploding into a flashy multitude of particles... Every frame...Some times this counts up to 50.000 PNGs with motion, rotation, alpha, event dispatching, scale, etc...But, this is JUST ONE scenario...At the moment I'm trying to use a Object Pool with a Linked List...Hopes that it will be faster that running a whole Array/Vector or create new instances every frame an let them dye with Garbage Collection.
Is there a secret to getting AS3 objects to translate over into Java using LCDS/Blaze?I'm working on a legacy system and we are having issue communicating with the back end, specifically when we send certain custom AS3 objects over Blaze to our Java RO methods... sometimes they port over, but often they come across "the bridge" as nulls.
(Objects coming from Java to AS3 work just fine however, as do sending primitive values rather than objects.)I thought using the remote metatag [RemoteClass(alias="java.foo.bar.Snafu")] in our AS3 classes was enough for bidrirectional support, and indeed it works just fine when Java is sending AS3 Snafu objects... but when AS3 tries to send to Java it works for some classes (mostly the legacy ones) but fails for others (mostly our new classes).
The specific error we get is something like this: "Cannot convert type flex.messaging.io.amf.ASObject with remote type specified as 'null' to an instance of class com.foo.bar.model.ResultableResource".
The error to me looks like Blaze cannot find the ResultableResource java class, yet we've doublechecked that the classes that don't translate have equivalents on both sides, and indeed they look similar to the classes that are working.
Is there some external mapping or publishing trick we need to do in Java or AS3 to allow these objects to export correctly? Do they need to implement the java.Externalizable interface? Maybe they need to be added manually to some kind of manifest? Adobe docs are fuzzy on the matter and make it sound like things should just work, but they don't.
for instance distance values,and temperatures For instance say I have a string containing some unknown inches value And the inches sign can either be the proper double prime OR double quotes. So, I'm guessing as a first step I would search for double prime or double quotes preceded by a number value, then parse out and convert this number value. But this doesn't seem foolproof for instances when it is actually a doublequote, NOT an inches sign
View 1 RepliesThe dictionary use strict equals(===) for key comparison, how to change the comparison, so I can use my standard for comparison, for example, I have a class named Student:
class Student{
var id:int;
var name:String;[code]....
I want Dictionary use id to compare if the two keys are equal, not use strict equal(===) to compare if the key is the same.
somehow plug a dictionary into flash which can be used to verify words in a word creation game I'd like to create..
Sounds perfectly feasible but I just wouldn't know where to start in finding it... are there ones which are readily available ?? (preferably free)
As the title suggests, is it possible to use AMF to encode/decode Dictionaries (without subclassing, that is)? For example, here's a test case:
[Code]...
Is there a way for flash to get the nature of a word (noun, verb, adverb, etc.) from a dictionary somewhere?
View 1 RepliesSo I am writing a program which uses Dictionary to store objects. For example
var dictionary:Dictionary=new Dictionary();
var myObject = new myObject(var1, var2, var3);
dicionary["key"]=myObject;
where var1, var2, and var3 are simply means of assigning values to variables in myObject.can I access values or functions that are found in myObject? In myObject class I have some getters and setters. Can I use a getter to get the value of var1 for example.
dictionary["keys"].getVar1()?
trying to work with "simple" XML for the first time. I'm building a small CMS for a Flash based site and the content is held in an XML file. My problem is that many of the copy fields are XML CDATA fields. on the one hand, with:
$xml = simplexml_load_file($file, 'SimpleXMLElement', LIBXML_NOCDATA);
I can pull the data out of that node and the CDATA tags are stripped. My issues come with trying to save the data with:
file_put_contents($file, $xml->asXML());
Problems are: a) tags are interpreted with their HTML entity equivalents. I don't want this to happen.I gather this is coming from the asXML method because even if I do anhtml_entity _decode on the $_POST data it's still being converted.
b) because of the above, there's no way to add the CDATA tags because they also have their charachters converted.
In one of the classes in my Flex application I have a dictionary, which is periodically updated from other parts of the application. It contains some sort of user preferences and I want to keep it in sync with a local shared object - the dictionary needs to be read during the class initialization and saved to the local storage when an element is changed, added or deleted.
The "Dictionary" object inherits only "Object" and does not have a change event - like the "collectionChange" in ArrayCollection. So I can't sync the dictionary just by listening for an event and manipulating the shared object in the event handler. The other possible solution would be to make the dictionary private and manipulate it using special methods in my class. Something like:
public function setValue(key:String, value:String):void
public function getValue(key:String):String
public function delValue(key:String):void
But using bindings will become a real nightmare and I will have to make changes in many other parts of the application.
I am using a dictionary variable to match up a drop and drag exercice.
var dict = new Dictionary ();
dict[box_a]=s1;
dict[box_b]=s2;
dict[box_c]=s3;
dict[box_d]=s4;
question 1: at the end i would like to check if box_a== with s1 and so on .... how would I do that
for each( var item in dict)
{ item.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
item.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);[code]....
question 2:I would like box_d to accept also s3 how would i do that if i do
dict[box_d]=s4; and dict[box_d]=s3; it wont work because it matches it with the last equal.
I am working on an older Flash project created in CS3 ActionScript 2.0 How can I make the pointer cursor change to the hand when hover over a list item?_root.slidePanel.myList'myList' is the list. I have traced out the contents of the List MC and it has a child MC called 'content_mc'. I assumed this was the object containing all of my list items but the only members of this MC I can see (when tracing them out) are 'setRGB' and 'searchKey'.
View 1 RepliesI want to add a SimpleButton to a list item in a list component. I am getting the CellRenderer for the list item I want and using the addChild method to add the simple button. The button appears in the right spot on the list item but it doesn't function like a button. It's like the contents of the buttons first frame is added to the CellRenderer and nothing else.
View 1 RepliesWhy I have to press 2 times the arrow key down to get a navigation through the list items in a list component of Flash?
Theres any workaround for this? I have a listener for keyboard event that checks if keyCode is equal to 40 if it is then I use 'stage.focus = list', but I have to press 2 times key arrow down to start navigating through list items.
I am encountering a problem in my app only when it is run in flash player 10.1.85.3. Some earlier player versions I have tried are working fine.From what I can tell it seems related to the following:
Quote:
from here: h[url].....
When searching for objects (not strings) in Dictionary objects using the 'in' operator, if the object is not found in the Dictionary object, it will be searched for in the delegate objects. With 10.1, the toString operator will be called on the Object if not found in the Dictionary. This can cause problems with Proxy objects who need to define the callProperty function or it will generate a RTE. ...what it means "it will be searched for in the delegate objects"?
Is it possible to clear a Flex flash.utils.Dictionary? I have a Dictionary that I want to clear (remove all elements).
View 3 RepliesThe great thing about dictionary: one can use objects as keys. The bad thing: compiler still believes that the keys are strings.
[code]...
Normally in Flex you use a collection like ArrayCollection as the dataprovider for components. I often have data stored as a dictionary whose values I would like to use as a dataprovider.
View 2 RepliesI'm working with a large set of hierarchical taxonomic terms, where each term ("203") has a matching "term203" movie clip on the stage, and am having trouble getting a recursive function to return all of a given term's descendants.There is a main Dictionary() object with the following nested organization for each term:
{ [object Movie Clip] : { "tid":203, "parent":99, "name":"Culture", selected:false, "otherData":"etc" } }
...where the [object Movie Clip]'s instance name would be "term203". All of these object:subObjectArray items ("terms") are stored in a master taxonomy:Dictionary() object.I've been trying to make a recursive function (which is in itself already a little above my head) that takes the click.target of a movie clip and returns a new Dictionary() object with all of the children and grandchildren and great grandchildren (etc) of that term, in the same, nested organization described above.
The code below traces the right number of recursive loops, but the returned Dictionary() object only contains the first run's terms (only the immediate children of the requested term).
var taxonomy:Dictionary = new Dictionary();
// ...Term info is loaded into taxonomy from a JSON-style text file)
// ...MOUSE_OVER event listeners are added to each
[code]....
I certainly do not claim to be the most efficient AS3 programmer, so I am open to alternative configurations. However, after trying static and nested Arrays, I would prefer to continue using the Dictionary() object as my main pool.As noted, only the immediate children end up animating in the revealChildren() function. It's mystifying to me then, that in the getAllChildren() function, all of the descendants trace sequentially (well in no particular order) in the output window.Also I can't get any sort of name or property out of the subSet Object. That could be the problem.I've only tested it as far as 'two generations,' but it seems that only the first round of calling the function successfully adds those terms to the new Dictionary() object and returns it intact to the animating function.
I'm often seeing others using a Dictionary object in their AS3 code that simply maps objects by String keys and wondering if there is any advantage at all of using a Dictionary over a simple Object if String keys are used. Anyone know any details on this? I would suppose that since an Object is more lightweight it should be faster and preferable over a Dictionary if used with String keys.
View 1 Replieswhy the Dictionary class ignores setPropertyIsEnumerable? I found this bug at bugs.adobe, seems the prototype might be involved in some devious way.Here is some test code:
var obj:Object = {
'a': 0,
'b': 1,[code]......
Notice that the Dictionary is still enumerating the property "a" even though it was told not to.
What is the correct way to determine if a Dictionary contains a particular key or not?
In Java I can do:
HashMap x= new HashMap();
x.containsKey("test"); // returns true/false
Is this the correct way in AS3?
var xictionary = new Dictionary();
x["test"] == null
[Code]...
in Java this: dict.keySet()
View 6 Repliesfor (var k in dictionary)
{
var key:KeyType = KeyType(k);
var value:ValType = ValType(dictionary[k]); // <-- lookup
// do stuff
}
This is what I use to loop through the entries in a dictionary. As you can see in every iteration I perform a lookup in the dictionary. Is there a more efficient way of iterating the dictionary (while keeping access to the key)?
What exactly is the difference between an object and a dictionary in Actionscript?
var obj:Object = new Object();
obj.something = "something";
var dict:Dictionary = new Dictionary();
dict.something = "something";
trace(obj.something, dict.something);
The trace statement seems identical...
Right now I am using ArrayCollection. But I want to change that to Set as I want make sure do duplicate values come.
var addressList:ArrayCollection = new ArrayCollection();
One way is I can use Dictionary and store addresses as a key. And I can just use keys to iterate. But I am looking for Java HashSet like implementation.
I am writing my destructor but I am not sure how to make sure that my Dictionary object is completely dismantled.
Do I just walk the keys and 'delete' the objects? If so do I need to destroy the keys? or are they already removed when the object is removed from the Dictionary?[code]...
I have an ARRAY which contains single symbols and DICTIONARY in where every symbol in array is attached to unique string, what I want to do - is to merge ARRAY and DICTIONARY together, and as a result receive RESULT_ARRAY where order of elements is equal to ARRAY but elements are replaced according to a DICTIONARY.
Code:
//for example
//this is what we have -
var originalA:Array = new Array ();
originalA[0]="y";
[code]...