Bring in Pictures from a database into Flash

Here's what I want to do.  I am going to have a database set up and for each person's username/password I will have about 20 or so pictures.  It's for a wedding website for brides.  Now lets say I have 20 pictures in a database.  How can I get those 20 (the number will vary for each bride) or so pictures into Flash.  I would like to control the positioning and size of the pictures.  I want to have them sitting on the Flash page in an orderly way all the same size, like a thumbnail.  Then when they click on the picture I want a larger version of that picture to show up in the middle.  Please help.  Thanks.
graymikeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rascalpantsCommented:
you should save each JPEG into an individual .SWF and then use loadMovie("bride1.swf",_root.blankclip);


"blankclip" is just a movieclip container that you can then use to size and position the .swf once it is loaded into the movie...



let me know if you need more info


rp

0
graymikeAuthor Commented:
So lets say I have 20 pictures each for 20 people.  I would have to manually put each jpg into a shockwave file.  That would be 400 shockwave files.  I want to automate the system.  Can I place shockwave files into a database?
0
rascalpantsCommented:
you can't put shockwave files into a database...

currently there is no way for Flash to dynamically load a jpeg into a movie...  

you would just have to create a template .swf and then put the jpeg into that template, and then save the .swf to the server.  your flash application can then load that .swf dynamically from the server and everything can be controlled by referrences from a database...

To my Knowledge there is no work around for this yet...  you still will have to create the 400 .swf that you put the picture in...

rp
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

henrywwCommented:
well rp, if that's jpg and if graymike has MX that just load it in as is... don't have to create SWFs ..
0
graymikeAuthor Commented:
That's just doesn't make sense.  It's very time consuming.  Do you suggest I do this in an HTML page?
0
rascalpantsCommented:
I am pretty sure Flash MX can't dynamically load jpegs...  if it can, then PLEASE let me know...

I have been using the SWF load method way too long...  :)


rp
0
graymikeAuthor Commented:
no I have Flash 5
0
rascalpantsCommented:
well, then you can't even use henry's solution anyway...  but let me know how :)

sorry...  I can't think of an easier way to get those 400 images into Flash dyanamically...

rp
0
henrywwCommented:
yes ... u mean loading jpg file ... yes it does.
try put a jpg next to ur swf and do

loadMovie("text.jpg","holder");
seeing is believing ... LOL


bad luck not for 5 ...

if u have php/asp whatever for ur backend ...
use the turbine, much cheap than generator and u don't need to manually convert the jpg to swf just upload the jpg. i did a site with dynamic jpg in flash 5 2-3 years ago ...

here's the link for u ...
http://www.blue-pac.com/

but if u wanna save money and the site is done/update manually, just go for the lo-tech way ... import jpg -> export swf ... won't take too long anyway :)
0
henrywwCommented:
see http://www.god.com.hk 

the product section is done using php turbine, flash 5
on linux/apache/php
with content management system, user update/upload normal jpg and the product ticker is updated automatically using dynamically generated swf (from the given jpg)
0
rascalpantsCommented:
holy crap... I guess I was thinking about gif images... I know there was one that could not be dynamically displayed...

that saves me some time now...

anyway...  graymike, if you can get a hold of a copy of MX then do so, because henry just saved me a few hours a month on updating a company intranet site...

how would you like your payment henry?  in points or in marbles?  :)

rp
0
graymikeAuthor Commented:
I can't do it manually though.  What I would like to deisng for my client is to allow them to upload the pictures they take from their computer to a remote database.  Then when they login it loads up the pictures on the database.  Preferably I would like to have the pictures loaded into Flash but I may just have to do it with just a normal HTML page and stay away from Flash with just this section of the website.  I will be using ASP and an Access database.  Any other ideas?
0
henrywwCommented:
how much control of the server do u have?

if the only function u need is to convert upload jpg to swf ... that for flash 5 ... u can do with some 3rd party software. can u install asp component to do the job??

