# Trying to make dynamic images activate javascript on click

**URL:** https://forum.kirupa.com/t/trying-to-make-dynamic-images-activate-javascript-on-click/246178
**Category:** Uncategorized
**Created:** [December 7, 2007, 7:18pm UTC](https://forum.kirupa.com/t/trying-to-make-dynamic-images-activate-javascript-on-click/246178 "2007-12-07T19:18:00Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![coldrobot](https://avatars.discourse-cdn.com/v4/letter/c/f475e1/32.png) [@coldrobot](https://forum.kirupa.com/u/coldrobot)
#### Post date: [December 7, 2007, 7:18pm UTC](https://forum.kirupa.com/t/trying-to-make-dynamic-images-activate-javascript-on-click/246178/1 "2007-12-07T19:18:00Z")

</div>

Hello everyone-- This place looks like a great resource so I figured I’d sign up and ask. I am modifying an existing Actionscript that creates a basic scrolling thumbnail gallery. The image names and info load dynamically from a PHP doc. So far, the images load fine, the scrolling is tolerable etc… BUT, I am trying to make the thumbnails react to a click and call a javascript function (or do ANYTHING based on the click for that matter…). Any help would be greatly appreciated. I took out some irrelevant code for clarity…

```auto

import mx.transitions.Tween;
import mx.transitions.easing.*;
import mx.utils.Delegate; // used to keep button function scope = main timeline

var lv:LoadVars = new LoadVars();
var pics:Array = [];
var heights:Array = [];
var widths:Array = [];
var mcl:MovieClipLoader;
var ipic:Number; // index into pics, used during loading
var ifarleft:Number; // index of picture currently displayed at far left

function fillPicsArray(ok) {
   if (ok) {
      var i=0;
      do {
         pics.push(this["f"+i]);
		 heights.push(this["h"+i]);
		 widths.push(this["w"+i]);
      } while (this["f"+(++i)] != undefined);
      loadPic(); // when all read, start first pic loading
   } 
}

function onLoadInit(pic:MovieClip) {
   pic._width = 100;	// width of the viewable image
   pic._height = 80; // height of the viewable image
   pic._x = 8 + 110*ipic;	// how far to move over? starting x location per photo?
   pic._y = 10; // starting y location
   pic._alpha = 100; // transparency
   if (++ipic < pics.length) loadPic(); // load each photo
}
		
function loadPic() {
   holder.createEmptyMovieClip("p"+ipic, ipic);
   holder["p"+ipic]._alpha = 0;
   mcl.loadClip("ximages/s/" + pics[ipic], holder["p"+ipic]);
   
   /* THIS IS WHERE I'M MESSING UP...
   holder["p"+ipic].onRelease = function(){
	getURL("http://www.google.com");
   }
  */
   
}
	

function init() {
   lv.onLoad = fillPicsArray;
   lv.load("readfromdir.php?id=34");
   mcl = new MovieClipLoader();
   mcl.addListener(this);
   ipic = 0;
   this.createEmptyMovieClip("holder", 1); // holds all loaded pics

}

init();

```

Thanks a ton!  
Dave
