Solved

Flash: ActionScript: Getting variables from loadVariablesNum()

Posted on 2003-11-08
4
1,681 Views
Last Modified: 2012-06-22
Ok this should be easy...   but I am used to perl, and have never really used actionscript before....

I need to be able to use the information from loadVariablesNum in a var...     :

loadVariablesNum ("./inc?Ran="+random(999), 0);   ### get info from file "inc" << already know how to use this line

var newVariable == loadVariablesNum;

if(newVariable=="x")                                      ### this is what I need to do, but it doesn't work!! Is it because I am
{                                                                   ### use'n loadVariablesNum and not just loadVariables??
getURL("./test.htm");                                         ### Also: could I just referance inc instead of creating a new var for it??        
}

Any help would be much appreciated...    thanks :)
0
Comment
Question by:dr34m3rs
  • 2
  • 2
4 Comments
 
LVL 27

Expert Comment

by:negatyve
ID: 9710597
Maybe the external vars is not yet loaded.

Flash 5:

• create an empty movieclip on the stage
• assign this script to the clip:

onClipEvent(load){
      this.loadVariables("./inc?Ran=" + random(999));
}
onClipEvent(data){
      if(newVariable=="x"){
            getURL("./test.htm");
      }
}

Flash MX:

• drop this code on the stage:

data_var = new LoadVars();
data_var.onLoad = function(ok)
{
      if(ok){
            if(this.newVariable=="x"){
                  getURL("./test.htm");
            }
      } else {
            trace("FILE MISSING");
      }
}
data_var.load("./inc?Ran="+random(999));

=========== VERY IMPORTANT ============

in the external file, there should be a variable called "newVariable" defined this way:

&variableName=variableValue&

for example:

&newVariable=x&

0
 
LVL 1

Author Comment

by:dr34m3rs
ID: 9711154
The external vars are being loaded via loadVariablesNum ("./inc?Ran="+random(999), 0);

I currently use this output in a dynamic text box which reads everything written to the file inc where inc=x
All I need is the simplest way possible to read that variable (already read by flash) like:

if(inc==x){
getURL ("./test.htm");
}

or

if(loadVariableNum==x)){
getURL ("./test.htm");
}

Actually I haven't yet tried the if(inc==x) one...   but would that be written correctly?? I just have no idea how to write in actionscript. :-O

Thanks. I'm upping the points...
0
 
LVL 27

Accepted Solution

by:
negatyve earned 300 total points
ID: 9711421
ok, this is the simplest:

Flash 5:

• create an empty movieclip on the stage
• assign this script to the clip:

onClipEvent(load){
    this.loadVariables("./inc?Ran=" + random(999));
}
onClipEvent(data){
    _level0.inc = inc;
    if(inc=="x"){
         getURL("./test.htm");
    }
}

Flash MX:

• drop this code on the stage:

data_var = new LoadVars();
data_var.onLoad = function(ok)
{
    if(ok){
         _level0.inc = this.inc;
         if(this.inc=="x"){
              getURL("./test.htm");
         }
    } else {
         trace("FILE MISSING");
    }
}
data_var.load("./inc?Ran="+random(999));


All this if the external variable is called inc...
0
 
LVL 1

Author Comment

by:dr34m3rs
ID: 9711599
Ok excellent!! Thank you very much.  :)
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question