Solved

dynamic image in flash using PHP MySQL

Posted on 2002-07-23
21
857 Views
Last Modified: 2010-05-18
Hi everyone. I came across this very interesting FLA file posted at Flashkit.com

http://www.flashkit.com/jump.php?ID=6715&type=movies

Download and analyse it.

My question is, how did this fellow made it possible to get images into flash DYNAMICALLY from a MySql database.

Can someone study the code for me and make it simpler for me to understand the process.

Thanks.....
0
Comment
Question by:ssdesign
  • 9
  • 4
  • 3
  • +5
21 Comments
 
LVL 6

Expert Comment

by:rootdir
ID: 7177698
It will sound funny, but How do you execute PHP files? Can I publish in IIS? or I need any other software? Sorry I am totaly new for PHP.

I wanted to check this example.

RootDir
0
 
LVL 7

Author Comment

by:ssdesign
ID: 7179329
ok

if you are using windows then you need to install three things:

1. Apache server
2. PHP4
3. MySql

You can find very useful information and downloads at this website

http://in.geocities.com/samdarshipali/apache-php-mysql.htm

Its one of the best article i have come accross which will help you familiarise yourself with PHP and MySql.

I am eagerly waiting for someone to help me with this thing.

ssdesign
0
 
LVL 2

Expert Comment

by:thor918
ID: 7183606
ssdesign, You don't need apache server in windows to execute php.. you can use several webservers.. Like microsoft personal webserver(comes with win98) or microsoft Internet information server(comes with windows 2000)
0
 
LVL 7

Author Comment

by:ssdesign
ID: 7184312
fine but thats not my question.....

anyways i appreciate your help
0
 
LVL 6

Expert Comment

by:rootdir
ID: 7185817
Ok I got all setup of Apache, PHP, MySQL. I am able to launch above example through apache. Nothing is happning when I clicked on any links or buttons. What is going wrong? Is there any settings in PHP.ini or configure Apache? Please send me PHP.ini and aapache config file. So that I will compare with mine.

My email is rotdir@hotmail.com

RootDir
0
 
LVL 7

Author Comment

by:ssdesign
ID: 7189634
YOu have to place the files in the localhost directory whereever it it.

mostly it is at c:\phpdev\www or c:\php\www or c:\apachegroup\htdocs
0
 
LVL 7

Author Comment

by:ssdesign
ID: 7189637
you must refer to documentation that came with php and apache along with the setups to configure it to your computer....... its very comprehensive
0
 
LVL 7

Author Comment

by:ssdesign
ID: 7213992
hellooooooooo..... whats happening to this question??????? can anyone help me please?????
0
 

Expert Comment

by:WendelWorks
ID: 7318033
First, as far as PHP, MySQL and Apache, go grab FoxServ and install it.  One simple executable on a Windows machine.  I recommend it to all my students.  

  http://sourceforge.net/projects/foxserv  

Then as far as the images go, it is MUCH easier with Flash MX than it was with earlier versions of Flash.  I couldn't get the link you listed to work, but here is something I did a while back:  

http://www.f-body-classic.com/slideshows/ShadetreeMechanic/WendelWorksSlideshow.html  

With Flash MX you can use Flash remoting, skip PHP all together and write the code straight in ActionScript.  Both the pictures and the text come from a MySQL database DYNAMICALLY.  8^)

If this is on the lines of what you want, I will have to review my code.  Maybe I can put a tutorial up or something.  Oh, it is on a slow server (ISDN) so be patient.  

BTW, I couldn't get the page you linked to do anything except display a blank frame.  No pics, no nothing.  
0
 

Expert Comment

by:WendelWorks
ID: 7318041
Oops, my bad.  The link above only has two pictures.  I was trying to make html links in the live text but it wouldn't seem to work.  Here's two versions with more pictures:  

http://www.f-body-classic.com/slideshows/ShadetreeMechanic/ShadetreeEngineRebuild/TearDown/WendelWorksSlideshow.html  

and  

http://www.f-body-classic.com/slideshows/ShadetreeMechanic/ShadetreeEngineRebuild/CrankAdapter/WendelWorksSlideshow.html  

The first link I gave is supposed to be the into page and link to these two and more.  I got pulled off this project temporarily to do other client work.  
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Expert Comment

by:WendelWorks
ID: 7318045
One final note... I made 3 of the 4 panels 'float'.  You can click and drag them around the screen with the mouse.  Eventual plan is to have them expand/compress with the arrows on the top bar of each floating panel.  
0
 
LVL 7

Author Comment

by:ssdesign
ID: 7320874
Wendelworks
ok thats a better nice example but i still didnt get my answer about how to do it.

About the link that i have given. It works. All you have to do is DOWNLOAD the file from the link provided and install it on your webserver running Apache and PHP with MySQL.

I tried the link today and it still works.

Do not try the Flash SWF file at Flashkit because its just to show the interface. For real working example you will have to download it.

