Solved

Flash: ActionScript: Getting variables from loadVariablesNum()

Posted on 2003-11-08
4
1,714 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
Suggested Courses

630 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