This content has been marked as final. Show 11 replies
Does Adobe know an answer to this?
Look into event.currentTarget.
I think you need to cast the object as necessary.
ntsiiii........... event.currentTarget would be the canvas itself rather than the child as the documentation says after all.
Greg Lafrance think about it .... how can you cast the object as necessary when the type of the object itself is not the type is supposed to be?
Alert.show((event.target is MyAClass).toString()); .... this one returns false even though I'm creating the class before and adding it to the canvas, where it should be true.
It has to do with custom extended displayobjects because when I tried created an LinkButton on the fly it would recgonise it's type, but not extended displayObjects.
Please any suggestions or shall I just revert to registering an event click for each DisplayObjects.
Any other solutions or I'll have to assume this is a bug from Adobes end?
I'm not so up on OOP that I can say whether or not this is a bug, but there are times when objects passed around are of a certain type, but their type becomes generalized. They are still an object of a certain type, but you need to know their type and then cast them back to their original type.
In your case you want to check their type, and maybe Tracy (Ntsiii) can comment on that.
there's not so much OOP... only an inheritance where I'm extending my class named "Location" extending Image... (the Display mx:Image)
as the documentation says event.target should be...
you'r saying to use "as" instead of "is". I may try that but I'm confident enough that it wouldn't work because the flash player (for some reason) cannot understand the type of extended objects.....
In your case you want to check their type, and maybe Tracy (Ntsiii) can comment on that. --->
As I already I'm checking the type if it's my extended object but returns false with "is". event.currenTarget doesn't work because it would be the Canvas itself and not the child.....
Do Adobe take a look at these forums?
, Varagian, dont be angry, what you are doing is seems correct, you should get loader reference instead of image, because I believe every loaded image has associated loader that loaded it;
from loder you should be able to get information about the image includin gits refference, calling "contentLoaderInfo" which returns LoaderInfo and here is api doc for that object :
P.S : I am roughly guessing also all but I think thats how it works.
Lang reference is your best friend http://livedocs.adobe.com/flex/2/langref/ or
I'm frustrated because I cannot understand why this has to be so complicated for custom objects or Image where when adding a normal event wouldn't be.
I managed to get a FlexLoader type....
I should get the DisplayObject .... but from where?
I tried loader.getChildAt(0) ..or .content or .contentLoaderInfo.content to no avail....
what do you think is the next step?
Thanks for your time btw
lol now I'm getting angry ;)
now with the FlexLoader.content figured that the object is Bitmap!!!!!!
now why is it a Bitmap when on load this object was an extended Image object of mine!?!
The loaded image you're clicking on IS what would be returned with event.target. It is added to your extended image class as a child of that class. So this is probably want you want to do:
Alert.show((event.target.parent is MyAClass).toString());
Keep in mind that if you EMBED your images within your custom image class at compile time instead, then you can check for it like you did before:
Alert.show((event.target is MyAClass).toString());
Hello VarioPegged.... thanks for your help.
it worked hehe