Log in

View Full Version : php and flash



hipapatuk
07-01-2006, 09:07 PM
Hi, as you know every book has a unique ID - so called ISBN number with 10 digits. You can find this ID on every back side of a book. If I want to see a flash animation for book 1234567890 then the Flash file is loading the images from this book and includes the images in the animation. If I want to see another book, then the flash file is loading the images from another book.

All pages of a book are saved in a folder: structure like this:

Books:
- Book 1234567890
--image 1
--image 2
--image 3
-- ...
- Book 2345678901
--image 1
--image 2
--image 3
-- ...

I have to make a PHP program that can generate Flash files dynamically. Example: I open PHP script with ID of book 1234567890

example: flashbuilder.php?ISBN=123456890

then PHP script opens Flash animation and includes automatically images from folder 1234567890. Then I can open the book and turn pages in this book like above in task1. When I open book with this link flashbuilder.php?ISBN=123456890 then front cover is opened and when I open book then inside pages are loaded.

Very important: book pages are saved on other server. Script has to load pages via Internet. This means: script cannot download whole 400 pages for this book. My idea (maybe there is better solution): script loads always 2 pages in "cache". When I turn page forward then already 2 pages in cache loaded and animation can work very fast - no waiting for downloading pages from server.

Also I have to include function to open page in middle of book:

example: flashbuilder.php?ISBN=123456890&page=220

When I open book with this link then script loades automatically page 220 on the right and page 219 on the left (because always shown 2 pages: even number is right, odd number is left on screen). In cache is loaded automatically page 217 and 218 and page 221 and 222 (when I touch page 219 then I go back to last pages without waiting for loading images from server because already in cache, when I touch page 220 then loaded page 221 and 222 from cache very fast.)

"page" - this will be document-ID - in the future all files have this ID as name

If someone has any ideas please help me. Here is the flash book I made: http://iliyanedelchev.hit.bg/

Thank you!

Twey
07-01-2006, 10:12 PM
Well, I'm not a Flash guy (pun only slightly intended) so I don't understand half of this, but have the PHP Ming documentation (http://www.php.net/ming). I strongly suggest you ignore the chap at the bottom with the dodgy email address, His Simpeler PHP Libary, and even His Mate, Matt, Who Dosent Know Much PHP.

BLiZZaRD
07-02-2006, 09:14 AM
I think you have it backwards, and need to have Flash generate it's own images, called from a PHP script that is inside the swf.

You will save load time, and wont block people on a dial up, or those who disable cookies, clear cache hourly, or don't want to wait for each loading time.

Working like a highscore list, in essence, where the POST and VIEW are set to FLASH, instead of HTML. This will show the "image" or "table" or whatever else, inside the swf. You can write the PHP to load the next image and have a small button or mouseOver event on the edge of the virtul pages. When clicked or scrolled over, it will execute the POST methods to the PHP script telling which image to load, pretty simple to keep a base value (the ID of the current book)

You can have Flash set the ID on a button. Say at the main page of the site, the visitor clicks which book to read, when the link is clicked set var id = 1234567890, then on mouseOver of right page id = _root.id + 1 ( - 1) for the left side.

The Flash swf will tell the php which image (based on id #) to pull out, then POST to FLASH and the image will show.

Then basically all you have to rely on for the user is they have the version of Flash player installed and active.


Even another option since you are going through the trouble of making each page an image anyway, import them to the library, and make them all MCs, then use the mouseOver function to load MC with the next corresponding ID #.

DimX
07-02-2006, 09:39 AM
Flash also supports the "GET" method, you can put a flash into document like this: somefolder/flashmovie.swf?isbn=1234567890
You can then acces this number with: _root.isbn

hipapatuk
07-03-2006, 08:57 AM
mmm. That's good DimX. Thanks. If there are any other suggestions write them down, pleace.