setFlashVariable and Flash 9 with Action Script 3

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • lisbeth
    Indigo Rose Customer
    • Dec 2007
    • 15

    setFlashVariable and Flash 9 with Action Script 3

    Hi all!

    I've recently run into a problem with some flash files which we use to show different menu texts in an AutoPlay interface. The reason for the flash files is that the texts we show include languages such as Chinese and many other languages that need Unicode which to my knowledge is not available in AP. These flash files get a path from the AP interface which is then read and the data in that file is shown.

    To cope with Chinese, I've had to convert these flash files to ActionScript 3 (file size reasons), and now the SetFlashVariable function seems not to work. I've changed the way the flashVars are read within the flash and it works if I put the flash in a html page.

    I've made sure that the flashVar is set by AP before it's being loaded in the Flash (at least the way it used to work), by having a stop() as the first command in the Flash file and the loading taking place on the next screen. The AP project calls SetFlashVariable before calling play() on the flash, which should work, right? Any hints or tips on what I might be doing wrong?

    Thanks in advance,
    Lisbeth
  • lisbeth
    Indigo Rose Customer
    • Dec 2007
    • 15

    #2
    Has anyone gotten flashvars to work with ActionScript 3 and AutoPlay? If you have, then please let me know what I might do differently.

    Comment

    • lisbeth
      Indigo Rose Customer
      • Dec 2007
      • 15

      #3
      Worked around this before by using AS2 in the Flash objects, but now I'm back on square one. I need to be able to send flashvars to an AS3 Flash. Has anyone made this work?

      Comment

      • LucasTheDuck
        No longer a forum member
        • Oct 2009
        • 123

        #4
        It's possible to use flashvars with as3, i've done that in some projects, but it's a little complicated, some websites talk about change _root.var for MovieClip('root').var, but this doesn't work.

        You need to set up a public variable on as3 class

        There are great infor here: http://greenethumb.com/article/23/un...t-class-in-as3
        Last edited by LucasTheDuck; 03-17-2010, 01:51 PM.

        Comment

        • lisbeth
          Indigo Rose Customer
          • Dec 2007
          • 15

          #5
          Hi Lucas and thanks for your reply. I'm still unable to make this work, though. I have the following code in my AS3 Document class:
          Code:
          package
          {
          	import flash.display.MovieClip;
          	import flash.text.TextField;
          
          	public class Test extends MovieClip
          	{
          		public var myvar:String;
          	
          		private function loadme():void
          		{
          			if(myvar != null)
          				testtext.text = myvar;
          			tracetext.text = "I'm alive";
          		}
          	}
          }
          and two textfields, named testtext and tracetext in the .fla. The .fla calls loadme() on frame 5. I then put the resulting .swf in an AutoPlay MS project, and use this code in the page's On Show to set the flashvar:

          Code:
          Flash.SetFlashVariable("Flash1", "myvar", "text for myvar");
          Flash.Play("Flash1");
          The "I'm alive" shows up, but not the "text for myvar". Can you, or anyone else, please help me with what I'm doing wrong?

          Comment

          • Scriptonite
            Indigo Rose Customer
            • Oct 2009
            • 279

            #6
            Can you post your project so I can see what your trying to accomplish?
            There are 10 types of people in the world: those who understand binary, and those who don't.

            Comment

            • lisbeth
              Indigo Rose Customer
              • Dec 2007
              • 15

              #7
              Attached is my autoplay project and the source of the .swf I'm using. What I want to be able to do is to set a variable (myvar) in the flash from AutoPlay.

              I've used this many times with AS2, but am unable to make it work with AS3.
              Attached Files

              Comment

              • reteset
                Indigo Rose Customer
                • May 2006
                • 1688

                #8
                it is probably too late to set variable
                i cannot open your fla doc ,but your flash movie starts immediatly
                when on show event fires it may too late


                i have also not very much familiarity with AS3

                try making a listener on that variable and set text field's text if that variable is not empty

                for example (this is a AS2 code)

                Code:
                this.onEnterFrame = function()
                {
                	if ( _root.myvar != "")
                	{
                		testtext.text = myvar;
                		myvar = "";
                		
                	}
                }
                Code:
                Flash.SetFlashVariable("Flash1", "myvar", "text for myvar");
                with this method you can set this variable any time you want
                amsplugins.com Is Closed.

                Facebook Page

                Comment

                • Scriptonite
                  Indigo Rose Customer
                  • Oct 2009
                  • 279

                  #9
                  I will try to look this over tonight. I would make two quick recommendations though.

                  1) If you don't need AS3 I would strongly advise using AS2 when working with AMS because of it's ease of use.
                  2) If you are going to use AS3 your very best option is going to be using XML for your variables, it's just going to make your coding life easier.

                  I will do my best to get something together for you, it's rather late right now and I may not be able to sit down with this until monday.
                  There are 10 types of people in the world: those who understand binary, and those who don't.

                  Comment

                  • lisbeth
                    Indigo Rose Customer
                    • Dec 2007
                    • 15

                    #10
                    Hi and thanks for the help!

                    I just noticed that I'd forgotten to untick the AutoStart for the Flash in the AMS. The flash is not supposed to start until after the flashvar has been set. Just untick it for Flash1 in the project I uploaded in my last post and it should be fine.

                    Comment

                    Working...
                    X