Hi! A few questions about dictionary:
- Is anything wrong in doing something like this:
var mc = new MovieClip();
dictionary[mc] = mc; //in other words, the same mc as key AND value
I mean, any particular implication on performance? is it a bad practice?
-
Does it cause performance or memory problems to use moviclips as keys instead of primitive values?
-
Is is a good practice doing something like this:
private function prepare(){
fxArray = new Array();
fxDictionary = new Dictionary();
}
public function addFxListener(fx){
fxArray.push(fx);
fxDictionary[fx] = fxArray.length-1;
fxArray[fxDictionary[fx]].addEventListener(PageEvent.TRANS_IN_FINISHED,notifyPageEvent);
fxArray[fxDictionary[fx]].addEventListener(PageEvent.TRANS_OUT_FINISHED,notifyPageEvent);
}
Where fx are classes extending Movieclip, fxArray is an array where I store fx referencies and fxDictionary is a dictionary where I store indexes of the fxArray, using the relative fx as key. What do you think about this kind of usage?
also another question:
- Does a code like this create a reference to mc (along with events and so on?):
dictionary[mc] = 7 //(the value is a primitive)
I mean, if I then destroy mc, the line above will still keep it somehow alive?
Ooops… Maybe I should move this thread to the AS3 forum??? Could the administrator do it maybe? Sorry…