but ... if u really want to use flash. write ur code and script, do ur animation everything in 5 ...

then download the trial for MX, write the code for load jpg and compile it in MX swf ... upload ... done ... it will work.

0
rascalpantsCommented:
graymike...

I just tried this in Flash MX but exported it into a Flash 5 format, and it worked fine...


loadMovie("/images/"+imageName+".jpg","container");

where the variable of imageName whould be what is driven by the database...


so the variable in your ASP page would look like this:

Response.Write "clientName1="&rs.Fields("clientName1")&"&imageName="rs.Fields("clientPhoto1")&"&"


the above will look something like this when outputted to the screen:

clientName1=Smith Wedding&imageName=bride_groom&


you just have to make your ASP page out put the right format of information, so Flash can read the variable in...



in this code:

loadMovie("/images/"+imageName+".jpg","container");


the SWF is loading the variable imageName into the movielcip with the instance name of "container"


you would just build an application that displays the content depending on the results of the ASP page.


let me know if you are following what I have done, or need me to email you my example that uploads a jpg file into a container clip...


rp





0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
graymikeAuthor Commented:
The only concern I have with Flash MX is that a higher percentage of people would have to download the Flash Player to use it, right?  Only a few people have to download the Flash Player 5 to view it?  Am I right or wrong.  

That being said. OK. Can you walk me through a few examples of how i can load these pictures.  Let's say I have an access database and it has the path to the jpg.  like "images/colleen.jpg".  How do I get that jpg into Flash to be a certain size and to sit in a certain position (like a thumbnail that can be clicked on/button).  In the center I would like people to see the full size picture (the picture of the thumbnail they click on).  Can you just go slow and let me know how to do it if I do use Flash MX?
0
graymikeAuthor Commented:
When you say container do you mean an empty movie clip?  If the person has 20 pictures do I have to have 20 separate movie clips?

Here's what I want to do.  My client owns a beauty salon.  They do the hair for a lot of brides to be and they take pictures of the hair.  They want to be able to allow that bride to go to their website and login.  After they successfully login I want it to be able to bring in the pictures that are associated with that bride only.  Whether its 15 pictures or 21 pictures or whatever.  Do you suggest I have like a template for that Flash page and have en empty movie clip waiting there for each possible picture?
0
henrywwCommented:
rp,

the reason why it works, it is because the fucntion loadMovie exist in flash 5 and u have flash 6 player on ur computer .... so it should work, if not there is a problem.

and for graymike, i would say no ...
i dare to say by this time, 80%+ user are using flash 6
and so what if they don't have????

do a simple script to check the flash version, if they are using 5, get them to download from MM ... a simple click and install in less than 1 min.

people are so used to it now, i mean flash player. and installing a new version has very less resistance on user. unlike those unknown plug-ins, flash player is a world number 1 plug-in 500milion user i think ...

nothing to worry about.

