# Making filename a variable

**URL:** <https://forum.kirupa.com/t/making-filename-a-variable/186494>\
**Category:** Uncategorized\
**Created:** [April 21, 2006, 5:48pm UTC](https://forum.kirupa.com/t/making-filename-a-variable/186494 "2006-04-21T17:48:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![redrum00](https://avatars.discourse-cdn.com/v4/letter/r/e480ec/32.png) [@redrum00](https://forum.kirupa.com/u/redrum00)\
**Post date:** [April 21, 2006, 5:48pm UTC](https://forum.kirupa.com/t/making-filename-a-variable/186494/1 "2006-04-21T17:48:29Z")

</div>

Hi all,

Does anyone one know if it’s possible to have AS take the filename of itself and make it a variable. I need it to be done by AS only. I know it’s possible in PHP, but I’m not sure about AS.

I’m guessing if it’s possible it’s one line of code.

I’m using Flash 8 but publishing at Flash 6, AS 2.

Thanks in advance,  
Bret

---

<div class="post-metadata">

**Author:** ![redrum00](https://avatars.discourse-cdn.com/v4/letter/r/e480ec/32.png) [@redrum00](https://forum.kirupa.com/u/redrum00)\
**Post date:** [April 21, 2006, 9:03pm UTC](https://forum.kirupa.com/t/making-filename-a-variable/186494/2 "2006-04-21T21:03:19Z")

</div>

maybe I’m explaning this poorly… here’s some code that outlines what I’m trying to do.

* * *

var filename = [here is where I need help];  
trace (filename);

* * *

i have a file with this code in it, the filename is ‘test.swf’. when i test this movie i want it to output ‘test.swf’ in the output window.

basic operation, but i don’t know how to pull it off.

anyone?

---

<div class="post-metadata">

**Author:** ![redrum00](https://avatars.discourse-cdn.com/v4/letter/r/e480ec/32.png) [@redrum00](https://forum.kirupa.com/u/redrum00)\
**Post date:** [April 21, 2006, 10:44pm UTC](https://forum.kirupa.com/t/making-filename-a-variable/186494/3 "2006-04-21T22:44:34Z")

</div>

I’ve found a way. If anyone is interested…

function getFileName(fileUrl) {  
var fileName = fileUrl.substr(fileUrl.lastIndexOf("/") + 1,  
fileUrl.length);  
return unescape(fileName);  
}

trace (this.getFileName(this.\_url));
