View Full Version : changing images using img.src
jonbid
07-14-2003, 02:21 PM
hi, new here, not so new to flash but i thought u guys/gals could help me out... i hope. Anyways can this be done...
I have a button, called "1button"
I have this actionscript for the button:-
"on (release) {
getURL("javascript:photo.src='1.jpg';");
}"
Right, now, in my HTML file, i have this code:-
<img name="photo" src="dummyphoto.jpg">
For some reason, when i test my swf file out in the *.html file, i just get a white page with "1.jpg" written on it.
The idea for this whole thing is for the button in flash to change the photo in the html page. I dont want to put the images in the swf file because it is not as easy to change in the future. Essentially, this is a photo gallery page.
Incase you didn't notice I am not the best at explaining myself.
hope someone can grasp my idea, and tell me if it is possible and where about i am going wrong.
thanks a lot
freddycodes
07-14-2003, 02:33 PM
the src attribute for an image needs to be a javascript image object. You would be better off calling a javascript function from flash.
The javascript
changeImage(imgName, imgSrc) {
eval(imgName) = new Image();
eval(imgName+".src") = imgSrc;
photo.src = eval(imgName);
}
on (release) {
getURL("javascript:changeImage('img1', '1.jpg');");
}
That should work, although untested, you may need to adjust a few things.
jonbid
07-16-2003, 08:44 PM
:confused: I keep getting script errors in Explorer :confused:
I understand the theory behind the script, but I have very very basic.... or little knowledge of javascript, so I am unable to find out what is wrong with it.
I get an error of " expected ';' "
:mad:
Please help... would it be easier if i uploaded the site so you can have a look?
freddycodes
07-16-2003, 09:03 PM
Are you using Flash MX? If so, you may want to look at dynamically loading the images into Flash, that way you could easily update the gallery without having to open the fla.
jonbid
07-16-2003, 09:08 PM
i was thinking of that, but apparently, using the method you suggested, the jpegs will not load, erm (forgot exact word) erm progressively... i think is the word, loads from top to bottom.
See the real problem i have is that people think it isnt working when nothing happens... at least people may see something is happening.
Also, i would like to re-use the *.swf file in other galleries... i would also be intruiges to see how it is done, if indeed it can be done!
jonbid
07-16-2003, 09:09 PM
sorry, yes I am using Flash MX
on second thoughts... if i could preload the images with a loading bar, then this would solve the problems.
hang on i will try to upload the page as it could be developed into a nice little feature of this site. :p So how would i go about dynamically uploading the photos into a MC? (all the photos would be the same size) and i am thinking maybe there is already a tutorial for this somewhere?
thanks for the help
freddycodes
07-16-2003, 09:21 PM
That is indeed the case, jpegs of type progressive or in other words with a mime type of image/pjpeg, for non-designer types like myself cannot be dynamically loaded into flash.
jonbid
07-16-2003, 09:32 PM
would i use the loadMovie function? even though it is not a movie i want to load? sorry for all the newbie questions. :rolleyes:
freddycodes
07-16-2003, 09:36 PM
Yep, there are a ton of threads on loading jps, try searching the forusm for "loading jpg"
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.