Adobe Flash CS5.5 and AS3 – How to pass a variable from one flash application to another

Let’s say that I initially passed a parameter called ‘Testee’ to my preloader flash application via the HTML param tag. Now I need to pass this same parameter value from the preloader to the main flash application. Here is the code that receives the parameter from the the HTML:

var paramUserName:String;
var flashVars:Object = LoaderInfo(this.root.loaderInfo).parameters;
paramUserName = flashVars.Testee;

From flashVars, I get the Testee parameter and assign it to a variable called paramUserName.

In the preloader, after the loader has finished loading the main flash application, the event.complete calls my ‘done’ function:

_URLLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, done);

In my ‘done’ function, after I add the _URLLoader, I call the dispatch event:

function done(e:Event):void
{
removeChild(percent);
removeChild(_bar_border);
removeChild (_bar_guts);
percent = null;
_bar_border = null;
_bar_guts = null;

addChild(_URLLoader);
e.target.content.dispatchEvent (new Event("change"));
}

In my main flash application, I add a listener for the dispatched event called as shown above, ‘change’:

addEventListener(Event.CHANGE, SetUserName);

I then receive the value of my passed parameter in my SetUserName function:

function SetUserName(event:Event)
{
var mTestee:String = event.target.parent.parent.paramUserName;
}

Again, the ‘paramUserName’ is the variable in my preloader flash application that was assigned the ‘Testee’ parameter from the HTML that called the preloader flash application.

ASP.Net – How to pass the user.identity.name from your ASP.Net application as a parameter via the client side of your aspx page to a flash program

Say you want to restrict access to your flash application that is called by your aspx page. That is easy enough by adding the aspx page to your your web.config file’s location/authorization section. But what if you want to pass the user that is logged on to your ASP.Net application via the authentication process?

Here is how to pass a parameter called UserName to your flash application using the param name tag in your html of your aspx page.

<param name="FlashVars" value="UserName=&lt;% Response.Write(UCASE(User.Identity.Name)) %>" />

User.Identity.Name contains the user logged into your ASP.Net application. Response.Write is the method to use to place the user into the value property of your parameter.

You can then use the following logic in your flash application to read in the UserName parameter:

var paramUserName:String;
var flashVars:Object = LoaderInfo(this.root.loaderInfo).parameters;
paramUserName = flashVars.UserName;

Flash CS5.5 and AS3 – Flash (AS3) / ASHX (ASP.Net) / SQL Server – Post

This article explains in the most simpliest terms how to use action script to connect to SQL Server via an ashx file in order to post data from your flash application.

First, you build a flash game that keeps track of the gamer’s score. At the end of the game, you want to save the gamer’s score to your database.

To save the score, you need to add code to your action script to call an ashx file on your server.

First, define a URLVariables variable. Appended to this variable are the game statistics that you want to pass to your ashx file. (PlayerName, PlayerLevel, PlayerScore)

Second, you define a URLLoader variable.

Next, define a URLRequest variable that contains the url location of your ashx file. You then assign the POST method to your URLRequest variable and assign your defined variables to it’s data method.

Lastly, you assign the TEXT data format to your URLLoader, then execute the load method of the URLLoader passing as a parameter the URLRequest variable.

Below is the code:

var variables:URLVariables = new URLVariables;
variables.PlayerName = txtPlayerName.text;
variables.PlayerLevel = txtPlayerLevel.text;
variables.PlayerScore = txtPlayerScore.text;

var varLoaderPost:URLLoader = new URLLoader;

var varSend:URLRequest = new URLRequest("http://www.somewebsite.com/flash/somefile_POST.ashx");
varSend.method = URLRequestMethod.POST;
varSend.data = variables;

varLoaderPost.dataFormat = URLLoaderDataFormat.TEXT;
varLoaderPost.load(varSend);

Now that the action script code is explained, let’s talk about the ashx file that gets called by your flash application.

First, you receive the player name, level, and score posted to the ashx and assign them to variables.

Second, you establish your timezone of choice and get the current date.

Third, you open up your database connection.

Next, you build the insert sql statement.

Lastly, you execute the sql statement. The player’s data is now stored in the database.

The ashx finishes off by closing your database connection.

Below is the code:

somefile_POST.ashx

<%@ WebHandler Language="VB" Class="somefile_POST" %>

Imports System.Data.SqlClient
Imports System.Data
Imports System.Text