if u insist on using 5 to do the development (which i don't see the pt why?) ... then u will need to install some server side component to generate the jpg to swf ...
there are a few ones ... i have to check for u, some expensive more powerful some only does the jpg to swf conversion & i suppose it is cheaper, as u know, nothing for windows/asp is free ... only a few i can think of.

cheers
0
henrywwCommented:
however, .....

i will strongly suggest u to get MX and do it in the new version ... 6 months later ... u will be happy sitting in front of ur site and seeing thousands of pictures uploaded ... and no one will complains why u are doing in MX and not 5 ... trust me.
0
henrywwCommented:
not with MX ...
everything is dynamically created, unload ... load .. jpg ...

even the empty movieclip is created on the fly, load the jpg, resize it ... center it ... ... ...

done ... in no time.
0
graymikeAuthor Commented:
I have done all of the site in Flash 5 so far.  This is the only section I have yet to finish.  Is it OK to have most of the site done in Flash 5 and then just have this section in Flash MX?  I think the answer is Yes.

Secondly, has downloading the Flash PLayer 6 become much easier.  Is it true that all you have to do is press the button and its downloads automatically for you, then you restart your computer? I know for the Flash Player 5 download you had to download it to the desktop or anywhere and then double click on that icon again.

So if that's all true then I would like to do this photo section in Flash MX.  I will try when I get home tonight what you have already recommended.  However, I may ask alot of follow-up questions as I work through it.  Thanks.
0
graymikeAuthor Commented:
Henry,

So you are saying I can do all of this in Flash 5.  I just have to make sure they have Flash Player 6 installed before they can view it.  So I don't have to use Flash MX at all?
0
henrywwCommented:
yes .. u can do that ... if u have everything done except the load jpg bit ... keep it there, download the MX trial and see it for urself. just use the sample code rp supplied, load a jpg in a movieclip ... WOW ... it happens... and resize it like u normally do with movieclip, center it ... _x = _width/2 etc ... blah blah blah...

no restart is required...
very easy ... and no one ... no one wants to miss out to see what new things the flash MX player can do ... why not?

keep asking - rp - no problem, ... rp and the experts here are all for u :) LOL ... i get something like 4 -5 follow up question even after those questions were closed.

cheers
0
henrywwCommented:
hmmm i think we post at the same time ...

well ...

"I can do all of this in Flash 5.  I just have to make sure they have Flash Player 6"

technically "YES"

just use the loadMovie as in flash 5

and if the player is MX it will load even the loadMovie is loading a JPG ... not in player 5 ...

so ... make sure u have a detector to check the flash player version ...
0
rascalpantsCommented:
I typically still output all of my swf as Flash 5, so I don't have any problems with users not having Flash 6.  do what Henry has suggested about a version check, and then you will be set...


I am about to make an application that displays images dynamically to replace my existing app... so let me know if you need more help...


rp
0
henrywwCommented:
that's right, but if the user's player is 5 ... then the load JPG won't work.

ok then ... since rp is doing one, there u go ...
u can ask everything u want to know about how to use MX to load jpg dynamically ...

cheers rp :)

0
rascalpantsCommented:
I thought exporting from Flash MX to a flash 5 is just like creating the swf in flash 5... is that not the case Henry?


If it is the case, then shouldn't the load JPG thing work in Flash 5 if the swf was created in Flash 5?  I don't have a testing environment for the Flash 5 Player, so I can't test...  but my theory should work....

let me know

rp
0
henrywwCommented:
well ... yes it is. u are right. export the flash to version 5 will make it compatiable so it will play with no hiccups if the player is version 5... but if u use MX command or function only available to MX it will not work, not with v5 player.

but in this case ... the loadMovie is common to 5 & MX, so it will work fine loading a swf, but not jpg. v5 player can't load jpg. but if the movie (v5 swf) is in played in a v6 player and the loadMovie loads a jpg, it is ok.

try it if u have a computer with v5 player ... :)
0
rascalpantsCommented:
that is the problem...  I don't have that testing environment set up...


well, then just make em use Flash 6 player!  :)


rp
0
graymikeAuthor Commented:
Hey Henry or Rascal Pants.
I'm just wondering if you are around tonight.  I am working on this problem right now and I was wondering if you were there in case I had some quick questions.  Just write back if you are.  Thanks.
0
graymikeAuthor Commented:
Hey Henry or Rascal Pants.
I'm just wondering if you are around tonight.  I am working on this problem right now and I was wondering if you were there in case I had some quick questions.  Just write back if you are.  Thanks.
0
graymikeAuthor Commented:
Hey Henry or Rascal Pants.
I'm just wondering if you are around tonight.  I am working on this problem right now and I was wondering if you were there in case I had some quick questions.  Just write back if you are.  Thanks.
0
graymikeAuthor Commented:
I have run into problems. I am trying to test it out before I do the real thing.  I'll list what I've done so far.

