How to Get the Base URL in Flash ActionScript 2 and ActionScript 3?

Step 1

Create a flash project and set the Publish Settings’ ActionScript version as 2.

Step 2

Create two dynamic texts, named as txtFullUrl and txtBaseUrl.

baseurl01

Step 3

Create another layer; in first frame of that layer write the following ActionScript code.

Action Script 2 Code

baseurl02

function GetTheBaseUrl() {
var RootFullUrl = _root._url;
txtFullUrl.text = RootFullUrl;
var lastSlashIndex:Number = RootFullUrl.lastIndexOf("/");
var DriveIndex:Number = RootFullUrl.indexOf("|");
 
if (DriveIndex>=0) {
baseUrl = RootFullUrl.substring(0, DriveIndex);
baseUrl += ":";
} else {
baseUrl = "";
}
baseUrl += RootFullUrl.substring(DriveIndex+1, lastSlashIndex+1);
txtBaseUrl.text = baseUrl;
return baseUrl;
}
 
var BaseURL:String= GetTheBaseUrl();

Action Script 3 Code

baseurl03

txtFullUrl.text = this.loaderInfo.url;
 
var FullUrl:String = this.root.loaderInfo.url;
var lastSlashIndex:Number = FullUrl.lastIndexOf("/");
var DriveSepIndex:Number = FullUrl.indexOf("|");
 
var baseUrl:String;
if (DriveSepIndex >= 0) {
baseUrl = FullUrl.substring(0, DriveSepIndex);
baseUrl += ":";
} else {
baseUrl = "";
}
baseUrl += FullUrl.substring(DriveSepIndex + 1, lastSlashIndex + 1);
txtBaseUrl.text = baseUrl;

Step 4

Press Ctrl + Enter to run the application.

How to Embed a Flash File into C# Window Form?

To embed a flash file in C# Windows .Net Application we can use Shockwave Flash Object ActiveX Control.

Follow the Steps to embed flash file:

Step 1: In Tool box right click and select the menu “Choose Items”.

Step 2: From Choose Toolbox Items window select “Com component” tab.

Step 3: Scroll down and make sure “Shockwave Flash Object” is ticked and click ok. The Shockwave Flash Object will now appear in the toolbox.

Step 4: Simply click and drag the Shockwave Flash Object to window Form.

Step 5: Add the Code “Form Load”.

axShockwaveFlash1.LoadMovie(0, Application.StartupPath + “flash.swf”);

These steps embed the flash file and loads “flash.swf” in the application path when window loads.

How to Text Over a SWF?

To text over a SWF,we should use the “wmode” in object embed tab as “opaque”.By doing this we get the html text overlapping the swf content in the page at same position.

Coding :

<object classid=”clsid:d27cdb6e-ae6d-11cf-96b8-444553540000″ codebase=”http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0″ width=”300″ height=”150″ id=”s” align=”middle”>
<param name=”allowScriptAccess” value=”sameDomain” />
<param name=”allowFullScreen” value=”false” />
<param name=”movie” value=”s.swf” />
<param name=”quality” value=”high” />
<param name=”bgcolor” value=”#370037″ />
<param name=”wmode” value=”opaque” />
<embed wmode=”opaque” src=”s.swf” quality=”high” bgcolor=”#370037″ width=”300″ height=”150″ name=”s” align=”middle” allowScriptAccess=”sameDomain” allowFullScreen=”false” type=”application/x-shockwave-flash” pluginspage=”http://www.macromedia.com/go/getflashplayer” />
</object>

Demo Link