Si quisiéramos obtener el nombre del directorio sería tan sencillo como poner esto en nuestro archivo flash:
1 |
var dir:String = String(ExternalInterface.call("function getD(){return (location.href)}")).split("/").pop().split(".").shift(); |
Por lo que si nuestro archivo flash se estuviera reproduciendo desde http://www.tudominio.com/contacto entonces la variable dir contendría el valor «contacto».
Cogiendo ese ejemplo podemos hacer una función algo mas reutilizable así que os dejo otros ejemplos más y el ejemplo descargable.
This movie requires Flash Player 9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
function getData(js_objectProperty:String):String { var Data:String; if (ExternalInterface.available) { Data = String(ExternalInterface.call("function getD(){return ("+js_objectProperty+")}")); if (Data.length == 0) { Data = "Propiedad no disponible."; } } else { Data = "ExternalInterface no disponible en esta version de navegador."; } return Data; } hash.text = getData("location.hash"); host.text = getData("location.host"); hostname.text = getData("location.hostname"); href.text = getData("location.href"); pathname.text = getData("location.pathname"); port.text = getData("location.port"); protocol.text = getData("location.protocol"); referer.text = getData("location.referer"); //Ejemplo www.tudominio.com/contacto Resultado-> contacto hrefSplit.text = getData("location.href").split("/").pop().split(".").shift(); userAgent.text = getData("navigator.userAgent"); plataform.text = getData("navigator.plataform"); |
Download Source:
[download id=»43″ format=»2″]