PDA

View Full Version : PHP variable for Image into HTML Rendered Text Box


Clark
06-16-2005, 11:17 PM
Hi all,

I'm having diffculty in calling a variable in PHP that will contain <img src='logo.jpg'> and then load the variable through actionscript and put it in a dynamic text box that is HTML rendered and to show the logo.

If I put it through actionscript as (with the textbox having an instance name of 'logo_txt'....
logo_txt.html = true;
logo_txt.text = '<img src='logo.jpg'>;
I open this in the browser and it works so the image is in the correct form.

So then I've tried it through PHP such as
<?php
$logo= "<img src='logo.jpg'>";
print '&logo='.$thedate;
?>

and the use
//Creat LoadVars instance to retrieve date from PHP script
var getDate:LoadVars = new LoadVars();
//load IMG from PHP
getIMG.load("test.php");
//assign theDate property of the LoadVars instance to text field
getIMG.onLoad = function() {
logo_txt.html = true;
logo_txt.text = this.logo;
};

So I open the swf in a browser to test it but logo only the <img scr='logo.jpg'> is printed. If I open the php file it shows the image with &logo= to the left.

Any ideas?! I've tried to get around it so many ways.

I've tried it through a .txt file that is rendered as HTML as bold etc works in there. But then nothing is shown the IMG tag isn't seen and no image.

HELP!

Cheers,
Clark

ZBC
06-18-2005, 04:48 AM
Once you have loaded the variable in flash it is just text. So you have to then use the load movie function like so.
logo_txt.htmltext = loadMovie(this.logo);to load the picture into flash. Or if that doesn't work, in php put the full path to the image using http://www... etc. and use the .htmltext insead of .text, like in my example above.

Clark
06-18-2005, 01:04 PM
Once you have loaded the variable in flash it is just text. So you have to then use the load movie function like so.
logo_txt.htmltext = loadMovie(this.logo);to load the picture into flash. Or if that doesn't work, in php put the full path to the image using http://www... etc. and use the .htmltext insead of .text, like in my example above.

When I put the actionScript as per your example the "htmltext" doesn't go blue in the editor. I guess there's a problem there.
EDIT: The "htmltext" needs to be "htmlText" for it to work

Also, if I put the "loadMovide(this.logo)" I get the following error message...
Wrong number of parameters; loadMovie requires between 2 and 3.
theLogo_txt.htmltext = loadMovie(this.logo);

I've tried the full path too but not working.

ZBC
06-18-2005, 08:46 PM
I sorry, I used it worng.
loadMovie("this.logo", "logo_txt.htmlText");There are two parameters. and I used them in the wrong order. That should solve that.

Clark
06-18-2005, 09:14 PM
This still doesn't make it work.

The error messages have gone now.

You couldn't knock up a sample .fla for me please? Or give a tested ActionScript and PHP blow-by-blow coding as I just can't seem to get it.

ZBC
06-18-2005, 10:04 PM
I think I know what is wrong. You should try to load the picture into a movie clip not a text instance. Try making a simple flash movie clip with some sort of background to keep its shape. Then driect the picture to tehe movie clip.

Hope that helps.

Clark
06-19-2005, 12:16 AM
To ZBC,

To put it in a movie clip wasn't what I wanted as I wanted it in the text box.

However, I've got it to work somehow like this....

<?php
print '&logo='."<h1>This is the logo</h1><img src='http://www.hullkrfans.co.uk/logo.jpg'>"
?>


//Creat LoadVars instance to retrieve date from PHP script
var getLogo:LoadVars = new LoadVars();
//load date from PHP
getLogo.load("test.php");
//assign theDate property of the LoadVars instance to text field
getLogo.onLoad = function() {
theLogo_txt.htmlText = this.logo;
};


God knows how I stubled across this when I must of tried every combination possible!!!!

Thanks for everyones help.