How can I retrieve a swf's name?

Hello everybodys :slight_smile: !

This question is probably more theoretical than practical, though there may be uses for figuring out how to do this.

If I set up a small dynamic text box (var ‘disp’) on the main stage and then script on a movieclip: onClipEvent(enterFrame){_root.disp = this._name} I will get the name of the movieClip, correct?

I have been trying to get a swf to state what it’s name is, ie: if a swf called movie1.swf is playing, how can you extract that data? I tried scripting on a movieClip: onClipEvent(enterFrame){_root.disp = _root._name}, but nothing happened of course lol. Maybe it is not possible to do this.

Thanx in advance for any insights anyone might have on this :slight_smile:

_url

:wink:

onClipEvent(enterFrame){
    _root.disp = this._name
}

will return the instance name of MC, not the actual name. if you want to get the actual name you might have to use [COLOR=crimson]this._url[/COLOR] because that will get the full url of the movie, including movie.swf.

However you will also get the rest of the stuff like http://www.domain.com/… There is a way to remove all the rest of the crap if, you tell the variable to cut the string where the domain.com… is.

Like if your _url is [COLOR=crimson]http://www.domain.com/flash/movie1.swf[/COLOR] then you can go [COLOR=crimson]myVariable = _url.subString(27)[/COLOR] that will take what ever is 27 characters until the end of the string and store it in myVariable.

Thats the only way I can think to do it, With out writing a complex function.

_url.substr(_url.lastIndexOf("/")+1)
:slight_smile:

that’s pretty sweet, much better than mine, :stuck_out_tongue:

Thank you so much Senocular and Iamapathy.

I tried it out right away and it works perfectly - brilliant!

Much appreciated, bye for now :slight_smile: !