I want to make a button that loads a random image in a new window. Is this possible?
In a new browser window ?
Yep
I think someone already aked this before. I don’t know who and where though. I’m gonna look into it.
- Maybe this can help you: http://www.kirupaforum.com/forums/showthread.php?s=&threadid=17767. It’s not the one I was looking for, though you might find it useful.
** Found this one: http://www.kirupaforum.com/forums/showthread.php?s=&threadid=23363 and http://www.kirupaforum.com/forums/showthread.php?s=&threadid=18323 this one.
^ Those should get you starting
I didn’t see Voetsjoeba’s edit and made one in Flash real quick…It’s the same thing in all the other posts just in Flash:
pics=["pic1","pic2","pic3","pic4","pic5"];
randpic = pics[random(pics.length)];
_root.container.loadMovie(randpic+".jpg");
Same thing…just too slow; but when I’m in office…look out!!
These are great, but what about getting them to load in a new window? ie. _blank
Freddy - He/She was talking about a browser window, not Flash
Voetsjoeba; I think he/she was talking a bout a flash button that would load jpgs in a new window =)
want to make a button that loads a random image in a new window. Is this possible?
use getUrl("_blank","image"+imagenumber+".jpg")
imagenumber correspond to pics like image1.jpg,image2.jpg etc…
Just place the code Kit posted (which I’ll post below for your convenience) in a new html page. The code will generate a random image in the html page. So just call the html from flash using [AS]getURL(“java**script:window.open(‘randomimage.html’,’’,‘height=300,width=400’);”);[/AS] if you want it to be a pop-up and all the images have the same size (300x400). Or simply use the basic [AS]getURL(“randomimage.html”,"_blank")[/AS]That will bring up a big window though.
Here’s Kit’s code:
<head>
<script language="JavaScript">
function random_imglink(){
var myimages=new Array()
myimages[1]="image1.gif"
myimages[2]="image2.gif"
myimages[3]="image3.gif"
myimages[4]="image4.gif"
myimages[5]="image5.gif"
myimages[6]="image6.gif"
var ry=Math.floor(Math.random()*myimages.length)
if (ry==0)
ry=1
document.write('<img src="'+myimages[ry]+'" border=0>')
}
random_imglink()
</script>
</head>
*Forgot the random_imglink() at the end, this is important so make sure you don’t have the old script from before this edit.
*Originally posted by mlkdesign *
**Voetsjoeba; I think he/she was talking a bout a flash button that would load jpgs in a new window =)
use getUrl("_blank","image"+imagenumber+".jpg")
imagenumber correspond to pics like image1.jpg,image2.jpg etc… **
I know. A browser window should open, it shouldn’t be loaded in the flash movie. The code Freddy posted would work fine to load them into Flash.
getUrl("_blank","image"+imagenumber+".jpg")
Correct me if I’m wrong, but that doesn’t seem right to me. I don’t know if you can even load images through getURL, but I don’t think so. Even if, it should be [AS]getURL(“image”+imagenumber+“.jpg”,“_blank”);[/AS]don’t you think ? (getURL info)
*** Make sure you see my edit in the previous post**
Can you load a URL into flash?
Freddy - He/She was talking about a browser window, not Flash
After a little reasearch, I was answering someone else’s question from another post (loading random images in my footer). Hmm, guess I was tired…
Voetsjoeba - not as clean by any means, but you can use getURL for other files like pics; I just tried it 'cause I wasn’t sure, but in my experience - it’s not good because it displays the pictures address in the title bar.
I’d go with what Voetsjoeba said a few posts ago - that’s gonna be your best way
Can you load a URL into flash?
You can’t load an HTML page into flash, but you can load in images, text, partially formatted HTML text.