Loading external images

I would like to load images into flash from and external folder AND be able to link them, much like a banner. where can I find out how to do this? I’m thinking it would be similar to how the News Flasher works

Thanks
Dave

On the main timeline …

[AS]
this.createEmptyMovieClip(“holder”,1)
holder._x = 50;
holder._y = 40;
holder.loadMovie(“image.jpg”);
holder.onRelease = function(){
getURL(“http://www.server.com/page.html","_blank”);
}[/AS]

First you need to create an empty movie clip symbol to load to (thanks to Flash MX we can do this via AS)

[AS]this.createEmptyMovieClip(“container”, 1)[/AS] This creates an empty movie clip with the instance name “container” (no quotes) on level 1.

Then you need to load in your image. You can only dynamically load non-progressive .jpg images any other file types can’t be dynamically loaded in unless they are put in an external .swf file and that file is loaded in. [AS]container.loadMovie(“yourBanner.jpg”);[/AS]

Now to make it linkable you would use what are known as dynamic event handlers (more info here http://www.kirupa.com/developer/actionscript/tricks/dynamicevent.htm ) [AS]container.onRelease = function(){
getURL(“url”, “_blank”);
}[/AS]

getURL is flashs way to change the browser location, the URL parameter is obviously the url you want to load in, and the _blank tells flash to open the url in a new browser window.

Thanks for the quick responses!
I need to expand my question a little… I have a site that I want to replace the existing rotating banner with flash. it consists of about 30 images that rotate every 5 or 8 seconds automatically. The current banner is located at:
http://www.bajamx.com/main.htm

eventually I would like to convert the whole site to flash but I don’t think I’m ready for that yet.

Thanks again
Dave

You can create an array to hold the names of the 30 images, then write a function that randomly chooses an image from the array, and then use setInterval() to call that function every 5 seconds.

For example (untested)…

[AS]//create array to store image names
var banners = [“image1.jpg”, “image2.jpg”, “image3.jpg”];
//create container clip to load images to
this.createEmptyMovieClip(“container”, 1);
//set _x position to 100
container._x = 100;
//set _y position to 100
container._y = 100;
//create function to randomly choose image from array
function chooseImage() {
container.loadMovie(banners[Math.floor(Math.random()*banners.length)]);
}
//use setInterval to call the chooseImage function every 5000 milliseconds (5 seconds)
rotateInterval = setInterval(chooseImage, 5000);[/AS]

Hey I’m learning alot about arrays and stuff, reading other people’s posts…they seem like a huge time saver. lostinbeta, could you explain the foor/math part of the code. I have no idea what that means or is used for. (I guess it’s something about the randomness).

Thanks a ton