Hi,
I've stucked with a really weird behavior of TextField.
Look at this sample:
PHP Code:
var myField:TextField = new TextField();
var format:TextFormat = new TextFormat();
format.font = "Arial";
myField.defaultTextFormat = format;
myField.width = myField.height = 300;
myField.embedFonts = true; // with false it works
myField.selectable = false;
myField.htmlText = "test this image and you'll see: <a href='http://www.google.com'><img src='image.jpg' width='120' height='124'/></a>";
addChild(myField);
My goal is to have a text field with picture which works as URL link. It works fine in case that font isn't embed, once embedFonts is true then picture is dead. See attachment where is the source code and output html.
Thanks
Hi,
thanks for your attempt!
Did you realize in which case it happens? Only when selectable is true and when between first and second click some part of text is (or was?) selected. Really strange.
I had the same problem and with a quite difficult and demanding client, so i had to figure this out. And i found a not so simple solution but it works. Flash makes movieclips of every <img> in a textfield so they have the same properties as all movieclips and so does onRelease-function work with them. just add id-property to the <img> -tag. It will be the name of the movieclip Flash creates. So you can add the link to this property (of course with some decoding 'cos Flash doesn't allow / . etc in movieclip names). After the textfield has loaded all the <img>'s, go through this textfield-instance and search for movieclips that have an address as their name. Create onRelease-function to all of these with getURL-command. I can post a more accurate explanation if necessary.
Hi,
could you send more informations about your solution? As far as I know TextField isn't DisplayObjectContainer so it cannot store any movieclips.
Thanks
If your <img>'s ID is for example "imglink" and your textfield is on the root timeline named "textcontent", go through the textfield using this code:
for (i in _root.textcontent) {
}
i is the name of the movieclip inside the textfield -object. So if i = "imglink" you can use:
_root.textcontent[i].onRelease = function () {}
This will create an onRelease -function to the movieclip created by <img> -tag. onRelease can be created only if the movieClip has loaded fully, so you have to create a timer function or onComplete-function to check if the movieClip is ready.
Of course you have to also input the address to the ID, so you can use "imglink&&&enteraddresshere" and strip the string using "&&&" as the delimiter. Another problem is that movieClip names cannot contain characters like : / and so on, so you have to replace them with &slash; etc. and decode them in Flash after. Hope this helps.