# Can you pass args with events easily?

**URL:** <https://forum.kirupa.com/t/can-you-pass-args-with-events-easily/318767>\
**Category:** flash\
**Created:** [January 29, 2011, 10:04pm UTC](https://forum.kirupa.com/t/can-you-pass-args-with-events-easily/318767 "2011-01-29T22:04:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![megshea](https://avatars.discourse-cdn.com/v4/letter/m/e36b37/32.png) [@megshea](https://forum.kirupa.com/u/megshea)\
**Post date:** [January 29, 2011, 10:04pm UTC](https://forum.kirupa.com/t/can-you-pass-args-with-events-easily/318767/1 "2011-01-29T22:04:36Z")

</div>

Hi, I would liek to use this code to load and display images within 4 movie clips. But it looks like this fires off an event for “imageLoaded” which means I can’t specify which movieclip to use (in an arg).

Is there an easy way to make this code reusable for all 4 images?

```auto

//Define a loader
var imageLoader:Loader;
 
function loadThisImage(url:String):void {
    //Show Preloader
    preloader.visible=true;
    imageLoader=new Loader();
    imageLoader.load(new URLRequest(url));
    //Add a listener to update the preloader on the image's progress
    imageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,imageLoading);
    //Adding a listener that will update the preloader once the image has been loaded
    imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,imageLoaded);
}
 
 
 var thisImage:String;
 
function imageLoaded(evt:Event):void {
    // Load Image by adding it to the display list
    ImageLoaderClip.addChild(imageLoader);

    // Hide Preloader
    preloader.visible=false;
}
 
function imageLoading(evt:ProgressEvent):void {
    // Get the current download progress
    var loaded:Number=evt.bytesLoaded/evt.bytesTotal;
    // Send progress info to "preloader" movie clip
    updateProgress(loaded);
}
 
function updateProgress(value:Number) {
    preloader.progress.width=value*preloader.bar.width;
}
 
//Loading the image defined in the parameter
loadThisImage("myPic1.png");

```
