# Load image with its own url

**URL:** <https://forum.kirupa.com/t/load-image-with-its-own-url/204999>\
**Category:** Uncategorized\
**Created:** [October 25, 2006, 9:36am UTC](https://forum.kirupa.com/t/load-image-with-its-own-url/204999 "2006-10-25T09:36:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![razor21](https://avatars.discourse-cdn.com/v4/letter/r/5e9695/32.png) [@razor21](https://forum.kirupa.com/u/razor21)\
**Post date:** [October 25, 2006, 9:36am UTC](https://forum.kirupa.com/t/load-image-with-its-own-url/204999/1 "2006-10-25T09:36:41Z")

</div>

Hi there,

i got a code for loading external images into a movieclip, works fine and all…

```auto
var orgImages:Array = ["./images/pic1.jpg","./images/pic2.jpg","./images/pic3.jpg", "./images/person1.jpg"];
var images:Array = orgImages.concat();

function pickOne(){
        var theOne:Number = makeRandom(0,images.length);
        var theImage:String = images[theOne];
        loadMovie(theImage, imageHolder.holder_mc);
        images.splice(theOne,1);
        if(images.length <= 0) images = orgImages.concat();
}

function makeRandom(min,max){
        return Math.floor(Math.random()*(max-min)+min)
}

pickOne();

```

but now i want to add links to the images so when u press on “imageHolder” that the image u see brings u to its own page. The idea is clear but how i have to do it, i have no idea ☹

eventually this has to happen: imageHolder.onRelease = function() { getURL(url);}

But how can i tell wich url belongs to a image?

Who knows an answer? TNX!

---

<div class="post-metadata">

**Author:** ![mathew\_er](https://avatars.discourse-cdn.com/v4/letter/m/94ad74/32.png) [@mathew\_er](https://forum.kirupa.com/u/mathew_er)\
**Post date:** [October 25, 2006, 10:15am UTC](https://forum.kirupa.com/t/load-image-with-its-own-url/204999/2 "2006-10-25T10:15:35Z")

</div>

```auto
var orgImages:Array = ["./images/pic1.jpg","./images/pic2.jpg","./images/pic3.jpg", "./images/person1.jpg"];
var orgUrls:Array = ["www.example.com","www.blah.com","www.foo.com", "www.bar.com"];
var images:Array = orgImages.concat();
var urls:Array = orgUrls.concat();

function pickOne(){
        var theOne:Number = makeRandom(0,images.length);
        var theImage:String = images[theOne];
        imageHolder.holder_mc.loadMovie(theImage);
        imageHolder.holder_mc.onLoad = function ()
        {
                this.onPress = function ()
                {
                        getURL ( urls[theOne] )
                };
        };
        images.splice(theOne,1);
        if(images.length <= 0) {
                images = orgImages.concat();
                urls = orgUrls.concat();
        }
}

function makeRandom(min,max){
        return Math.floor(Math.random()*(max-min)+min)
}

pickOne();

```

maybe

---

<div class="post-metadata">

**Author:** ![razor21](https://avatars.discourse-cdn.com/v4/letter/r/5e9695/32.png) [@razor21](https://forum.kirupa.com/u/razor21)\
**Post date:** [October 25, 2006, 10:40am UTC](https://forum.kirupa.com/t/load-image-with-its-own-url/204999/3 "2006-10-25T10:40:49Z")

</div>

hmmm it doesnt recognize the url…

when i press on the button (imageHolder), there’s changing nothing, any idea why?

---

<div class="post-metadata">

**Author:** ![mathew\_er](https://avatars.discourse-cdn.com/v4/letter/m/94ad74/32.png) [@mathew\_er](https://forum.kirupa.com/u/mathew_er)\
**Post date:** [October 25, 2006, 10:58am UTC](https://forum.kirupa.com/t/load-image-with-its-own-url/204999/4 "2006-10-25T10:58:51Z")

</div>

I tought it wont work…

try

```auto
function pickOne(){
        var theOne:Number = makeRandom(0,images.length);
        var theImage:String = images[theOne];
        imageHolder.targetURL = urls[theOne];
        imageHolder.holder_mc.loadMovie(theImage);
        imageHolder.holder_mc.onLoad = function ()
        {
                this.onPress = function ()
                {
                        getURL ( this._parent.targetURL )
                };
        };
        images.splice(theOne,1);
        urls.splice(theOne,1);
        if(images.length <= 0) {
                images = orgImages.concat();
                urls = orgUrls.concat();
        }
}

```

---

<div class="post-metadata">

**Author:** ![razor21](https://avatars.discourse-cdn.com/v4/letter/r/5e9695/32.png) [@razor21](https://forum.kirupa.com/u/razor21)\
**Post date:** [October 25, 2006, 11:16am UTC](https://forum.kirupa.com/t/load-image-with-its-own-url/204999/5 "2006-10-25T11:16:07Z")

</div>

well i tried that but that didnt work, but when i tried this:

```auto
imageHolder.onPress = function ()
                {
                        getURL ( this.targetURL )
                };

```

instead of:

```auto
imageHolder.holder_mc.onLoad = function ()
        {
                this.onPress = function ()
                {
                        getURL ( this._parent.targetURL )
                };
        };

```

it worked!!

so thank u very much for your help mathew.er!!
