Passing variables to flash using html - Flashvars AS3

Hey guys! I'm gonna teach on this tutorial how to pass the variables to the Flash(AS3) using flashvars in html.
We will start creating the html that will be our file .swf wich in this exemple will be called flashvars.swf :

   <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
width="550" height="440" id="flashvars">
        <param name="movie" value="flashvars.swf" />
        <param name="quality" value="high" />
        <param name="FlashVars" value="nome_Vars=Erick&lastname_vars=Alves"
        <embed src="flashvars.swf"
FlashVars="name_vars=Erick&lastname_vars=Alves" quality="high"
bgcolor="#ffffff" width="550" height="440" name="flashvars"
pluginspage="" />

The code above shows that I'm creating the tag object and passing the param name FlashVars with the variables that the flash will load. Let's see now the AS3:

We will create a new swf file named flashvars and inclue a dynamic instantiated text like nomecompleto on stage.
We need to create now a new class named Main that should go like this:

package  {
    import flash.display.MovieClip;
    import flash.display.*;
    public class Main extends MovieClip {
        public function Main() {
        public function loadVariables():void{
            var parameters:Object =
            var name:String = parameters['name_vars'];
            var lastname:String = parameters['lastname_vars'];
            fullname.text = name + " " + lastname;

Now we can play our clip. Probably the variable's place 'fullname' will be showing the text 'null null'. That happens because the variables are empty. The flash needs to be named by the html that we created before.

Well, folks, that's it. Any doubts just coment bellow that I will try to help you guys out.

Your rating: None


Post new comment

The content of this field is kept private and will not be shown publicly.