Public Class somefile_POST : Implements IHttpHandler
    Protected mLogger As NLog.Logger = NLog.LogManager.GetCurrentClassLogger

    Protected mDatabaseServer As String = String.Empty
    Protected mDataBase As String = String.Empty
    Protected mDatabaseUserID As String = String.Empty
    Protected mDatabasePassword As String = String.Empty
    Protected mSQLConnection As New SqlConnections
    Protected mSQLCommand As New SqlCommand

    Protected PlayerName As String = String.Empty
    Protected PlayerScore As String = String.Empty
    Protected PlayerLevel As String = String.Empty
   
    Protected _CurrentDateTime As DateTime = Nothing
    
    Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
        Try
            PlayerName = Trim(context.Request.Form("PlayerName"))
            PlayerScore = Trim(context.Request.Form("PlayerScore"))
            PlayerLevel = Trim(context.Request.Form("PlayerLevel"))

            Dim timeZoneInfo__1 As TimeZoneInfo
            'Set the time zone information to US Mountain Standard Time 
            timeZoneInfo__1 = TimeZoneInfo.FindSystemTimeZoneById("US Eastern Standard Time")
            'Get date and time in US Eastern Standard Time 
            _CurrentDateTime = TimeZoneInfo.ConvertTime(DateTime.Now, timeZoneInfo__1)
            'Print out the date and time

            OpenDatabaseConnection()

            ToDataBase()

            CloseDatabaseConnection()

        Catch ex As Exception
            mLogger.Error(ex.Message)
        End Try
    End Sub
    
    Protected Sub OpenDatabaseConnection()
        Try
            mDatabaseServer = "your.database.server"
            mDataBase = "yourdatabasename"
            mDatabaseUserID = "userid"
            mDatabasePassword = "password"

            mSQLConnection.ConnectionString = "Data Source=" & mDatabaseServer & ";Initial Catalog=" & mDataBase & ";Persist Security Info=True;User ID=" & mDatabaseUserID & ";Password=" & mDatabasePassword
            mSQLConnection.Open()
            mSQLCommand.Connection = mSQLConnection

        Catch ex As Exception
            mLogger.Error(ex)
        End Try
    End Sub

    Protected Sub CloseDatabaseConnection()
        Try
            mSQLConnection.Close()
        Catch ex As Exception
            mLogger.Error(ex)
        End Try
    End Sub

    Protected Sub ToDataBase()
        Dim mString As New StringBuilder
        Try
            Dim mReplaceString As String = String.Empty

            mString.Append("INSERT INTO flash_game_table")
            mString.Append("(DatePlayed, PlayerName, PlayerLevel, PlayerScore) ")
            mString.Append("VALUES (")

            mString.Append("'")
            mString.Append(_CurrentDateTime)
            mString.Append("'")
            mString.Append(", ")

            mString.Append("'")
            mString.Append(PlayerName)
            mString.Append("'")
            mString.Append(", ")

            mString.Append("'")
            mString.Append(PlayerLevel)
            mString.Append("'")
            mString.Append(", ")

            mString.Append("'")
            mString.Append(PlayerScore)
            mString.Append("'")

            mString.Append(")")

            mSQLCommand.CommandText = mString.ToString
            mSQLCommand.ExecuteNonQuery()

        Catch ex As Exception
            mLogger.Error(ex)
            mLogger.Error("SQL Statement: " & mString.ToString)
        End Try
    End Sub
 
    Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
        Get
            Return False
        End Get
    End Property

End Class

Flash CS5.5 and AS3 – Flash (AS3) / ASHX (ASP.Net) / SQL Server – Get

This article explains in the most simpliest terms how to use action script to connect to SQL Server via an ashx (ASP.Net) file in order to extract data for display in your flash application.

