PDA

View Full Version : help!


alsvik
03-21-2005, 09:53 PM
I have a site that loads text dynamic from .txt-files. (render as html)
I've been searching high and low to find a way to have pictures inside the .txt-files.
Is it possible?

<img src="picture.jpg"> - doesn't work!

i use this code to load the text:

loadVarsText = new loadVars();
loadVarsText.load("content/text.txt");
loadVarsText.onLoad = function(success) {
if (success){
trace ("done loading");
System.useCodepage=true;
text.html = true;
text.htmlText = this.var1
}else{
trace ("not loaded");
}
}

Gibberish
03-21-2005, 11:04 PM
you want to display pictures in flash? you would have to load in the image name in as a variable then call that image through a loadMovie(); Flash does not support the HTML <img> tag.

So say var2 = "images/myImage.jpg" in your txt

loadVarsText = new loadVars();
loadVarsText.load("content/text.txt");
loadVarsText.onLoad = function(success) {
if (success){
trace ("done loading");
System.useCodepage=true;
text.html = true;
text.htmlText = this.var1
// set the variable
image = this.var2
// create a holder for the image
this.createEmptyMovieClip("imageHold",0);
//place the holder
imageHold._x = 100;
imageHold._y = 100;
// place the image in the holder
imageHold.loadMovie(image,0);
}else{
trace ("not loaded");
}
}

HTML Tags support: MX 2004 (http://livedocs.macromedia.com/flash/mx2004/main_7_2/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Flash_MX_2004&file=00001040.html) and 5/MX (http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_14808) (MX does support the <b> and <font> tags though I don't think there are actual docs on this from Macromedia)

alsvik
03-21-2005, 11:46 PM
Thanks ...

Now it just adds 'var2="content/image.jpg"' to the textfield.
Perhaps something i misunderstood!?
Do i need to create a seperate area to load var2 into?

Gibberish
03-21-2005, 11:59 PM
are you seperating the variables by a '&'?

var1=thisisvaraibleone&var2=content/image.jpg

alsvik
03-22-2005, 08:36 AM
still no luck! :confused:

Is it so, that if i use Scrollbar i can't have pictures shown?
Do i need to use Scrollpane then? (and could that be the cause of the problem?)

MichaelxxOA
03-22-2005, 08:44 AM
what version flash are you using? if you have flash mx 2004 i think that it supports the img tag.

alsvik
03-22-2005, 08:56 AM
I use Flash MX v.6
- but i also have 2004, so i'll just try to install it and test it there too.

( i just better like MX than 2004)

MichaelxxOA
03-22-2005, 08:59 AM
well what's the directory your keeping the images in, is it the root directory or an images folder on the root directory?

alsvik
03-22-2005, 09:00 AM
i have both text and images in a folder called "indhold".

MichaelxxOA
03-22-2005, 09:01 AM
well you could put um... the path to the image in there
what does your txt file look like right now?

alsvik
03-22-2005, 09:02 AM
in Flash MX 2004 i get this error:

**Warning** Scene=Scene 1, layer=knap text, frame=1:Line 1: Case-insensitive identifier 'loadVars' will obscure built-in object 'LoadVars'.
loadVarsText = new loadVars();

alsvik
03-22-2005, 09:04 AM
txt-file:

var1=teste leste
&
var2="indhold/ture.jpg"

MichaelxxOA
03-22-2005, 09:07 AM
well it's telling you that

loadVars();
needs to be
LoadVars(); with the capital L.
let me look into the other code for a bit okay?
I'll get back to you soon

alsvik
03-22-2005, 09:11 AM
Thanks Michael

I've changed the loadVars to LoadVars - and yes i figured that out going throuigh the error-text. Just got a little worried and didn't think before posting :rolleyes:

MichaelxxOA
03-22-2005, 09:13 AM
so does it work now? lol gotta ask

alsvik
03-22-2005, 09:16 AM
Now i don't get any errors - but still no image :cool:

MichaelxxOA
03-22-2005, 09:17 AM
alright I have to go bu i'll look at it more in the morning
good night!

alsvik
03-22-2005, 09:42 AM
Thanks alot!
Figured it out!

Two things went wrong:

First i didn't publish the swf as Flash 7 and didn't use actionscript 2.
Secondly i didn't use the correct tag to load image within the txt-file:
var1=<img src='content/image.jpg'>

So actually i didn't need to load two variables.
So this AS works fine:

on (release) {
LoadVarsText = new LoadVars();
LoadVarsText.load("content/text.txt");
LoadVarsText.onLoad = function(success) {
if (success){
trace ("done loading");
System.useCodepage=true;
scroller.html = true;
scroller.htmlText = this.var10
}else{
trace ("not loaded");
}
}
}


:D

MichaelxxOA
03-22-2005, 05:45 PM
hey good job! Congrats.