Solved

Flash: ActionScript: Getting variables from loadVariablesNum()

Posted on 2003-11-08
4
1,669 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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. …
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

863 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now