Load image with its own url

Hi there,

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

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 :frowning:

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!

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

hmmm it doesnt recognize the url…

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

I tought it wont work…

try

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();
        }
}

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

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

instead of:

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

it worked!!

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