4 Replies Latest reply on Sep 20, 2006 10:27 AM by calmchess333

    global flash variables

    calmchess333 Level 1
      Hi example #1 pulls data from a php script into flash.........my problem is i can't access that data from anywhere else in the script...........I'd like to somehow make.....username = myLoadVars.valid; ....variable global.....or make the php data global so i can access the data from anywhere within the flash script.

      I've tried alot of ways to accomplish this...._global.....var.....trace from outside the onload function......every which way you can think of but I always get a trace output of undefined.......or the data isn't accessible....Please help...i've given it my best effort.



      example#1

      var myLoadVars:LoadVars = new LoadVars();
      myLoadVars.onLoad = function( success ){
      if(success){
      username = myLoadVars.valid;
      trace(username);
      }
      }
      myLoadVars.load('test4.php');
        • 1. Re: global flash variables
          DazFaz Level 1
          Ive used a basic .txt file to test this and its working fine for me. i can access the ueser name variable from a button with no problem. Are you trying to detect the variable before its had chance to load. In the past for me, when connecting to asp and a like. Ive had real problems detecting variables being passed only to realise I was trying to read them before they had all loaded.
          • 2. Re: global flash variables
            calmchess333 Level 1
            the script i have works for me but say i want to trace the username variable from
            the end of the current script......the below example demonstrates what i mean and the trace output says undefined.....my problem is I cannot access the username variable from anywhere except inside the myLoadVars.onLoad function.



            var myLoadVars:LoadVars = new LoadVars();
            myLoadVars.onLoad = function( success ){
            if(success){
            username = myLoadVars.valid;
            trace(username);
            }
            }
            myLoadVars.load('test4.php');

            trace(username);
            • 3. Re: global flash variables
              Rothrock Level 5
              Well of course the trace says undefined, username is undefined when the trace is executed. Flash doesn't just wait at the onLoad line until the load happens and then continue on. It does all the code in the frame. So what you can do is put all the code that needs the variables in the next frame and have your onLoad handler tell the timeline to go to the next frame.
              • 4. Re: global flash variables
                calmchess333 Level 1
                that worked perfectly....thankyou and forgive my keyboard....it turns green when I use flash.