Here is my asp page;
<%
Dim Conn, mySQL, Recordst
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DSN=images"
mySQL = "SELECT * from Image"
Set Recordst = Server.CreateObject("ADODB.Recordset")
Recordst.Open mySQL, Conn, 1, 1
Response.Write "Name="&Recordst.Fields("Name")&"&imageName="&Recordst.Fields("imageName")&"&"
%>

Here is my flash page.  I have two empty movie clips on the page, one called "empty1" and the other "empty2".  I made an instance for both of them. I have actionscipt on the first frame;
loadVariablesNum ("images.asp", 0);
loadMovie("/images/"+imageName+".jpg","empty1");

My Access database;
table name = Image
Fields=PictureID, Name, ImageName
Sample Date (Row1) = 1, allison, alli1
Sample Date (Row2) = 2, allison, alli2

I just first of all tried to get one picture in but that didn't work so I stopped there.  How do you get one picture in and then after that how do you get more than 1?



0
henrywwCommented:
the way u are doing it is quite ok.

but if u can just loop thru all images name then send the lot to flash, let flash display it one by one it is easier

like
Response.Write "Name="&Recordst.Fields("Name")"&imageName="
while not Recordst.Fields("imageName").eof
Response.Write Recordst.Fields("imageName")& "||"
wend

us a delimiter to separate the records

and split it in flash ....
...
...
.. etc ...

done ... finish ...

:)
0
rascalpantsCommented:
yes, a simple  while not Recordst.EOF  will do the trick just fine:


WHILE NOT Recordst.EOF

Response.Write "Name1="&Recordst.Fields("Name1")&"&imageName1="&Recordst.Fields("imageName1")&"&imageName2="&Recordst.Fields("imageName2")&"&imageName2="&Recordst.Fields("imageName3")&"&imageName2="&Recordst.Fields("imageName4")&"&imageName2="&Recordst.Fields("imageName5")&"&&imageName2="&Recordst.Fields("imageName6")&"&imageName2="&Recordst.Fields("imageName7")&"&imageName2="&Recordst.Fields("imageName8")&"&imageName2="&Recordst.Fields("imageName9")&"&imageName2="&Recordst.Fields("imageName10")&"&"

Recordst.MoveNext
WEND


BUT, you need to set your while loop up so that you reference a unique ID for each clients name and image...  something like this:


client1=value&client1_img1=value&client1_img2=value&client1_img3=value&


that way your Flash application can keep track of everything...

so your ASP code should look something like this:

rp

0
henrywwCommented:
well ... i will just use 1 variable for each type and split it with the delimiter ... much easier


like

imageName=henryww||rp||graymike&imageURL=images/hw.jpg||rp.jpg||gm.jpg

(with server.urlencode of course ... )

then split the string with imageName.split("||") ...

0
rascalpantsCommented:
never used that before...  not sure how it works...

eitherway, I think your problem has been solved graymike...


if you have any other questions, let us know...


rp
0
henrywwCommented:
yes ... answer accepted :)
ha ha ha ...

well, write ur code extactly as given by rp in the flash 5

export it ...

open it in a the browserwith a flash 6 player ... and PUFF ... the jpg is loaded.

cheers
0
henrywwCommented:
i like splitting ... it is easier to do it in an array than eval() ...  and smaller data size for sending/loading

just a habit ... rp's way works fine too :)

cheers
0
graymikeAuthor Commented:
I do really appreciate both of your help.  When I get home tonight I will try it out and let you know right away.  Thanks again.  I will have to raise the points if this works.
0
graymikeAuthor Commented:
I am still not getting it.  I'm a little bit slow programmically.  Can you give me the exact Response.write code for the two pictures I have above; alli1.jpg and alli2.jpg.  And also the actionscript I would have in Flash to pull in those 2 pictures.  Thanks.
0
rascalpantsCommented:
something I saw is your code above that might be giving you some errors...

below you are using " instead of '

Response.Write "Name="&Recordst.Fields("Name")&"&imageName="&Recordst.Fields("imageName")&"&"


the above statement should be this:

