Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Flash: ActionScript: Getting variables from loadVariablesNum()

Posted on 2003-11-08
4
Medium Priority
?
1,723 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 1200 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
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…

715 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