This content has been marked as final. Show 4 replies
Sorry I forgot to mention how to reproduce the error!!!
Let's say that I defined the following lines of glow like this:
<mx:Glow id="glowIn" duration="500"
<mx:Glow id="glowOut" duration="500"
And if I want to glow a specific component while I loop over the ArrayCollection of the GlowContainer, I tried to do this without success:
First, this will not work:
myHB.ID = "myHBID";
Well, it assigns that string to the id property of the component, but you *cannot* use that id to reference the component. That only works when you declare an id property in an mxml tag.
If you are dynamically creating instances, then you must maintian a list of actual references to the instances yourself.
Why not pass the actual reference into your _objReference property?
alternatives to ArrayCollection would inclyude an "associative aray" or "hashmap", which is implemented using the Object class. Use your ID as the key to the actual reference.
You could also use Dictionary. I would use associative array myself.
Hi Tracy, this is exactly what I want to do but I just missing the way to store the reference while I am creating the object dynamically (the HBox). I tried many different things but without any success.
Base on your knowledge, what will be the type of the _objRerefence and what will be the code to transmit the HBox reference to that property?
Let's say that we create a HBox and the _objReference is shorten here to the property in my class (I just want to make it simple here instead of putting too many code) :
var myHB:HBox = new HBox();
_objReference = myHB; ??? (this not work either)
Youpi!!! I found how to made it!!!
First, I finally have to make the property objReference in my class GlowObjectReferencer as an Object in order to work.
Than, I have to pass myHB as the Object (which, if I understand properly, will put a reference of the current Object into the new class Object).
var _objReference:GlowObjectReferencer = new GlowObjectReferencer (myHB, false);
And when I run my functions to manage the Glow FX (setAllCategoryGlowOut and setCategoryGlowIn), it is now working fine!!!
I am so happy now! I knew it was possible but in my mind, it was just not logic to store an Object in the class but it seems that it is what I need to do! But just to make sure: what I pass to the class GlowObjectReferencer as the first property is only the reference to myHB? Not a copy of myHB; right?
Again, thank Tracy because you force me to find the way to do it!!! ;-))