First, you build a flash game that keeps track and stores the gamer’s score. Before we even discuss that (in another article: http://www.jamesandchey.net/?p=543),
we want to retrieve the top score from the database saved from a previous game and display it to the current gamer.

To retreive the top score, you need to add code to your action script to call an ashx file on your server.

First, define a URLLoader variable.

Next, define a URLRequest variable that contains the url location of your ashx file. Also, assign the GET method to your URLRequest variable.

You then need to define an event listener to your URLLoader so it can fire a function (that you define) once the data is returned to your flash application via the ashx file.
The function you define will take the data (built in XML format by the ashx file) and load it into textbox variables for display.

Lastly, execute the load method of the URLLoader passing as a parameter the URLRequest variable.

Below is the code:

var varLoaderGet:URLLoader = new URLLoader;
var varGet:URLRequest = new URLRequest("http://www.somewebsite.com/flash/somefile_GET.ashx");
varGet.method = URLRequestMethod.GET;

varLoaderGet.addEventListener(Event.COMPLETE, loaderGetCompleteHandler, false, 0, true);
varLoaderGet.load(varGet);

function loaderGetCompleteHandler(e:Event):void
{
	var dataXML:XML = XML(e.target.data);
	_SQLDatePlayed.text = (dataXML.item[0]);
	_SQLName.text = (dataXML.item[1]);
	_SQLLevel.text = (dataXML.item[2]);
	_SQLScore.text = (dataXML.item[3]);
}

Now that the action script code is explained, let’s talk about the ashx file that gets called by your flash application.

The first part of your ashx file connects to SQL Server and establishes a connection to your database.

Next, you build your query statement to retrieve the data.

Lastly, you execute the query and store the results in your DataTable.

Now that you have the data, you build the xml file using XmlTextWriter.

The ashx finishes off by writing out the XML to be retrieved by your flash application.

Below is the code:

somefile_GET.ashx

<%@ WebHandler Language="VB" Class="somefile_GET" %>

Imports System
Imports System.Web
Imports System.Data.SqlClient
Imports System.Data
Imports System.Text
Imports System.Xml
Imports System.IO

Public Class somefile_GET : Implements IHttpHandler
    Protected mSQLDataReader As SqlDataReader
    Protected somefileSchemaTable As DataTable
    Protected somefileDataTable As DataTable

    Protected mDatabaseServer As String = String.Empty
    Protected mDataBase As String = String.Empty
    Protected mDatabaseUserID As String = String.Empty
    Protected mDatabasePassword As String = String.Empty
    Protected mSQLConnection As New SqlConnection
    Protected mSQLCommand As New SqlCommand
          
    Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest

        OpenDatabaseConnection()
        
        Dim mString As New StringBuilder

        mString.Append("SELECT top 1 * FROM flash_game_table order by PlayerScore desc, DatePlayed desc")

        mSQLCommand.CommandText = mString.ToString
        mSQLDataReader = mSQLCommand.ExecuteReader()

        If mSQLDataReader.HasRows = True Then
            DataReaderToDataTable()
        End If

        mSQLDataReader.Close()
        
        CloseDatabaseConnection()
        
        Dim somefile As New System.IO.MemoryStream
        Dim writer As New XmlTextWriter(somefile, System.Text.Encoding.UTF8)
        writer.WriteStartDocument(True)
        writer.Formatting = Formatting.Indented
        writer.Indentation = 2
        writer.WriteStartElement("flash_game")
        
        For Each pRow As DataRow In somefileDataTable.Rows
            Dim mDatePlayed As String = String.Empty
            Dim mPlayerName As String = String.Empty
            Dim mPlayerLevel As String = String.Empty
            Dim mPlayerScore As String = String.Empty
            For Each pColumn As DataColumn In somefileDataTable.Columns
                Select Case pColumn.Caption
                    Case "DatePlayed"
                        mDatePlayed = pRow(pColumn)
                    Case "PlayerName"
                        mPlayerName = pRow(pColumn).ToString
                    Case "PlayerLevel"
                        mPlayerLevel = pRow(pColumn).ToString
                    Case "PlayerScore"
                        mPlayerScore = pRow(pColumn).ToString
                End Select
            Next
			
            writer.WriteStartElement("item")
            writer.WriteString(mDatePlayed)
            writer.WriteEndElement()
			
            writer.WriteStartElement("item")
            writer.WriteString(mPlayerName)
            writer.WriteEndElement()
			
            writer.WriteStartElement("item")
            writer.WriteString(mPlayerLevel)
            writer.WriteEndElement()
			
            writer.WriteStartElement("item")
            writer.WriteString(mPlayerScore)
            writer.WriteEndElement()
        Next
                
        writer.WriteEndElement()
        writer.WriteEndDocument()
        writer.Flush()
        
        'This is so I can see the xml that I am actually building. 'writer' is what I will be sending to my flash program.
        Dim _somefileXML As String = Encoding.UTF8.GetString(somefile.GetBuffer(), 0, CInt(somefile.Length))
      
        context.Response.ClearContent()
        context.Response.Clear()

        context.Response.ContentType = "text/xml"
        context.Response.OutputStream.Write(somefile.ToArray(), 0, somefile.Length)
        context.Response.Flush()
        writer.Close()
    End Sub
 
    Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
        Get
            Return False
        End Get
    End Property
    
    Protected Sub OpenDatabaseConnection()
        Try
            mDatabaseServer = "your.database.server"
            mDataBase = "yourdatabasename"
            mDatabaseUserID = "userid"
            mDatabasePassword = "passwrod"

            mSQLConnection.ConnectionString = "Data Source=" & mDatabaseServer & ";Initial Catalog=" & mDataBase & ";Persist Security Info=True;User ID=" & mDatabaseUserID & ";Password=" & mDatabasePassword
            mSQLConnection.Open()
            mSQLCommand.Connection = mSQLConnection

        Catch ex As Exception

        End Try
    End Sub
    
    Protected Sub CloseDatabaseConnection()
        Try
            mSQLConnection.Close()
        Catch ex As Exception

        End Try
    End Sub
    
    Protected Sub DataReaderToDataTable()
        'This function receives a Data Reader and returns a Data Table
        Try
            'Table Schema
            somefileSchemaTable = mSQLDataReader.GetSchemaTable()
            'Data Table
            somefileDataTable = New DataTable
            Dim intCounter As Integer
            'Now to create the Schema on the DataTable
            For intCounter = 0 To somefileSchemaTable.Rows.Count - 1
                'Current Row
                Dim dataRow As DataRow = somefileSchemaTable.Rows(intCounter)
                'Current Column Name
                Dim columnName As String = CType(dataRow("ColumnName"), String)
                'Current Column
                Dim column As New DataColumn(columnName, CType(dataRow("DataType"), Type))
                'Add Column to the DataTable
                somefileDataTable.Columns.Add(column)
            Next intCounter
            'Now to fill the table with the reader
            While mSQLDataReader.Read()
                'New Row
                Dim dataRow As DataRow = somefileDataTable.NewRow()
                'Loop the fields
                For intCounter = 0 To mSQLDataReader.FieldCount - 1
                    'Insert the current value of the DataReader to the DataRow
                    dataRow(intCounter) = mSQLDataReader.GetValue(intCounter)
                Next
                'Insert the Row into the DataTable
                somefileDataTable.Rows.Add(dataRow)
            End While
        Catch ex As Exception

        End Try
    End Sub
End Class

Flash CS5.5 and AS3 – Flash (AS3) / PHP / MySQL – Post

This article explains in the most simpliest terms how to use action script to connect to MySQL via a php file in order to post data from your flash application.

First, you build a flash game that keeps track of the gamer’s score. At the end of the game, you want to save the gamer’s score to your database.

To save the score, you need to add code to your action script to call a php file on your server.

First, define a URLVariables variable. Appended to this variable are the game statistics that you want to pass to your php file. (PlayerName, PlayerScore)

Second, you define a URLLoader variable.

Next, define a URLRequest variable that contains the url location of your php file. You then assign the POST method to your URLRequest variable and assign your defined variables to it’s data method.

Lastly, you assign the TEXT data format to your URLLoader, then execute the load method of the URLLoader passing as a parameter the URLRequest variable.

Below is the code:

var variables:URLVariables = new URLVariables;
variables.PlayerName = txtPlayerName.text;
variables.PlayerScore = txtPlayerScore.text;

var varLoaderPost:URLLoader = new URLLoader;

var varSend:URLRequest = new URLRequest("http://www.somewebsite.com/flash/somefile_POST.php");
varSend.method = URLRequestMethod.POST;
varSend.data = variables;

varLoaderPost.dataFormat = URLLoaderDataFormat.TEXT;
varLoaderPost.load(varSend);

Now that the action script code is explained, let’s talk about the php file that gets called by your flash application.

The first part of your php file connects to MySQL and establishes the database name.

Second, you receive the player name and player score posted to the php and assign them to php variables.

Third, you get the current date. (The time zone is set at the beginning of the php file to whatever time zone you prefer)

Next, you build the insert sql statement.

Lastly, you execute the sql statement. The player’s data is now stored in the database.

The php finishes off by closing your database connection.

Below is the code:

somefile_POST.php

<?PHP
date_default_timezone_set('EST');

$link = mysql_connect("localhost", "username", "password");
mysql_select_db("flash_database") or die ("no database");

$PlayerName = $_POST['PlayerName'];
$PlayerScore = $_POST['PlayerScore'];

// Get the current date
$current_date = date('Y-m-d H:i:s');

$sqlCommand = "INSERT INTO flash_game_table (date_played, name, score)
               VALUES('$current_date ', '$PlayerName', '$PlayerScore')";

$results = mysql_query($sqlCommand) or die (mysql_error());

mysql_close($link);

?>

Flash CS5.5 and AS3 – Flash (AS3) / PHP / MySQL – Get

This article explains in the most simpliest terms how to use action script to connect to MySQL via a php file in order to extract data for display in your flash application.

First, you build a flash game that keeps track and stores the gamer’s score. Before we even discuss that (in another article: http://www.jamesandchey.net/?p=530),
we want to retrieve the top score from the database saved from a previous game and display it to the current gamer.

To retreive the top score, you need to add code to your action script to call a php file on your server.

First, define a URLLoader variable.

Next, define a URLRequest variable that contains the url location of your php file. Also, assign the GET method to your URLRequest variable.

You then need to define an event listener to your URLLoader so it can fire a function (that your define) once the data is returned to your flash application via the php file.
The function you define will take the data (built in XML format by the php file) and load it into textbox variables for display.

Lastly, execute the load method of the URLLoader passing as a parameter the URLRequest variable.

Below is the code:

var varLoaderGet:URLLoader = new URLLoader;
var varGet:URLRequest = new URLRequest("http://www.somewebsite.com/flash/somefile_GET.php");
varGet.method = URLRequestMethod.GET;

varLoaderGet.addEventListener(Event.COMPLETE, loaderGetCompleteHandler, false, 0, true);
varLoaderGet.load(varGet);

function loaderGetCompleteHandler(e:Event):void
{
	var dataXML:XML = XML(e.target.data);
	_SQLDatePlayed.text = (dataXML.item[0]);
	_SQLName.text = (dataXML.item[1]);
	_SQLLevel.text = (dataXML.item[2]);
	_SQLScore.text = (dataXML.item[3]);
}

Now that the action script code is explained, let’s talk about the php file that gets called by your flash application.

The first part of your php file connects to MySQL and establishes the database name.

Next, you build your query statement to retrieve the data.

Lastly, you execute the query and store the results in your result string.

Now that you have the data, you build the xml file using the echo statement.

The php finishes off by closing your database connection.

Below is the code:

somefile_GET.php

<?PHP

$link = mysql_connect("localhost", "userid", "password");
mysql_select_db("flash_database");

$query = 'SELECT * FROM flash_game_table order by score desc, date_played desc LIMIT 1';
$results = mysql_query($query);

echo "n";
echo "n";

while($line = mysql_fetch_assoc($results)) {
   echo "" . $line["date_played"] . "n";
   echo "" . $line["name"] . "n";
   echo "" . $line["level"] . "n";
   echo "" . $line["score"] . "n";
}

echo "n";

mysql_close($link);

?>

Flash CS5.5 and AS3 – How to save local data to a Flash Shared Object (Flash Cookie)

Create a shared object (Flash Cookie) in Flash to save data for later retrieval. These shared objects are saved with a SOL file extension.

Here are two ways you can find them.

Run the ‘Analyze’ feature of ‘CCleaner’   (You can get this product at http://www.piriform.com/ccleaner)

Do a scan using the program Flashcookiesview.   (You can get this product at http://www.nirsoft.net/utils/flash_cookies_view.html)

I will call my shared object (or file) myLocalData.

var myLocalData:SharedObject =SharedObject.getLocal("myLocalData");

To set data in a shared object, define any object name of you want after the class member, data, and assign it a value. The object can be a string, number, or even an object.

myLocalData.data.name= "James";
myLocalData.data.score = 80;

The shared object is written from memory to the hard drive when the flash movie ends. You can force the shared object to be written manually using the flush() command.

You can read the shared object from memory at any time while the flash movie is active.

Here is an example by using a trace.

trace("Name = " + myLocalData.data.name);
trace("Score = " + myLocalData.data.score);

An object would be read like this:

trace("someobject = " + getlocal.(“TheObject”);

You can check whether the data exists like this:

If (myLocalData.data.name == null)

You can delete a shared object like the following:

MyLocalData.clear();

You can delete just the object variables of a shared object using a loop:

For (var MyObjectVariable in MyLocalData.data)
{
 deleteMyLocalData.data(MyObjectVariable);
}

Flash CS5.5 and AS3 – Giving keyboard focus to an embedded Flash movie

Add to the beginning of the <body> tag, the onload event handler for your flash object. When the page is produced in the browser, the focus should now be on the flash object.

<body onload="window.document.someflashfile.focus();">
        <div id="flashContent">
            <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="550" height="400"
                id="BibleTests" align="middle">
                <param name="movie" value="http://www.somewebsite.com/someflashfile.swf" />
                <param name="quality" value="high" />
                <param name="bgcolor" value="#cc99ff" />
                <param name="play" value="true" />
                <param name="loop" value="true" />
                <param name="wmode" value="window" />
                <param name="scale" value="showall" />
                <param name="menu" value="true" />
                <param name="devicefont" value="false" />
                <param name="salign" value="" />
                <param name="allowScriptAccess" value="sameDomain" />
                <!--[if !IE]>-->
                <object type="application/x-shockwave-flash" data="http://www.somewebsite.com/someflashfile.swf"
                    width="550" height="400">
                    <param name="movie" value="http://www.somewebsite.com/someflashfile.swf />
                    <param name="quality" value="high" />
                    <param name="bgcolor" value="#cc99ff" />
                    <param name="play" value="true" />
                    <param name="loop" value="true" />
                    <param name="wmode" value="window" />
                    <param name="scale" value="showall" />
                    <param name="menu" value="true" />
                    <param name="devicefont" value="false" />
                    <param name="salign" value="" />
                    <param name="allowScriptAccess" value="sameDomain" />
                    <!--<![endif]-->
                    <a href="http://www.adobe.com/go/getflash">
                        <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif"
                            alt="Get Adobe Flash player" />
                    </a>
                    <!--[if !IE]>-->
                </objectgt;
                <!--<![endif]-->
            </objectgt;
        </divgt;
     </body>

Adobe Flash CS5.5 and AS3 – Registration Point vs. Transformation Point

Flash defines two different types of points for every symbol. Both points are used for reference by Flash, but in different ways.

Transformation point is a tiny circle displayed on the symbol. This point is used when transforming the symbol. In other words, the point where you rotate the symbol. You can move this point around using the Transformation tool.

Registration point is a tiny cross-hair used to set the coordinate of the symbol on the stage. When a symbol is created, it defaults to the top left corner of the symbol. This is the same as a symbol’s current X/Y coordinate. X = Distance from the left of the stage. Y = Distance from the top of the stage. This point can be manipulated via ActionScript code. For example, the point, or X/Y coordinate is used to determine collision.

Adobe Flash CS5.5 and AS3 – How to center flash games in the center of the browser

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta http-equiv="content-type" 
content="text/html;charset=ISO-8859-1?>
  <title>Test
  <style type="text/css">

html {
  height:100%; /* fix height to 100% for IE */
  max-height: 100%; /* fix height for other browsers */
  padding: 0; /*remove padding */
  margin: 0; /* remove margins */
  border: 0; /* remove borders */
  background: #ff0000 /*color background – only works in IE */
  overflow: hidden; /*get rid of scroll bars in IE */
  overflow-y: hidden;
  overflow-x: hidden;
}

body {
  height: 100%; /* fix height to 100% for IE */
  max-height: 100%; /* fix height for other browsers */
  padding: 0; /*remove padding */
  margin: 0; /* remove margins */
  border: 0; /* remove borders */
  hide overflow: hidden from IE5/Mac
  overflow: hidden; /*get rid of scroll bars in IE */
  overflow-y: hidden;
  overflow-x: hidden;
}

 </style>
</head>
<body bgcolor="#ff0000? leftmargin="0" topmargin="0" marginwidth="0?
     marginheight="0" scroll="no">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000?
   codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"
   width="100%" height="100%">
   <param name="movie" value="Test.swf">
   <param name="quality" value="high">
   <param name="menu" value="false">
   <param name="salign" value="mc">
   <param name="scale" value="noscale">
   <embed src="Test.swf" width="100%" height="100%"
  scale="noscale" quality="high" menu="false"
  pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"
  type="application/x-shockwave-flash">
    </embed>
  </object>
  </body>
  </html>

/* Incidentally, if you want to position the swf somewhere other than center, change the salign to either “t”, “lt”, “l”, or “b”, etc. */