Using SWFObject it’s pretty easy to pass variables from a web page to your flash movie.
If you are using the static publishing method:
<param name="flashvars" value="myBlueVariable=5&myRedVariable=6" />
If you are using the dynamic publishing method:
<script type="text/javascript">
var flashvars = {};
flashvars.myBlueVariable = "5";
flashvars.myRedVariable = "6";
To retrieve these variables in Flash, simply write:
var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters; blueTextField.text = "Blue variable is ..." + paramObj.myBlueVariable; redTextField.text = "Red variable is ..." + paramObj.myRedVariable;
Be prepared however, when you test your movie to see the following error:
UNDEFINED
Because your web page is sending the variable to flash, to view this properly, you would have to test it in a web browser.
Download flashVarsExample.
Gaia Framework: How to work with SWFAddress and SWF Assets from Nicole Chung on Vimeo.
Here are some code snippets I found useful when working with SWFAddress in the Gaia Framework, if anyone has more suggestions let me know!
To change the address:
Gaia.api.goto("index/nav/my-current-page/my-sub-page");
Gaia automatically listens for when the address changes, but if you are doing something special when the address changes (other than loading in a page) you can override the onDeeplink method:
overrride public function onDeeplink(e:GaiaSWFAddressEvent):void
{
trace(e.deeplink);// gets you the deeplink
// do your stuff here
}
When working with .swf assets, there’s no need to manually load the asset in (unless you want to), just include the following in your site.xml:
<asset id="yellow_mc" src="yellow.swf"/>
Then to make your .swf file visible, write:
IMovieClip(assets.yellow_mc).visible = true;
And to access items on the stage of your yellow_mc:
IMovieClip(assets.yellow_mc).content.instanceName = doSomething;
Gaia Flash Framework – How to use your own preloader animation from Nicole Chung on Vimeo.
Lately I have been messing around with the Gaia Framework. I think for certain kinds of flash sites – for example, sites that aren’t Flash games or complex applications – that this framework is a great thing. I know that there are developers out there who feel that it’s better to roll their own framework, but Gaia really does a lot, especially if you use SWFAddress (which – once you get into making larger sites with more than one “/level/” of linking – isn’t easy without employing some design patterns).
A really great thing about the framework, in addition it the constant updates (which I suppose if you were on a longer project, might end up working against you) are some terrific mods (for example, to control cacheing and memory management) and a pretty easy-to-use API.
So today I am starting to build a small site using the Gaia Framework.
The first thing I noticed is that when creating assets, the asset ID has to be alpha-numeric, so the following:
- won’t work at all. It has to be:
No dashes.
No ending with a number.
With flupie, you can create some great text animation events. However, it doesn’t work with actionscript StyleSheet objects, only TextFormat.
To use HTML text in with flupie, use the .htmlText property to combine bold, italic and regular styles in the same TextField:
format = new TextFormat("My-font-name");
message = new TextField();
message.defaultTextFormat = format;
myAnim = new TextAnim(message); myAnim.htmlText = " Some text here with bold text ";