Response.Write "Name="&Recordst.Fields('Name')&"&imageName="&Recordst.Fields('imageName')&"&"

maybe that was your problem...

let us know


rp
0
henrywwCommented:
sorry ... what's the difference??
0
graymikeAuthor Commented:
I will try that tonight and see if it works.  I may just create each page manually because even if I do get this code to work it seems to take away my control a bit from the design of the pictures and the page.  I may be totally wrong on that point.  Anyway, to give you an idea of what I'm trying to do, go to the following link.  Then click on wedding then click on wedding pictures login.  Type in allison for username and donlevie for password.   This is just to give you an idea of what I want the outcome to look like.  I haven't lined up anything and I am going to change that ugly yellow frame and make it smaller.  But you'll get the point.

www.hairbydina.com/draft.htm
0
henrywwCommented:
that's nice ...
so in the wedding section u have those small thumbnails and u want user to click and load the big photo in the middle of the screen?

that's shouldn't be too hard, since u have all the thumbnails there already ...

how did u get them in the 1st place?

0
rascalpantsCommented:
H, the difference is the use of " instead of '  

you need to use ' to make it work properly...


rp
0
graymikeAuthor Commented:
Thanks,

What I did was just bring the full size picture into Flash.  Then just scale a copy of that picture down to the thumbnail size.

It's a nice feature for my client because after she does the brides hair she can take pictures of it and then say go to the website and go see your pictures. The rest of her family can look too.
0
henrywwCommented:
oh ... wow ... i didn't see that ...

but why? it doesn't make any difference ... " or ' ... :)

Response.Write "Name="&Recordst.Fields("Name")&"&imageName="&Recordst.Fields("imageName")&"&" is the correct syntax too ...

u can just do with just Recordst("filedname") ... my lazy way.


and next time dim the variable as rs ... why make the code so lengthy? rs("fieldname") ... :) LOL ...

cheers
0
rascalpantsCommented:
"Response.Write "Name="&Recordst.Fields("Name")&"&imageName="&Recordst.Fields("imageName")&"&" is the correct syntax too ... "


I don't think that is the correct syntax, because DMX is freaking out when I put that code in like that...

you have to keep the code that will print to the screen in between quotes and use '' to put the field names in...

I am not sure why that would work for you to use all quotes, because it doesn't work for me...


"and next time dim the variable as rs ... why make the code so lengthy? rs("fieldname") ... :) LOL ... "

I TOTALLY AGREE!  :)  

no need to type so much...

rp
0
henrywwCommented:
exactly ... rs = recordset ... easy shortcut ...

but then ... try paste the code with the " ... it will work :)

let's bet 50pts & a grade A over it how's that :) LOL ...
0
graymikeAuthor Commented:
I am going to give you half my points and Henry the rest if I am able to do that.  You both were great. I did not figure it out but I figure I will do each page manually.  I cannot say you didn't try.
0
VDCommented:
Hi,

I'm facing exactly the same problem as Mike was, with loading jpgs into Flash 5.

loadMovie("test.jpg","container");

Where the container is a flash graphic instance.

Another solution?  Generator allows you to include .jpg files, without importing them, however how do I dynamically alter the file name?
0
VDCommented:
Hi,

I'm facing exactly the same problem as Mike was, with loading jpgs into Flash 5.

loadMovie("test.jpg","container");

Where the container is a flash graphic instance.

Another solution?  Generator allows you to include .jpg files, without importing them, however how do I dynamically alter the file name?
0
rascalpantsCommented:
Thanks for the comment VD...  if you have a question, please post it in the Forum...


rp
0
VDCommented:
It's the G.D. refresh it repeated my question here.

I've posted the question in the forum, but Henry and yourself were whom I wanted to target.

I read another answer you gave PHP, FLASH and the giant MySQL.  I am from an VB/Oracle/SQL Server client - server environment, and it has been useful looking at all your comments, and the tutorials.

Anyway I've posted my question.  I'll see how I do.

Van
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.