Question
getImageReference and eventListeners
Hi,
Through a textField you can access images (or it's Loader object) with
getImageReference( imgId ). This works fine.
Now I want to add eventListeners to the Loader to detect mouseClicks on
the images. But somehow that part won't work.
Code from a quick test:
In a function which loads the XML I have these lines:
var img:Loader = Loader( html_txt.getImageReference( "img_0" ) );
img.contentLoaderInfo.addEventListener( Event.COMPLETE, loadedImage );
the eventListeners are:
function clickImage( evt:MouseEvent ):void
{
trace( evt.target );
}
function loadedImage( evt:Event ):void
{
trace( evt.target.content, "is loaded" )
var li:LoaderInfo = LoaderInfo( evt.target );
li.content.addEventListener( MouseEvent.CLICK, clickImage );
li.loader.addEventListener( MouseEvent.CLICK, clickImage );
}
Al this traces:
[object Bitmap] is loaded
If I click on tha image in the textField however, nothing happens... Now
I could go with the textField, have it listen to mouseEvents, get the
bounds of all the images in it and see over which the mouse is at that
moment, but that seems rather silly if I could get each image to
register it's own listeners.
Anybody?
Thanks in advance.
Manno
--
----------
Manno Bult
http://www.aloft.nl