|
-
self-portrait
image loaded trough htmlText
Sorry about the obscure name.
Here's the problem; let's say you got the following code and
an image named "img.png" in the same directory.
code: import flash.text.TextField;
var t :TextField = new TextField ();
t.htmlText = "<a href=\"#\"><img src=\"img.png\" id=\"myImage\"></a>";
addChild ( t );
The textfield will automatically load in the image and embed it.
1) How can I get a reference to the image? (To be able to handle IOErrors for instance).
I checked the livedocs and came up with this (TextField - htmlTex):
the id attribute - Specifies the name for the movie clip instance (created by Flash Player) that contains the embedded image file,
SWF file, or movie clip. This is useful if you want to control the
embedded content with ActionScript.
Sounds like exactly what I need, only thing is - how does it work? There's no documentation whatsoever.
2) The html-link placed around the image tag won't work as you might
expect. Only the border around the image is a button, the actual image
lies over the hitarea (Check out this example ). If I solve the first
problem I'll probably be able to find away around this though.
Thanks in advance
-
Senior Member
In Flash 8 you could reference to the image using
t.myImage;
but that does not seem to work any more in AS3, since myImage is not a property or method of the TextField. Either the statement in the Live docs is wrong or there is a different way of doing that.
- The right of the People to create Flash movies shall not be infringed. -
-
Senior Member
Different way 
t.getImageReference("myImage");
You can give button mode to the image in this way:
var myImage:Sprite = Sprite(t.getImageReference("myImage").root);
myImage.buttonMode = true;
Last edited by cancerinform; 01-20-2007 at 07:58 AM.
- The right of the People to create Flash movies shall not be infringed. -
-
self-portrait
Thank you cancerinform! You have truly saved the day(week)!
I've already started a script that cuts up the text into multiple text fields
and places them around images, but I'll happily discard that.
-
-
Senior Member
- The right of the People to create Flash movies shall not be infringed. -
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|