# Loading external images

**URL:** <https://forum.kirupa.com/t/loading-external-images/30075>\
**Category:** Uncategorized\
**Created:** [September 3, 2003, 7:27pm UTC](https://forum.kirupa.com/t/loading-external-images/30075 "2003-09-03T19:27:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dmschenk](https://avatars.discourse-cdn.com/v4/letter/d/839c29/32.png) [@dmschenk](https://forum.kirupa.com/u/dmschenk)\
**Post date:** [September 3, 2003, 7:27pm UTC](https://forum.kirupa.com/t/loading-external-images/30075/1 "2003-09-03T19:27:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 3, 2003, 7:44pm UTC](https://forum.kirupa.com/t/loading-external-images/30075/2 "2003-09-03T19:44:35Z")

</div>

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](http://www.server.com/page.html%22,%22_blank)”);  
}[/AS]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 3, 2003, 7:48pm UTC](https://forum.kirupa.com/t/loading-external-images/30075/3 "2003-09-03T19:48:31Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 4, 2003, 11:06am UTC](https://forum.kirupa.com/t/loading-external-images/30075/4 "2003-09-04T11:06:20Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 4, 2003, 4:01pm UTC](https://forum.kirupa.com/t/loading-external-images/30075/5 "2003-09-04T16:01:18Z")

</div>

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]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 5, 2003, 5:11am UTC](https://forum.kirupa.com/t/loading-external-images/30075/6 "2003-09-05T05:11:51Z")

</div>

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
