Flash video tutorials

Free Utilities

Events Scroller | Images Scroller | Multi FLV Player | Flash CS3 GuestBook | News Scroller | Tortillas - creator of simple graphs for statistical data | 3D images visualization free utility | Flash CS3 Uploader - free utility | Mini Gallery | Flash CS3 puzzle | Hit counter Flash CS3 + XML + PHP | Multi Audio Player | Newsletter module | Bluring Slide | Monthly Calendar | ShoutBox | StripGallery - Flash CS3 and XML gallery | Email Form PRO | MaskMenu | Elastic Gallery | PhotoNavigator | Pixellation - SlideShow | Email form | Analogue clock | FullScreen images gallery | Rotating header | Flash Portfolio | Polls System | Products Exhibitor | Mini Navigator | Drag Menu | Horizontal Menu | Quizzer | Mini Navigator 2 | Reflect Gallery | Events Scroller - version 2 | Rotating header 2 | Magnifying Glass | Zoomify | MenuVibration | Email form Flash CS3 and ColdFusion 8 | News Scroller 2 | Simple GuestBook | Captcha for Flash CS3 | Email form with pictures - Flash CS3 and PHP | FlepCharCode | Mac Menu | Header | Memory Game - Flash CS3 game | Flash CS3 CountDown | FLV Slide Show Videos | Illusion - images gallery | Tell A Friend | terms of use | Flash RSS reader | ToolTip Flash CS3 - CS4 | Sliding Email Form | ComboMenuHeader | ComboMenuHeader PRO | Mac Front Row in Flash CS3 | FlaTwit - Flash and Twitter - twit this | Store Locator | Multi Video Player MAC style | hittest and magnifying glass | Flash XML editor | BlurSlideShow | ImagesViewer | Video Gallery | Flash XML editor gallery 1 | 15 numbers game | Tipper vertical scroller with Iphone effect | YouTube Video Player by categories | GuestBook Flash CS4 | tweened menu | Twitter RSS reader | Xmas Flash header | Events Scroller - version 3 | TripleBox | BlackComboBox | Inertial Photo Portfolio | Fullscreen Background | Multi Categories Images Gallery |

Getting the page url where my SWF is located

by admin on November 6, 2008 · 6 comments

in Flash CS3, Sintax, Tutorials

Sometime we need to get the url of the web page where our SWF is located.
Actionscript 3.0 gives us a way to do it just using 1 line code.
Just use ExternalInterface class that runs a Javascript command and gets the page’s url.

Here is the code:

1
2
var pageURL:String=ExternalInterface.call('window.location.href.toString');
trace(pageURL);

DEMO

In that case I called the property href of Javascript Location class using Actionscript.
Javascript Location class has its properties so I used hostname, pathname and protocol too.

Also I got data of the user’s browser using the Navigator class of Javascript with its properties userAgent and platform.
hurray
All this with Actionscript 3 !

1
2
3
4
5
6
7
8
9
10
11
12
var pageURL:String=ExternalInterface.call('window.location.href.toString');
var pageHost:String=ExternalInterface.call('window.location.hostname.toString');
var pagePath:String=ExternalInterface.call('window.location.pathname.toString');
var pageProtocol:String=ExternalInterface.call('window.location.protocol.toString');
var userAgent:String=ExternalInterface.call('window.navigator.userAgent.toString');
var platform:String=ExternalInterface.call('window.navigator.platform.toString');
 
url_txt.text=pageURL;
hostname_txt.text=pageHost;
path_txt.text=pagePath;
protocol_txt.text=pageProtocol;
browser_txt.text=userAgent+"\n"+platform;

Share This Post

Related posts

{ 6 comments… read them below or add one }

1

wtfpixel 12.16.08 at 12:40 am

does not work. returns Parameter text must be non-null error.

2

admin 12.16.08 at 5:46 am

Works to me…
Are you trying it online ?

3

vicky 12.30.08 at 11:54 am

aaaaaaaaaaaaaaaaaaaaaaaaaaa

4

henry 10.10.09 at 10:33 am

not working…

5

admin 10.10.09 at 11:28 am

Works to me

6

Jocce 12.02.09 at 9:16 am

Nice stuff
I’m trying to get the description from a page into my flash, iv tried this as3 code, but cant get it to work.

var pageDESCRIPTION:String;

var metas:Array = new Array(ExternalInterface.call('document.getElementsByTagName("meta")'));
for (var x:int=0; x<metas.length; x++) {
if (metas[x].name.toLowerCase() == "description") {
pageDESCRIPTION = metas[x];
}
}
trace(description.content);

Any ideas?

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Older post:

Newer post: