|
-
Loading image into a dynamic text field
I need to be able to display images in a dynamic text field using HTML. I have MX2004, and it's supposed to be possible.
Here is basically the code I am currently trying to use:
PHP Code:
myText_txt.html=true;
myText_txt.htmlText = "<img src='../external/mindbutton.jpg' id='link01' width='88' height='31'>";
Unfortunately that doesn't display the image at all. I've double and triple checked to make sure that URL is right also, and it is. Is there something that I'm missing?
-
sometimes it doesnt like an img alone (so add the ) ; also changed ' to \ (escape slashes are safer). try this
code:
myText_txt.html=true;
myText_txt.htmlText = " <img src=\"../external/mindbutton.jpg\">"
-
Make sure the .jpg is not progressive as well I guess!
-
Many thanks moagrius. It works now!
-
-
Hrm... problems again -_- Before, I was doing it in a seperate swf to get it working before i tried to make it work w/ the site i'm building. It worked great in the test swf I made. But, now that I put it into my actual movie, it's no longer working. -_-
code: right_txt.html = true;
right_txt.wordWrap = true;
right_txt.multiline = true;
right_txt.label.condenseWhite=true;
right_txt.htmlText = " <img src=\"../external/mindbutton.jpg\">"
Is it normally this buggy? Or is it just me..
-
proably the path
assuming the jpg and both swfs are in the same folder, you don't need any dots or preceding slashes
just
code:
right_txt.html = true;
right_txt.wordWrap = true;
right_txt.multiline = true;
right_txt.label.condenseWhite=true;
right_txt.htmlText = " <img src=\"mindbutton.jpg\">";
or if the folder "external" is in the same folder the swfs are in
code:
right_txt.htmlText = " <img src=\"external/mindbutton.jpg\">";
also noticed no terminating semi-colons? they're included in the two codes i just gave
-
Originally posted by Jaelle_MJ
Hrm... problems again -_- Before, I was doing it in a seperate swf to get it working before i tried to make it work w/ the site i'm building. It worked great in the test swf I made. But, now that I put it into my actual movie, it's no longer working. -_-
Code:
right_txt.html = true;
right_txt.wordWrap = true;
right_txt.multiline = true;
right_txt.label.condenseWhite=true;
right_txt.htmlText = " <img src=\"../external/mindbutton.jpg\">"
Is it normally this buggy? Or is it just me..
hmm what's that bit in red?
-
the condenseWhite is supposed to take out extra white space. Eventually i'm going to be loading an xml file into that text box, but I haven't gotten that far yet, since the image refuses to work.
I'm 99.9% sure the path is right. My directory structure is like this:
/flash/file.swf
/external/image.jpg
-
lol, i know what condenseWhite does ya kook
i meant... everything so far has been
code:
right_txt.something
but now there's that one phantom
code:
right_txt.label.something
-
It was supposed to fix a possible formatting problem that can occur w/ the xml. However, it seems to work fine w/out it as well. The image still doesn't show up either way though.
-
hmmm ok what i'm saying is... that means you're referencing something else, an mc or textfield named "label" which makes me wonder if we're targetting the right thing
go here
http://qfiles.iamyourhost.com/fkstest/jaelle.html
-
Ok... now I'm confused. So I just tried to make it simpler. The label.condenseWhite there isn't causing me any problems as of yet. I take it out completely and it still works fine. The image still doesn't appear tho.
I'm going to attempt to explain again in more detail.
The non-simplified version of what I have in my movie is:
code:
right_txt.html = true;
right_txt.wordWrap = true;
right_txt.multiline = true;
if(content_xml.firstChild.childNodes[i].attributes.type=="links") {
right_txt.htmlText = "<ul><li><a href=\""+content_xml.firstChild.childNodes[i].firstChild.firstChild+"\">"+content_xml.firstChil d.childNodes[i].firstChild.attributes.header+"</a> <img src=\"../external/mindbutton.jpg\"></li></ul>";
trace(right_txt.htmlText);
}
I used trace to see what exactly it was reading. It returns:
Code:
<TEXTFORMAT LEADING="2"><LI><FONT FACE="Arial" SIZE="14" COLOR="#000033"><A HREF="http://www.undeadninja.com/unmindful/unmindful.html" TARGET="">Unmindful</A> </FONT></LI></TEXTFORMAT>
As you can see, it doesn't seem to like the idea of the image being in there. And it obviously doesn't show up either.
-
maybe this'll help
open a new fla, paste this in frame 1, publish, save, close.
code:
var z:Number = 0;
var tf:TextFormat = new TextFormat();
//add your text formats here
this.createEmptyMovieClip("table", ++z);
function textblock(n, x, y, s) {
var k = _level0.table.createEmptyMovieClip(n, ++z);
k.createTextField("tx", 0, x, y, 220, 15);
k.tx.html = true;
k.tx.htmlText = s;
k.tx.setTextFormat(tf);
}
var x:XML = new XML();
x.ignoreWhite = true;
x.load("jaelle.xml");//change jaelle.xml to the name of your xml sheet
x.onLoad = function(success) {
if (success) {
for (i=0; i<x.childNodes.length; i++) {
j = i*80;
textblock("fieldA"+i, 0, j, x.childNodes[i].childNodes[0].childNodes);
textblock("fieldB"+i, 0, j+15, x.childNodes[i].childNodes[1].childNodes);
textblock("fieldC"+i, 0, j+30, x.childNodes[i].childNodes[2].childNodes);
textblock("fieldD"+i, 0, j+45, x.childNodes[i].childNodes[3].childNodes);
textblock("pic"+i, 300, j, "<img src='"+x.childNodes[i].childNodes[4].childNodes+"'>");
}
}
};
and your xml sheet is formatted like this
Code:
<emptyplatitude><field100>maple</field100><field200>syrup</field200><field300>is</field300><field400>tasty</field400><field500>images/picoftastymaplesyrup.jpg</field500></emptyplatitude>
<emptyplatitude><field100>pixel</field100><field200>fonts</field200><field300>are</field300><field400>for girls</field400><field500>images/girlinpinkdress.jpg</field500></emptyplatitude>
<emptyplatitude><field100>i'm</field100><field200>out</field200><field300>of</field300><field400>ideas</field400><field500>dumbguy.jpg</field500></emptyplatitude>
-
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
|