About your suggestion. I think if i can look at the code and if it works the same as the example i have provided, then i will award you the points.

Another thing i would likt to tell you is that the example i am pointing to is a very advanced example.

In here you can even upload images to MySql database straight away from Flash interface. and also call them back from same interface.

looking forward to your reply.
0
 
LVL 9

Expert Comment

by:dutchfoxer
ID: 7522036
Allthough this one is locked, I must agree that Flash MX is the way to go. I have just build a dynamic photo system with Flash MX and Perl.

To keep it short, I supply Flash MX with Perl the complete URL of JPG files. The URL is used to import the JPG file into a movie (using duplicate movieclip). Once imported Flash MX can control this JPG (size, rotate, position, etc).

Flash MX cannot put files on the internet server, but Perl can through a form (input type=file). The JPG URL can be stored in a Flat file or SQL database by Perl/PHP. The same applies to text.

Flash MX is the way I think:
    duplicateMovieClip(_root.jpgholder, "jpg1", 1);
    loadMovie("picture1")+".jpg", "jpg1");
    setProperty("jpg1", _visible, false);

0
 

Expert Comment

by:Nao
ID: 7566441
Hello, i don´t have time to download the example file, but i can describe the basic proccess to get images from a mySql database in flash.

In the database you store the url of the image you want to load in flash. You need to write a php file which queries the database an return the url to flash (using php sentences you can write the correct string based on data in the database. The parameters to the query can be specified on the url you use to call the php file). In flash you can use a loadVariables object to execute the php file (from flash point of view its not important if you load variables from a text file or a php, asp, or whatever languaje you like) an get the url from the database to flash trough the php query. When you have the url in an actionscript variable it´s simple to do a loadmovie of that url, it could be a jpg, an swf or whatever you can load into a movieclip.

I hope this helps.
Sorry for my poor english.

Nestor Alonso.
León (Spain).
0
 
LVL 6

Accepted Solution

by:
rootdir earned 500 total points
ID: 7580002
Nao is right. This is nice example to study. Here is the soloution

1. "iris_open_flash" movie sends 'Selected_node' to "page_init.php" page.(dig more if you want how to get selected_node).

2. Php page(page_init.php) query "iof_photos" depends on id_page = '$Selected_node' and retrive detail information about photo(photo movie URL, photo id, x, y, height, width etc) in 'output_photo' seperated by # and |

Note: Check "iris_open_flash.sql" this is inserting data inside "iof_photos" table. "nom_photo"  field name is used to store photo movie URL.

see query

$sql_photo="select * from iof_photos where id_page = '$Selected_node' order by id_photo";

and sends output back to flash like this

echo $output;

3. Inside iris_open_flash.fla you will find function 'create_photo_array()' inside "iris_nuke" movie. This function loads _root.photo_array.

4. "init_photo" function loads photo movie into target movie called new_target + ".CadrePhoto" with x and y parameters.

see this

new_target = "page.page_container."+new_name;
duplicateMovieClip("page.page_container.module_photo", new_name, 100+_root.counter++);
set(new_target+".id", i);
setProperty(new_target, _x, _root.photo_array[i][2]);
setProperty(new_target, _y, _root.photo_array[i][3]);
loadMovie(_root.UrlSite + "data/"+_root.photo_array[i][1], new_target + ".CadrePhoto");


Basically this loading photo dynamically by querying photo movie URL.

I think this will help you lot.

RootDir
0
 
LVL 7

Author Comment

by:ssdesign
ID: 7582083
well rootdir

that is a detailed explanation and let me chew over it. hope to crack it soon.

will need some time to examine the codes

ssdesign
0
 

Expert Comment

by:pok33
ID: 7941309
Have you ever thought about shortening the ways???

There's a possibility to store whole images as BINARY in a DB.

What is this good for you ask??

Instead of sending back the URL of the file and then load the file you can simply write a PHP-snippet that queries the DB and sends back a valid Image-Header and then the image data after it.

So you load the PHP-script as image URL (myImage.php?picID=212&border=black...) cause it returnes the image data with a prefixed valid ImageTypeHeader for that image-type you told FLASH to load.
Using this method you can have the GD or some selfwritten module do image-manipulation jobs for ya behind the scenes.
0
 
LVL 5

Expert Comment

by:elhy
ID: 7973230
BTW ssdesign, ONLY JPG images can be loaded dynamically. Yes, u can use swf but that defeat the purpose of dynamic images as u gotta import the gifs etc into flash then export it to swf before u can use.
0
 
LVL 6

Expert Comment

by:rootdir
ID: 8412993
Did you cracked or chew on my comment?

RootDir
0
 
LVL 7

Author Comment

by:ssdesign
ID: 8433492
i want to accept ROOTDIR's answer
0
 
LVL 7

Author Comment

by:ssdesign
ID: 8433503
thanks, giving B because i also had to do lot of weroks... but a good line of thought from you...
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now