6 Replies - 15693 Views - Last Post: 02 July 2006 - 05:00 PM

#1 katrin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 13-June 06

flash load image dynamically

Posted 28 June 2006 - 08:30 AM

I'm making a website using PHP/MySQL/Flash.
I need ur help how to connect PHP and Flash.
And how about Flash can load image dynamically where the image get from a database.

Please help me.
Thank u so much.
Is This A Good Question/Topic? 0
  • +

Replies To: flash load image dynamically

#2 snoj  Icon User is offline

  • Married Life
  • member icon

Reputation: 84
  • View blog
  • Posts: 3,564
  • Joined: 31-March 03

Re: flash load image dynamically

Posted 28 June 2006 - 08:47 AM

Moving to Flash & ActionScript.
Was This Post Helpful? 0
  • +
  • -

#3 snoj  Icon User is offline

  • Married Life
  • member icon

Reputation: 84
  • View blog
  • Posts: 3,564
  • Joined: 31-March 03

Re: flash load image dynamically

Posted 28 June 2006 - 09:34 AM

I don't know anything about Flash, but the PHP part I can easily answer.

If the image is stored in a database (such as MySQL) you just need to retrieve the data row, echo field that actually contains the image, and add a
"content-type" set to what the image format is.
Was This Post Helpful? 0
  • +
  • -

#4 Will Danger  Icon User is offline

  • "Sorry, that isn't something we support."

Reputation: 0
  • View blog
  • Posts: 55
  • Joined: 01-September 02

Re: flash load image dynamically

Posted 28 June 2006 - 10:04 AM

Hello Katrin,

Are you storing the images in the database as URL's pointing to where the images are on your servers filesystem or are you storing the images in the database as blobs? Depending on which you are doing the answer will be different.
Was This Post Helpful? 0
  • +
  • -

#5 pioSko  Icon User is offline

  • still.dreaming
  • member icon

Reputation: 23
  • View blog
  • Posts: 1,888
  • Joined: 06-June 03

Re: flash load image dynamically

Posted 29 June 2006 - 01:49 AM

In either case, the PHP script will be called from Flash using LoadVars() and sendAndLoad(). These two send data to PHP, PHP does it's thing and sends back an echo back to Flash, which you can then use.

It would work like this:
1.user clicks on button in flash
2. flash calls php script and sends variable to it (ie. image name)
3. php searches database and echo() back to flash where it can find it (address or name)
4. flash loads image using variable sent from php and closes function call

Here is a similar script tha you can work from:
function sender() {
	var result_lv:LoadVars = new LoadVars();
	result_lv.onload = function(success:Boolean) {
		if (success) {
			result_ta.text = result_lv.welcomeMessage;
		} else {
			result_ta.text = "Error connecting to server.";
		}
	};
	var send_lv:LoadVars = new LoadVars();
	send_lv.name = name_ti.text;
	send_lv.sendAndLoad("echo.php", result_lv, "POST");
};

submit_button.onPress = function(){
	sender();
}


See the Flash manual for more information on LoadVars and sendAndLoad(). It's the way to go.
Was This Post Helpful? 0
  • +
  • -

#6 katrin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 13-June 06

Re: flash load image dynamically

Posted 29 June 2006 - 08:06 AM

View PostWill Danger, on 28 Jun, 2006 - 08:56 AM, said:

Hello Katrin,

Are you storing the images in the database as URL's pointing to where the images are on your servers filesystem or are you storing the images in the database as blobs? Depending on which you are doing the answer will be different.


Hi Will Danger,

i'm storing the images in the database as URL's pointing to where the images are on my servers filesystem.

trims ^_^
Was This Post Helpful? 0
  • +
  • -

#7 Will Danger  Icon User is offline

  • "Sorry, that isn't something we support."

Reputation: 0
  • View blog
  • Posts: 55
  • Joined: 01-September 02

Re: flash load image dynamically

Posted 02 July 2006 - 05:00 PM

I'm really sorry I have been away for so long, but pioSko's pseudo-coding is correct. The only missing piece to the puzzle is displaying the images in Flash. Once you get the dataset into flash (the URL's to the images), you just need to create an empty movie clip either on the stage or through createEmptyMovieClip(), and then just do a loadMovie with the URL to the image. The image should load into that clip and should be visible then.

If you wanted, you could also look into using AMFPHP as opposed to using loadVars for getting the data in. Either would work, but AMFPHP (Flash remoting using PHP) might be a bit more of an elegant solution. Up to you.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1