PDA

View Full Version : TextEvent problem


dahongpalay
12-03-2007, 08:22 AM
Hi, i'm fairly new to AS3.

I have a textfield, say textFieldSample, that has an externally loaded html content and I added a listener (textFieldSample.addEventListener(TextEvent.LINK,h andlerFunction); ) to it to detect when links are clicked within my textfield. Everything was working fine until I added images in my html content, and then the listener doesn't simply fire anymore. I'm don't know what is wrong with it.

Help please?

panel
12-03-2007, 08:37 AM
Image is like separate object so you habve t oadd listener to image itself using its id


textField.htmlText = "<img id='image'src='smile.gif' hspace='2' vspace='0'/>"
textField.getImageReference("image").addEventListener(MouseEvent.MOUSE_DOWN, onMouseDownImage);

dahongpalay
12-03-2007, 08:53 AM
Thanks! Although I forgot to say that the images in the textfield are not links. It's just that when I added the images in the textfield the links that were working before now are dead. :(

this is the html content (sort of :P)

<img id= "image" src="images/img001.jpg"/>
<img id= "image" src="images/img002.jpg"/>
<a href="event:BCK2TOP">back to top</a>

by the way, if there is only 1 image the event works but with multiple images it doesn't anymore. :(

panel
12-03-2007, 10:21 AM
Propably becouse you have to set unique id for each image

dahongpalay
12-04-2007, 12:21 AM
Thanks anyways.