Solved

Flash: ActionScript: Getting variables from loadVariablesNum()

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
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.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

743 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

13 Experts available now in Live!

Get 1:1 Help Now