# Loading with variable

**URL:** <https://forum.kirupa.com/t/loading-with-variable/288995>\
**Category:** Uncategorized\
**Created:** [May 24, 2009, 9:19pm UTC](https://forum.kirupa.com/t/loading-with-variable/288995 "2009-05-24T21:19:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![xelaxam](https://avatars.discourse-cdn.com/v4/letter/x/5e9695/32.png) [@xelaxam](https://forum.kirupa.com/u/xelaxam)\
**Post date:** [May 24, 2009, 9:19pm UTC](https://forum.kirupa.com/t/loading-with-variable/288995/1 "2009-05-24T21:19:24Z")

</div>

All rgiht,

here i’s a easy one ( for you not for me) . On the stage I have buttons that should load different swf. Usually I should put all the code on a single “action” layer. But, it is not what I want to do I have a movie clip that I want to play before the loading ( button click - movie clip - loading the swf).

So i put this code at the en of the movie clip:

```auto
var mLoader:Loader = new Loader();
var swf;
var mRequest:URLRequest = new URLRequest(swf);

function startLoad()
{

mLoader = new Loader();
mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
mLoader.load(mRequest);
}

function onCompleteHandler(loadEvent:Event)
{
        addChild(loadEvent.currentTarget.content);
}
function onProgressHandler(mProgress:ProgressEvent)
{
var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;
trace(percent);
}
startLoad();

```

and on the main stage I got

```auto
import flash.net.URLRequest;
import flash.display.Loader;
import flash.events.Event;
import flash.events.ProgressEvent;

var swf;

function printCLICK(event:MouseEvent):void {
	this.mask_vid.gotoAndPlay(2);
	swf = "print.swf";
	
	}

print_btn.addEventListener(MouseEvent.CLICK, printCLICK);

```

So I get Parameter url must be non-null. How can I fix this…

Thx
