Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




LoadVars = Success, But My Vars Are Undefined?



Hello all!
I've been working with LoadVars a lot recently and like it very much so. However, I have encountered a new problem. As always, I have searched through a bunch of threads to no avail; if this is a repeated question, please trout slap me and I'll apologize! Anywho -

I have this array that already works in my Flash project:

ActionScript Code:
angles = [0, 35, 100, 72, 72, 81];

Now I want to pull those numbers in the array from a changing PHP program. To start, I'm using a test file:

PHP Code:


&p1=0&p2=35&p3=100&p4=72&p5=72&p6=81 



Then I have actions like this right before I need those pulled in:

ActionScript Code:
lv = new LoadVars();lv.onLoad = function(success){if(success){p1 = this.p1;p2 = this.p2;p3 = this.p3;p4 = this.p4;p5 = this.p5;p6 = this.p6;trace(p1);     //returns a zero}}lv.load("myStupidTextFile.txt");trace(p1);    //returns 'undefined'  

How do I get those variables to register outside of the loadVars? There has to be a way, right??!!



KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 06-04-2004, 08:29 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

LoadVars = Success, But My Vars Are Undefined?
Hello all!
I've been working with LoadVars a lot recently and like it very much so. However, I have encountered a new problem. As always, I have searched through a bunch of threads to no avail; if this is a repeated question, please trout slap me and I'll apologize! Anywho -

I have this array that already works in my Flash project:

ActionScript Code:
angles = [0, 35, 100, 72, 72, 81];

Now I want to pull those numbers in the array from a changing PHP program. To start, I'm using a test file:

PHP Code:



&p1=0&p2=35&p3=100&p4=72&p5=72&p6=81 




Then I have actions like this right before I need those pulled in:

ActionScript Code:
lv = new LoadVars();lv.onLoad = function(success){if(success){p1 = this.p1;p2 = this.p2;p3 = this.p3;p4 = this.p4;p5 = this.p5;p6 = this.p6;trace(p1);     //returns a zero}}lv.load("myStupidTextFile.txt");trace(p1);    //returns 'undefined'  

How do I get those variables to register outside of the loadVars? There has to be a way, right??!!

Loadvars Success Problem
I am making an e-mail form through Flash.

This is my action script code on the submit button:

on (press) {
var result_lv:LoadVars = new LoadVars();
result_lv.onLoad = function(success:Boolean) {
if (success) {
trace("success");
} else {
trace("Error connecting to server.");
}
};
var send_lv:LoadVars = new LoadVars();
send_lv.email = _parent.Email;
send_lv.sub = _parent.Name;
send_lv.message = _parent.Message;
send_lv.sendAndLoad("website.com/mail2.php", result_lv, "POST");

}


The emailing works, but I always get the "error connecting to server" message. Does anyone have any idea why?

Thanks for any help

Defaulting Undefined Vars Using | ?
I've seen some posts where people are using some kind of shorthand to provide default values for prop/vars that are othewise undefined. I seem to recall that they also use the OR (|| or |) operator, kinda like this: Rex = "Dog" || AnimalType, which basically means "If AnimalType has been defined, set Rex to that value, otherwise, use 'Dog'"... (obviously the example shown won't work, and would instead evaluate to true/false)

And before you post, yes I know about the ?: syntax like Rex = (AnimalType==undefined) ? "Dog" : AnimalType - the one I'm specifically looking for is different and uses (I think) the bitwise or logical OR operators. I've only seen a very few people using it, and thought it was very cool and space-saving.

The search engine here and on google won't recognize the | character, so I'm finding this impossible to search for!

Anybody know the answer? Very curious....

PHP Vars Are 'Undefined' In Flash
Hi everyone, first post! Ok, enough of the small talk.

I'm importing variables from PHP into Flash.
Everything is fine when user types in the web address with WWW dot WHATEVER dot COM.

However, if the user types in WHATEVER dot COM without WWW, it returns the values as 'undefined'.

Anything I can do about this?

SendAndLoad Vars (result Undefined)
I'm having some difficulties with the LoadVars class.

This is a function that gets called on button press. When I run the movie the send_lv loadvars object traces

Quote:




username=Anonymous&userid=0&preferenceVar=both&tag Var=&txtVar=%0D&titleVar=&longitudeVar=582&latitud eVar=1219




So the vars are filled. But they don't seem to get passed on to sendReview as they don't get inserted into my DBase. Also, the onLoad always returns 'true', whether I run it from my localhost or not. But the result_lv.debug remains undefined.

ActionScript Code:
function sendReview(){
    tagArray = tagVar.split(" ", 30);
    trace(tagArray);
   
    var result_lv:LoadVars = new LoadVars();
    result_lv.onLoad = function(success:Boolean) {
        if (success) {
            trace("success: " + result_lv.debug);
        } else {
            trace("Error connecting to server.");
        }
    };
    var send_lv:LoadVars = new LoadVars();
    send_lv.latitudeVar = latitudeVar;
    send_lv.longitudeVar = longitudeVar;
    send_lv.titleVar = titleVar;
    send_lv.txtVar = textVar;
    send_lv.tagVar = tagArray;
    send_lv.preferenceVar = preferenceVar;
    if(isset(userid)){
        // If authorised
        send_lv.userid = userid;
        send_lv.username = userName;
    }else{
        send_lv.userid = "0";
        send_lv.username = "Anonymous";
    }
    trace(send_lv);
    send_lv.sendAndLoad("sendReview.php", result_lv, "POST");
}

If wanted, this is my .php code.

PHP Code:



<?php include("conn_settings.php");
if(isset($_POST['userid'])){
    // Insert review
    $tagid = uniqid(rand(0, 9), true);
    $usr_id = addslashes($_POST['userid']);
    $usr_name = addslashes($_POST['username']);
    $latitude = addslashes($_POST['latitudeVar']);
    $longitude = addslashes($_POST['longitudeVar']);
    $title = addslashes($_POST['titleVar']);
    $text = addslashes($_POST['textVar']);
    $pref = addslashes($_POST['preferenceVar']);
    
    /* Debug
    $tagid = uniqid(rand(0, 9), true);
    $usr_id = "0";
    $usr_name = "Anonymous";
    $latitude = 125;
    $longitude = 250;
    $title = "test";
    $text = "database testje";
    $pref = "onlyme";
    */
    
    $query = "INSERT INTO `review` VALUES ('$tagid', '$usr_id', '$usr_name', '$latitude', '$longitude', '$title', '$text', '$pref');";
    
    if(mysql_query($query)){
        $debug = "Review added to database successfully.
";
    }else{
        $debug = "Review could not be added to database. " . mysql_error() . ".
";
    }
    
    
    // Loop through the tags array and create a row for each.
    $tagQuery = "";
    $tagArray = $_POST['tagVar']);
    // $tagArray = array('Belgium', 'Ghent');
    for($i=0; $i<count($tagArray); $i++){
        $tagQuery = $tagQuery . "('$tagid','" . $tagArray[$i] . "'),";
    }
    $tagQuery = substr($tagQuery, 0, -1);
    $query = "INSERT INTO `tag` VALUES $tagQuery;";
    
    if(mysql_query($query)){
        $debug = $debug . "Tags added to database successfully.";
    }else{
        $debug = $debug . "Tags could not be added to database. " . mysql_error() . ".";
    }
    
    echo "&debug="$debug"";
}
?>




Also, when I use send_lv.send it just opens the .php script in my browser (as it would a .txt for example), without actually parsing it.

SendAndLoad Vars (resultVar Undefined)
I'm having some difficulties with the LoadVars class.

This is a function that gets called on button press. When I run the movie the send_lv loadvars object traces

Quote:




username=Anonymous&userid=0&preferenceVar=both&tag Var=&txtVar=%0D&titleVar=&longitudeVar=582&latitud eVar=1219




So the vars are filled. But they don't seem to get passed on to sendReview as they don't get inserted into my DBase. Also, the onLoad always returns 'true', whether I run it from my localhost or not. But the result_lv.debug remains undefined.

ActionScript Code:
function sendReview(){    tagArray = tagVar.split(" ", 30);    trace(tagArray);        var result_lv:LoadVars = new LoadVars();    result_lv.onLoad = function(success:Boolean) {        if (success) {            trace("success: " + result_lv.debug);        } else {            trace("Error connecting to server.");        }    };    var send_lv:LoadVars = new LoadVars();    send_lv.latitudeVar = latitudeVar;    send_lv.longitudeVar = longitudeVar;    send_lv.titleVar = titleVar;    send_lv.txtVar = textVar;    send_lv.tagVar = tagArray;    send_lv.preferenceVar = preferenceVar;    if(isset(userid)){        // If authorised        send_lv.userid = userid;        send_lv.username = userName;    }else{        send_lv.userid = "0";        send_lv.username = "Anonymous";    }    trace(send_lv);    send_lv.sendAndLoad("sendReview.php", result_lv, "POST");}


If wanted, this is my .php code.

PHP Code:



<?php include("conn_settings.php");
if(isset($_POST['userid'])){
    // Insert review
    $tagid = uniqid(rand(0, 9), true);
    $usr_id = addslashes($_POST['userid']);
    $usr_name = addslashes($_POST['username']);
    $latitude = addslashes($_POST['latitudeVar']);
    $longitude = addslashes($_POST['longitudeVar']);
    $title = addslashes($_POST['titleVar']);
    $text = addslashes($_POST['textVar']);
    $pref = addslashes($_POST['preferenceVar']);
    
    /* Debug
    $tagid = uniqid(rand(0, 9), true);
    $usr_id = "0";
    $usr_name = "Anonymous";
    $latitude = 125;
    $longitude = 250;
    $title = "test";
    $text = "database testje";
    $pref = "onlyme";
    */
    
    $query = "INSERT INTO `review` VALUES ('$tagid', '$usr_id', '$usr_name', '$latitude', '$longitude', '$title', '$text', '$pref');";
    
    if(mysql_query($query)){
        $debug = "Review added to database successfully.
";
    }else{
        $debug = "Review could not be added to database. " . mysql_error() . ".
";
    }
    
    
    // Loop through the tags array and create a row for each.
    $tagQuery = "";
    $tagArray = $_POST['tagVar']);
    // $tagArray = array('Belgium', 'Ghent');
    for($i=0; $i<count($tagArray); $i++){
        $tagQuery = $tagQuery . "('$tagid','" . $tagArray[$i] . "'),";
    }
    $tagQuery = substr($tagQuery, 0, -1);
    $query = "INSERT INTO `tag` VALUES $tagQuery;";
    
    if(mysql_query($query)){
        $debug = $debug . "Tags added to database successfully.";
    }else{
        $debug = $debug . "Tags could not be added to database. " . mysql_error() . ".";
    }
    
    echo "&debug="$debug"";
}
?>




Also, when I use send_lv.send it just opens the .php script in my browser (as it would a .txt for example), without actually parsing it.

My thanks to anyone who can help me point out the problem. (also, I would like to apologize for cross-posting this here and on as.org, but it seems as.org's somewhat died out )

LoadVars Gives An Undefined
Hi there,
because I am no 'AS-wizard' my wisdom came to an end...

I tried to load text from an external txt file into the textfield with the LoadVars ...
but I only get an 'undefined'....
I have no clue whats wrong...anyone can help??

thats the AS:
import caurina.transitions.Tweener;


//set the alpha to 0

scroller_mc._alpha = 0;



//fade the textfield in
Tweener.addTween(scroller_mc, {_alpha:100, time:3, delay:2.5});



//--------------LoadVarsAS goes here-------to load the contentTXT-----------
var myLV:LoadVars = new LoadVars();

myLV.onLoad = function (success:Boolean) {
if (success) {
scroller_mc.txt_mc.text_txt.htmlText = myLV.links;
trace("jaja");
} else {
scroller_mc.txt_mc.text_txt.text = "Sorry!There has been an error in loading the text."
}
}


//---------load the text
myLV.load("links.txt");


the external text starts with "links=........"
and I use sharedFonts

Hope someone can help

Thanks a lot

Loadvars Undefined
No matter what I do,

myData = new LoadVars();
myData.onLoad = function() {
Success = true
};
myData.load("params.txt");

when I test this movie in the flash player all run ok,

but embedded in a html page, tested in a server all the parameters are undefined. can anyone help me please????

LoadVars + Php = Undefined
This should be a rather simple thing to do. Server is running, files are in my htdocs folder.

but it just reports undefined. Any thoughts?


Code:
var cat = new LoadVars

function printOut(success){
frankencat.text = cat.id;
}

cat.load("test.php");
cat.onLoad = printOut();

PHP Code:



<?php     print "id=lalalalalalalalalalallalalalalalalalalalalalalalalalalala";?>

LoadVars + PHP = Undefined.. Over And Over Again
First off, I'm no idiot. Wanted to make that statement before acting like one...

PHP Code:


PHP Code:





<?php
echo "score1=1";
?>







Actionscript:


Code:


var score:LoadVars = new LoadVars();
score.load("score.php");
score.onLoad = function() {
trace(this.score1); // displays 'undefined'
};



I tried 11 actionscript examples from the actionscript Bible, PHP for Flash and from numerous websites. I copy/paste code and yet.... nothing works.

I'm using Flash MX 2004.

How is this possible?

LoadVars.loaded Always Undefined
Hi there,

I have:


Code:
lv = new LoadVars();

lv.pageIndex = pageIndex;
lv.sendAndLoad("List_NewsStories.aspx", result_lv, "GET");

trace("loaded: " + lv.loaded);
And it always outputs 'undefined' even in the onLoad handler.

Any ideas?

[F8] LoadVars == Undefined ? [RESOLVED]
Hi,

I've got a LoadVars object that has issues with one of its parameters. This is for a dynamic image gallery that's mostly complete. All of my code works fine, except for when I put the php script I'm calling on my web server. Then one (and only one) of my variables comes back as undefined.

Here's the code:


Code:
var picVars:LoadVars = new LoadVars();
var gall:String = "gallery1";

picVars.onLoad = function(success){
if (success){
parseFiles(picVars.returnFiles,picVars.widths,picVars.heights);
trace(returnFiles); // returns "undefined"
trace(widths); // returns a string of numbers
trace(heights); // returns a string of numbers
}
else{
error = "ERROR WITH LOADVARS";
}
};
picVars.load("../getImages.php?gall=" + gall);


So as you can see, all but one of my LoadVars variables returns the correct data. picVars.returnFiles traces as undefined. And as I said, it works fine when I run it locally.

Also, if I navigate directly to my script, PHP prints the correct data, so it's not a server-side issue. The proper string it returns is:

returnFiles=8.jpg|9.jpg|1.jpg|2.jpg|3.jpg|5.jpg|6. jpg|7.jpg|4.jpg|&widths=47|47|39|39|40|24|48|40|53 |&heights=36|36|36|36|36|36|36|36|36|

Just a big string of image names and dimensions.

This is especially puzzling since "success" is obviously coming back as true. Anyone have any ideas?

LoadVars Returns Undefined
en.txt:
introHead=Headline here.&introBody=Body copy here.

The Flash 8 Stage:

- Text Field instance named "head_txt"
- Text Field instance named "body_txt"
- Both set to Dynamic

The ActionScript:


Code:
// default language //
loadText("en");

// load all site text from file //
function loadText(language:String) {
siteText = new LoadVars();
siteText.load(language + ".txt")
}

// populate headline and body copy text fields for this page //
function populatePage(pageName:String) {
siteText.onLoad = function() {
head_txt.text = siteText.pageName + "Head";
body_txt.text = siteText.pageName + "Body";
}
}

populatePage("intro");
stop();
Since I'm using "pageName" twice, it seems obvious to declare it as a variable and have the function dynamically retreive it. But it's not working. The text being displayed in those two boxes returns as "undefinedHead" and "undefinedBody" instead of the real content from the text file. This does work, however:

Code:
head_txt.text = siteText.introHead;
body_txt.text = siteText.introBody;
i.e., if I "hard code" it, it works fine. But as a variable, it doesn't.

Other random piece of info: if I declare the LoadVars with strict data typing it doesn't load the text file at all:

Code:
var siteText:LoadVars = new LoadVars();
I'm guessing it's scope-related, but I've run out of ideas. Any thoughts?

LoadVars/Targeting Problem . ..undefined
I am building a site in which there is a container file that loads multiple swfs. Those loaded swfs, then load other swfs into them. Once that third level of swfs is loaded, I am loading txt files into the interface. swf(_root) > swf(2) > swf(3) > txtfile.

The LoadVars script that I am using loads perfectly when I test that specific swf individually, but once I script it to load into the various levels, I get an undefined error.

Here is the script without considering the levels:

var loadVarText = new LoadVars();
LoadVarText.load("botero.txt");
loadVarText.onLoad = function() {
scroller.html = true;
scroller.htmlText = this.var1

}

Here is the script considering the levels:

var loadVarText = new LoadVars();
LoadVarText.load("botero.txt");
loadVarText.onLoad = function() {
_root.sections.loader.scroller.html = true;
_root.sections.loader.scroller.htmlText = this.var1

}

If anyone has had this problem and has found a fix, please help!!!

thanks. tonofmun

Global Arrays In LoadVars Undefined
Heellp... I have read all the threads I could find on this topic, but now I've gotta give up.

The question is simple, but the answer isn't... or so it seems.

How can I make the arrays, defined in mycode accessible outside the loadVars object??? The arrays stays local no matter what I do. When I access data in the arrays inside the loadVars object it works okay, but ouside they are "undefined"....!

I have tried using the _global property in every thinkable way, but it does not work.... and now I am completely lost!

What I am trying to do is to build up a poll, importing data from a mysql database. The data import goes fine, and the comboboxes and dynamic text fields in Flash are filled with the data from the database, but, I need the arrays for calculating percantages and totals for when the user clicks submit,

Check out my work in progress here (it's in Danish):
http://www.andand.dk/ulydige_db/ulydige_poll.swf


Here's the code:

var var_loader = new LoadVars();
var var_saver = new LoadVars();

var_loader.onLoad = function(success){
if (success){
var headline_array:Array = this.headline.split("~");
var sp1_array:Array = this.sp1.split("~");
var sp2_array:Array = this.sp2.split("~");
var sp3_array:Array = this.sp3.split("~");
var sp4_array:Array = this.sp4.split("~");
var sp5_array:Array = this.sp5.split("~");
var sp6_array:Array = this.sp6.split("~");
var sp7_array:Array = this.sp7.split("~");

var sv1_array:Array = this.sv1.split("~");
var sv2_array:Array = this.sv2.split("~");
var sv3_array:Array = this.sv3.split("~");
var sv4_array:Array = this.sv4.split("~");
var sv5_array:Array = this.sv5.split("~");
var sv6_array:Array = this.sv6.split("~");
var sv7_array:Array = this.sv7.split("~");

spørgsmål.sp1.text = headline_array[0];
spørgsmål.sv1_1.label = sp1_array[0];
spørgsmål.sv1_2.label = sp1_array[1];

spørgsmål.sp2.text = headline_array[1];
spørgsmål.sv2.dataProvider = sp2_array;

spørgsmål.sp3.text = headline_array[2];
spørgsmål.sv3.dataProvider = sp3_array;

spørgsmål.sp4.text = headline_array[3];
spørgsmål.sv4.dataProvider = sp4_array;

spørgsmål.sp5.text = headline_array[4];
spørgsmål.sv5.dataProvider = sp5_array;

spørgsmål.sp6.text = headline_array[5];
spørgsmål.sv6.dataProvider = sp6_array;

spørgsmål.sp7.text = headline_array[6];
spørgsmål.sv7.dataProvider = sp7_array;
spørgsmål._visible = true;}
else {
_parent.tekst.text = "data could not be read...";}}
var_loader.load("ulydige_poll.php");}

Sending Data With Loadvars To Php , Undefined
Hi,

I've looked around on the net and can't get an answer to my problem..
I need to send data from my flash to php.

here's the code from my flash file

on (press) {
dataSender = new LoadVars();
dataSender.nom = nom.text;
dataSender.prenom = prenom.text;
dataSender.email = email.text;
dataSender.send("../update.php","_self","POST");
trace( dataSender.toString() );

}
they come up undefined in my php file.

Also, when I load my swf with the url http://www.avocadotraiteur.com/fr/swf/intranet.swf the submit buton works, but when the swf is loaded through another swf when you click on submit nothings happens any idea?
Http://www.avocadotraiteur.com click on french then intranet in the bottom menu to see the difference

thank you so much in advance..

Getting Vars From LoadVars
I am loading VARs from an external text file and populating dynamic text fields with information from this external file. This is what I have so far (frame action):

loadVarsText = new loadVars();

loadVarsText.load("directory/file.txt");

loadVarsText.onLoad = function(success) {

if (success) {
dynamicTextFiled.text = this.information1;
} else {
trace("not loaded");
}
};
stop();

As you can see, a dynamic text field is populated with information that is taken from the external text file – after the external text file has been loaded. How can I access other information from this same external text file WITHOUT reloading the entire external text file? In other words... when the next frame in the scene loads I want dynamicTextField.text=this.information2. Any ideas?

Loadvars Getting Vars From A Php File
i have this simple php file set up
<?php
$name1 = "Hello";
$name2 = "World";
echo $name1 . $name2;

?>

i want to load them up in flash
the action script in flash

var myLoadVars:LoadVars = new LoadVars();
myLoadVars.onLoad = function(success:Boolean) {
if(success) {
trace(myLoadVars.name1);
trace(myLoadVars.name2);

}else{
//throw error
}
}
myLoadVars.load("http://localhost/dataDriven/loadvars.php");

however i get this when i test the movie iin flash

undefined
undefined

can anyone point out my mistake
thks

How Get Vars If I Use LoadVars.onData
I use this code and try to get data from simply txt file.
I explored with onData method.
AS:

Code:
var myLV:LoadVars = new LoadVars ();
myLV.onData = function (scr:String)
{
if (scr == undefined)
{
trace ("Error loading content");
}
else
{
_level0.createTextField ("scr_txt", 1, 10, 10, 200, 200);
_level0.scr_txt.border = true;
_level0.scr_txt.text = scr;
_level0.createTextField ("a_txt", 2, 10, 300, 200, 200);
_level0.a_txt.border = true;
_level0.a_txt.text = myLV.var_a;
}
};
myLV.load ("myText.txt", myLV, "GET");
How can I get the value of var_a?
Shoud I use for it method onload ?

Thanks
TXT file has those vars:

Code:
var_a=Hello&var_b=World

List Vars From LoadVars
Is there a way to list the vars retrieved from loadVars?

Thanks,
e39m5

Need LoadVars To Show Vars In Address Bar
Hi,

I'm using this code for a search form and the problem is that when I hit "submit", it returns the page without the variables showing in the address bar of the web browser. I need them to show up.

I need it to go from this: mysite.com/search.php
to this: mysite.com/search.php?search%5Ftype=like&player%5Fname=mantle &cat=1&searchby=last%5Fname&action=search

This is the code I'm currently running:

Code:
stuff = new LoadVars();
stuff.action = "search";
stuff.searchby = searchby;
stuff.cat = cat;
stuff.player_name = mainfield;
stuff.search_type = stype;
//trace(stuff);
stuff.send("http://www.mysite.com/search.php","_self","POST");
Any help would be GREATLY appreciated.

Update Vars Sent To Flash WITHOUT 'GET' Or Loadvars?
OK - could somebody simply tell me if this is even possible -


My main.swf is embedded in my index.html page.

It loads external swfs in ONLY WHEN a HTML button, sitting outside my main.swf but ON index.html is clicked - posting it's variable/value to my swf?

So what I am saying is - Flash will not be functioned to do it's loadVars magic, I want Flash to be ready & waiting for a new variable to arrive at any given time - THEN action a function depending on the value of the variable.

Does this make sense to anyone?

I'm just not sure on the limitations of Flash - the program where I thought absolutely ANYTHING is possible.

If it's not possible then I will go around this problem another way.

Simple Slideshow: LoadVars, Undefined Trace...scope Issue?
I'm making a simple slideshow (Flash MX 2004 V7.2).

I'm using LoadVars to access an outside text document to get the number of slides used in the slideshow (path: vars/slideInfo.txt, totalFrames=4).

Now I KNOW this is elementary, and I know it is something I'M doing/not doing, but I can't get my slideshow to recognize: totalFrames=4 (unless I hardcode it in!).

Using trace I get "undefined" everywhere in my code except within my .onLoad function statement which traces the number correctly: 4 (or whatever I change it to).

From hours of internet searching I think this may be a scope issue.
I've tried adding additional code to fix this (my last efforts reflected below). Still I can't get the number of slides out of this function to be used by the rest of the slideshow.

Will someone please point out what I'm doing wrong (I know I'll feel stupid but I'll still appreciate it!)?

Thanks!

Trace Output from below code:

undefined
undefined
4

4


Code:

var totalFrames:Number;
var slideInfoLV:LoadVars = new LoadVars();
var totalFrames:Number;
trace(totalFrames); //output: undefined
slideInfoLV.onLoad = function(success:Boolean) {
if (success) {
slideCounter();
trace(this.totalFrames); //output: 4
totalFrames = this.totalFrames;
trace(totalFrames); //output: 4
} else {
frameNum.text = "error";
}
};
slideInfoLV.load("vars/slideInfo.txt");
trace(totalFrames); //output: undefined

LoadVars - Passing Vars To External Loaded SWF
I load my vars with LoadVars in main SWF and would to like use the loaded variable in later loaded SWF.
I can´t find how to find the right path to my txt field in this loaded SWF.
E.g.
I load ext. SWF in mc container_images_of_pools
In root of this ext. SWF I habe txt field txt_pools_plastic
Thanks

LoadVars - Passing Vars To External Loaded SWF
I load my vars with LoadVars in main SWF and would to like use the loaded variable in later loaded SWF.
I can´t find how to find the right path to my txt field in this loaded SWF.
E.g.
I load ext. SWF in mc container_images_of_pools
In root of this ext. SWF I habe txt field txt_pools_plastic
Thanks

Load Txt Using LoadVars. Text Doesn't Show But "undefined" Instead?
Hello guys

I'm having some problems loading text. I tried to use the solution explained in the help file of MX 2004. But it doesn't work. What am I doing wrong here

Fla and txt attached.

Regards
Michael

LoadVars Flashing "undefined" In Text Box
Hello, I have a situation here, that I can't figure out.

I have a main movie with:

var externalData:LoadVars = new LoadVars();
externalData.onLoad = function(success:Boolean) {
if (success) {
rcopy_txt.text = externalData.rhomecopy;
trace ("success");
}
};
externalData.load("rhomecopy.txt");

when first coming to the scene there is no "undefined" message and the text file loads fine.

However, my external swfs loading on buttons have this code on it's third frame (after the first two for preloader):

this.onEnterFrame = function(){
_root.rcopy_txt.text = _root.externalData.rcraftscopy;
}
_root.externalData.load("rcraftscopy.txt");

When these files load the text box flashes ("undefined") and then loads the text. Any ideas on how to fix that? Here's a link to the site.

surroundings-rogersgallery.com

HTML "undefined" Using LoadVars()
I'm trying to load HTML into a text field using loadVars(). The text field is in a MC which I am calling to the stage using attachMovie. When the MC is called to the stage it should then load the HTML into the window.

I think everything is correct but when I test the movie and click on the button to launch the MC the text field appears blank. If I click on it there is text there that says "undefined" in Cooper Black, which is the font I specified in the HTML. That font is also embedded in my movie library. I'm confused.

Here is the code I'm using:



Code:
myData = new LoadVars();
myData.onLoad = function() {
theslides_txt.html = true;
theslides_txt.htmlText = this.myVariable;
};
myData.load("theslidehtml.txt");


the html .txt file is a really simple page and is saved in the same directory as the flash. I've attached it if anyone wants to take a look.

Any help would be appreciated immensely.

Success
Thanks grotesmurf and dudovcic@qrex.com, I used a combination of your posts to create the effect I needed.

Thanks a ton!!!

frankosonik

Success
Woot! I finally got the code down. Thanks for those that helped me.

It's probably nothing fancy to all of you Guru's but for me (a newbie to Flash) it's exciting. I've been working on coding a template that is VERY dynamic. ALL the text is dynamic (title, copyright info, main text, menu titles, menu items). There are four dropdown menu's, and each menu can have a user-defined number of items. Each item in the menu can either open a URL in a new window or load a text file into the main textbox, depending on what the webmaster desires.

Check it out and tell me if you find bugs. If you'd like a copy of the FLA, email me, though it's probably rather sloppy for some of you perfectionists.

This was a quickie movie. I basically just wanted to get the code right so I can use it on future projects, so it doean't look too fancy. (only two simple animations, lol)



Thanks again!!

Little Success
I am trying, with little success, to create a custom class that recognizes how many movie clips(or instances of another custom class) are within a defined area. Can anyone help me out here? I'm trying to create a game of backgammon and each Point class needs to know how many Chip classes are on top of it. How can I capture or display that? Any help would be greatly appreciated. Thanks in advance.

Bo

If Undefined Dont Show Text That Says Undefined
Curious to know, I am using flash, .Net, and MySQL and have elements (text fields) posting in flash.

Question is, if the table in the data base is not holding the var char how can I set the text field in flash to not show undefined and just be blank?

I am about to search the heck out of this but if anyone can hit me with some insight it would be much appreciated.

Thanks in advance,
MT

SendAndLoad. Success?
Hi
iuse sendAndLoad to run a asp page and populate a access database. How can i detect the success of the command sendAndLoad? When i get an error in my asp file, how can i detect that?
Thanks
Mario

Loadvariablesnum Success
hi, i'm using loadVariablesNum to load variables from a txt file into a dynamic text box in my movie. i've got it working so that everytime a link is clicked the content in the text box changes and the text box fades in. the problem is sometimes the animation to fade in happens before the variables are loaded. how can i make it so the animation doesn't play until the variables are loaded. here is my code.

ar_mc.onRelease = function() {
loadVariablesNum("arsro.txt", 0);
_root.gotoAndPlay(247);
};

any help would be great.

thx
jeremy boyd

Trying To AttachMovie With No Success
I have created an array of XML Nodes called ContainerArray. Now I would like to attach a movie clip for each of the nodes and fill text boxes inside those movie clips with information from the nodes attributes. Here is my code:
[code]function buildContainerArray() {
ContainerArray = new Array
for (i=0; i<TitleNode.childNodes.length; i++){
curContainer=TitleNode.childNodes[i];
ContainerArray[i] = new Container (curContainer.attributes.number, curContainer.attributes.name, curContainer.attributes.type);
}
makeContainer();
}


function makeContainer(){
for (b=0; b<ContainerArray.length; b++){
attachMovie("con_button", "selection"+b, b);
_root["selection" + b]._x = 15;
_root["selection" + b]._y = 90 + (b*30);
trace ("worked");
}
eval ("selection" + b).onPress = function() {
if (eval ("selection" + b).type_box.text="container") {
trace ("this is a container");
}else if (eval ("selection" + b).type_box.text="test") {
trace ("this is a test");
}
}
}

function Container (numbers, names, types) {
_root["selection" + b].number_box.text=numbers
_root["selection" + b].names_box.text=names
_root["selection" + b].type_box.text=types
trace (numbers)
trace (names)
trace (types)
}
}
[code]
It all seems to work fine except for the attachmovie. I get nothing. Any suggestions?

Trying To AttachMovie With No Success
I have created an array of XML Nodes called ContainerArray. Now I would like to attach a movie clip for each of the nodes and fill text boxes inside those movie clips with information from the nodes attributes. Here is my code:
[code]function buildContainerArray() {
ContainerArray = new Array
for (i=0; i<TitleNode.childNodes.length; i++){
curContainer=TitleNode.childNodes[i];
ContainerArray[i] = new Container (curContainer.attributes.number, curContainer.attributes.name, curContainer.attributes.type);
}
makeContainer();
}


function makeContainer(){
for (b=0; b<ContainerArray.length; b++){
attachMovie("con_button", "selection"+b, b);
_root["selection" + b]._x = 15;
_root["selection" + b]._y = 90 + (b*30);
trace ("worked");
}
eval ("selection" + b).onPress = function() {
if (eval ("selection" + b).type_box.text="container") {
trace ("this is a container");
}else if (eval ("selection" + b).type_box.text="test") {
trace ("this is a test");
}
}
}

function Container (numbers, names, types) {
_root["selection" + b].number_box.text=numbers
_root["selection" + b].names_box.text=names
_root["selection" + b].type_box.text=types
trace (numbers)
trace (names)
trace (types)
}
}
[code]
It all seems to work fine except for the attachmovie. I get nothing. Any suggestions?

ExternalInterface- Has Anyone Had Any Success
Works great on Safari, but does not work on E.I or Mozilla for Mac, but does work on E.I or Mozilla for Win.

Example:
http://islcomps.islco.com/flash/Exte...ace/index.html

The example takes what's in the input box- calls a function in the flash movie that populates the text field in the flash movie and then calls function that calls a javascript function that populates the field on the HTML page with the value in the flash field. Also, pressing the "call Js" button in the flash movie should call an alert with the content of the flash text field.

I suspect this might be a permissions or sandbox issue but really don't know.

I've set the allowScriptAccess = "always" and have also tried "samedomain" .

???

Any help would be greatly appreciated!
Joe

Success OnData? & Z-value Of Mc's
Last edited by Codemonkey : 2006-04-21 at 05:13.
























hi everybody!
well, i got this code... and i'd like to personalize it more... 'cause it shows a message only if .css file fails... what about the .htm file, how can i do it?
it could be better if someone knows the way the make a link in the "load failed message" to load again those files... or just refresh de page...


ActionScript Code:
// Create a new style sheet and LoadVars object
var myVars:LoadVars = new LoadVars();
var styles = new TextField.StyleSheet();
// Location of CSS and text files to load
var txt_url = "news.htm";
var css_url = "news.css";
// Load text to display and define onLoad handler
myVars.load(txt_url);
myVars.onData = function(content) {
storyText = content;
};
// Load CSS file and define onLoad handler:
styles.load(css_url);
styles.onLoad = function(ok) {
if (ok) {
// If the style sheet loaded without error,
// then assign it to the text object,
// and assign the HTML text to the text field.
svnews.styleSheet = styles;
svnews.text = storyText;
} else {
svnews.htmlText = "<br><br><br><br><br><br><br><br><p align='center'><font color='#FF0000'>¡ERROR!<BR>CARGA DE DATOS FALLIDA</font></p>";
}
}

hope u can help me, it doesn't seem difficult

and... there is some code to make a movie clip stay over the other elements? like above in layers? 'cause i load a swf in other swf... and i need a mc stay over the elements in the main swf

thanx ni advance
cheers!

(yes, my engish isn't good )

LoadVariablesNum Success?
Heres my dilema, I'm trying to pass variables from a whole slew of text files, each one has a few variables, heres an example of one of the text files :


Code:
&question=Sample Question
&answerA=Answer A
&answerB=Answer B
&answerC=Answer C
&answerD=Answer D
&answerCorrect=A
Each question will be stored in a numbered text file, question0.txt, question1.txt, etc.. A quiz will be generated and loaded in a random order, the problem I'm having is that I want to create an array with each of these variables stored in that cell, so as question1.txt loads, array[1] stores another array of 6 things, and once those arrays are stored, the next text file is loaded, using a for loop. What I need is a way to pause the for loop untill the information has loaded and been stored from the text file, because right now its going too fast and the variables dont have time to load and be stored before the clip is loading the next text file. I know I can check for the success of a LoadVars() command, but is there a way to do this with a loadVariablesNum? or should I be doing this another way... The only stipulation is the text files, they have to be text files for updateability and scaleability issues.

Heres the code I'm using, thanks to degenerate, to generate my Array.

in the frame, where _root.questionsTotal is a variable loaded from a text file with the total number of questions as a variable.

Code:
_root.questionList = new Array();
_root.questionArray = new Array();
for(i=0;i<_root.questionsTotal;i++){
_root.questionArray[i]=i;
}
in the button

Code:
on(press){
for(i=0;i<25;i++){
var temp = _root.questionArray.length;
if(temp>0){
var rand = Math.floor(Math.random()*temp);
questionArray.splice(rand,1);
}
}

}
This all works fine, its the initial storing of all the variables that has me stumped... Any ideas? Anyone... thanks in advance, and thanks degenerate for the help so far.

If(success) Problem
Here is the code

Code:


sav.onRelease = function(success:Boolean)
{



mdm.FileSystem.saveFile(workorder.text.split("
").join("")+".txt", "Date Posted"+" " + date_proded2.text );

if(success){
mdm.Dialogs.prompt("Correct!")
firstSound=new Sound(this);
firstSound.attachSound("saveprint");
firstSound.start();

} else {
mdm.Dialogs.prompt("Error!")
firstSound2=new Sound(this);
firstSound2.attachSound("error");
firstSound2.start();

}
}




The file saves fine, but I always get the "Error!" prompt. Why is this?

A Zoom Success Story
Hi
I posted a problem on this board a while ago:
I was trying to create this effect:
when you click, you zoom into an image in such a way that the part of the image on which you clicked, is centered on the stage. When you click again, the image returns to its original size. So you can have a closer look at different parts of the image.
I did not understand any of the answers I got, so I had to figure it out for myself, and Voila! (eventually) I did it.

Im attaching the .fla so you can have a look at it, maybe some one else would find this usefull.

I'm sure my script is not the most efficient, and could be neater etc but hey, it works. So for all the newbies out there, keep trying. If I can do it, anyone can.

Cgi Email Success Page
soooo i just set up my email form on my site and it works fine. but once you type in your info and hit send a success page pops up sayin what you entered and that it was sent. i dont want this page to pop up...can i do this in my actionscripting on my button. the script as of now goes as follows:

on (release) {
subject = "Website Email";
recipient = "kurt@kurtcruse.com";
loadVariablesNum("/cgi-sys/FormMail.cgi", this, "POST");
nextFrame();
}


the address is
http://bgsugraphics.com if you wanna try it out and see what i mean

Currency Calculation...success But
i did a currency calculatio prog...that rounds the result to two positions after the decimal points.with help of the funktion posted by johnmac.but it has a problem of not displaying the secong digit after the point if its "0". i found out a solution but still it dosnt work for some numbers entered....pls take a look at the attached file and give me a solution.

.onLoad(success) Confusion
Hi, I'm having trouble understanding this syntax. Can someone spell this out in English for me? (see also)


Code:
myLoginReply.onLoad = myOnLoad;
I know that myOnLoad is executed when myLoginReply has loaded, but I can't read this line in English, and I don't understand why it pauses until myLoginReply has executed. I would have thought onLoad would be set to whatever myOnLoad returned... which is not true?

I've also seen .onLoad(success), and I don't understand why the success argument is in there, or how it works.

Can someone interpret for me?

Whats Up With The Success Boolean?
onClipEvent(load){
var result_lv:LoadVars = new LoadVars();
result_lv.onLoad = function(success:Boolean) {
if (success) {
this._parent.result_ta.text = "AAAIIIIIIIIIIIIIIIII";
} else {
this._parent.result_ta.text = "Error connecting to server.";
}
}
var send_lv:LoadVars = new LoadVars();
send_lv.name = "GOOOOOTCHHHHHAAAAAAAAAAAAAA";
send_lv.sendAndLoad("test2.cgi", result_lv, "POST");
}

I can't see how this returns any value. Does the success boolean thing work no matter what you send the data to? The result_ta doesn't show anything, not even the error message. What am i doing wrong?

How To Determine Load Success
I'm doing something wrong here. I'm loading a string in the form of a url in order to send a variable from my flash movie. This works fine, but I need to figure out how to tell if the variables have been accepted so I can then load an xml file.

Here is the actionscript I am using... anybody have a suggestion for how to check to see if it has been sent/accepted?


Code:
function tagImage(){
var tagTerm = txtTag.text;
var tagURL = "http://blahblahblah.com"+tagTerm+;
var tagArt:LoadVars = new LoadVars();
tagArt.load(tagURL);
tagArt.onLoad = function(success) {
if(success) {
trace("successfully loaded tag supposedly");
grabIt();
} else {
trace("Error sending tag");
}
}
}

[CS3] If(success) ... Fail Issue...
I have an issue where if I have an on.Load, and it succeeds then I want to display one thing... but if it fails, I want to display another in a dynamic text box area with the var sAssistTitle.

I know this should be simple, but it's defaulting to the second and not the first message. And when I make it fail, it doesn't even display the second message.


Code:
obj.onLoad=function(success)

{

if(success){

trace("properties in the object:");
for(var i in this)

{ trace(i+" = "+this[i]);

sAssistTitle = ("It worked.");

}

}

else

{

trace("Error communicating to server.");

}

sErrorTitle = ("It didn't work.");

}

How To Determine The Success Of LoadVariables?
Hey guys, thanks for taking the time.

Before somebody tells me "Hey man use the LoadVars insted" I must say "Yes yes, I know that's the better way to load variables in flash" and I do plan to use them from now on, but since an application I have was programmed in a nasty way I do not understand at a 100%, and it uses a line to send variables to a mail form, but it uses the loadVariables function and I don't wanna mess with that, and I need to fix something quickly.

So, to my question:
I need to display a message upon the success of the loadVariables function or a different message upon failure. And the line is the following:


PHP Code:



_root.orderForm.loadVariables("http://www.domain.com/orders/checkOrder.php", "POST");




Thanks for the help!

[F8] XML Object Success - IE Different Than FireFox
I'm having a pain in the butt problem related to XML file loading...

Here is the set-up (problem described below):

var xmlData:XML = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = makeDataArrays;

And the function receives "success" variable to know everything worked:

function makeDataArrays(success) {

Finally this is the line that loads a file:

xmlData.sendAndLoad("myfile.xml", xmlData);


Here is the problem, testing on a web server: If the XML file does NOT exist, in FireFox success traces as "false". In IE 6, it traces as "true "!

How/Why is this possible? The file is not there. It should be false in both browsers. Needless to say, this is wreaking havoc on error-checking and some debugging efforts.

Firefox Flash Player version is: 9,0,115,0
IE 6 Flash Player version is: 9,0,47,0

Copyright © 2005-08 www.BigResource.com, All rights reserved