Using
Flair’s automatic player output, you
can create a custom player that will add the
actionscript included in the player to the first
frame of your
Flash SWF files created in or exported from Flair (it can
only be added to the first frame).
There are many reasons why someone would want
to add actionscript to a Flash SWF file created in or exported from Flair. Some possible
uses are:
To query a database to get information
for user tracking or ecommerce.
To load additional information into your Flair output
such as data, text or graphics.
To cause your Flair output to launch a web page
or another .swf.
To ensure that files are only played from
a specific web server for file protection.
To add actionscript to a Flair player
so you can dynamically load your Flair output into the
player.
In this example we will add an action to open
an html page when the file starts to play.
Included
with your Flair install are two sample player
FLAs that work with the Flair automatic player
output feature. These can be found in the Wildform>Flair>Players folder.
The two files are called:
Flixskin4a_red.fla
Flixskin5a_red.fla
The
only difference between these two files is that
the “5a” player has volume control.
For the purposes of this tutorial we’ll
be using the players to add actionscript and
not for the play controls, so it doesn’t
matter which one we use.
The first thing to do is to open Flixskin5a_red.fla
in Flash.
Next
rename the output (File>Save As) to Get_Url.fla.
For the purposes of this tutorial we'll eliminate the player frame and play controls
to illustrate how you can use this method to
add actionscript to a Flair SWF file without embedding
the SWF in an actual player. If you want to
keep the player frame and play controls, you
can skip down to “Editing the actions”.
Double
click on the player to drill down into the Flair
Player Skin level.
Then
select the Play Controls, which highlights the
play controls.
Delete
the play controls with the delete key. (They
are not required for a valid Flair player.)
Next select the frame.
Click
on the frame and then change the “Color” setting
to Alpha with a value of 0%. This makes the frame
invisible – the color changes from red
to white on the Flash stage.
Next
you will drag the your Flair output box – the black
box in the center of the frame – to the
top left corner of the frame. I do this so the
file will be positioned correctly and not offset.
Before:
After:
Finally
I adjust the size of my new Secure Player.
I
set it to 400x300 to match the size of the SWF file originally created for this player.
Now
the visual portion of my new player is complete.
The
next thing I need to do is go into the actions
panel and adjust the name, dimensions and add
the actionscript.
Going into “Scene 1”
I
select the “Flix Skin”
And
open the Actions panel.
I
change the “name=” field to “Get
Url Player”. This is the name that appears
in the Flair players window.
I change the “frame_min_width=” field
to “1”
I change the “frame_min_height=” field
to “1”
These new width and height settings will work
for any size file.
And finally I add the following action:
getURL("http://www.wildform.com");
This will cause any Flair outpul file encoded with this “Get
Url Player” to open the web page http://www.wildform.com when
the file starts to play.
Now the actions panel looks like this:
Finally,
I save my output .fla and export my .swf and
I’m done.
This
is a simple example of adding actionscript to
a Flash SWF file created in or exported from Flair. You can use the same method to
add other actionscript to your Flair output.
For more information on how to add players to Flair files, please see our "Adding a Player" tutorial.