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




LoadVars.onload And Return



i have been stuck on this thing for a while now and can't find the solution anywhere on the internet. I'm working on making a class file for the flash foru i just made and am stuck on the logging in part. The cript works and logs in the user, but i want to be able to know when the data has been loaded from php to flash.
ActionScript Code:
class trpFF { public var URLString:String;  //Login Variables public var user:String; public var pass:String; public var output:String;  function trpFF(absoluteURLString:String) {  URLString = absoluteURLString;  System.security.allowDomain(URLString); }  public function loginUser(username_str:String, password_str:String) {  var lv:LoadVars = new LoadVars();  var lo:LoadVars = new LoadVars();  lv.user = username_str;  lv.pass = password_str;  lo.onLoad = function(sucess:Boolean):Void  {   if (sucess) trace(output);  };  lo.onLoad();  lv.sendAndLoad(URLString+"checkuser.php", lo, "POST"); }}
it works with this and logs me in
ActionScript Code:
as = new trpFF("http://www.trp-florida.com/flash_forum/");as.loginUser('teddy','any_password');
and i want to be able to do this
ActionScript Code:
as = new trpFF("http://www.trp-florida.com/flash_forum/");as.loginUser('teddy','any_password'); as.onLoggedIn = function() { gotoAndPlay(2);}
thanks for help anyone



KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 07-19-2006, 05:15 PM


View Complete Forum Thread with Replies

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

Return Value From Onload
I am new at as2 and haven't used as1 for years and am running into some problems. My first question is, is it possible to return a value from the onload function? I have tried but it seems to just return a bolean. Now I'm just trying to duplicate the onload function with a different name but that doesn't seem to work either.

the purpose is to load an xml document, extract the one address, and use that address in the flash movie to load a video.

here's what I have so far:
[hr]
var xmlLoc:String = "xml/video.xml";
// create the XML object
var videoLocXML:XML = new XML();
videoLocXML.ignoreWhite = true;

// create the event for when it laods content
videoLocXML.onLoad = function(success) {
if(success) {
var file:String = this.firstChild.childNodes[0].childNodes[0];
var dir:String = this.firstChild.childNodes[1].childNodes[0];
var loc:String = dir + "" + file;
trace("location = "+loc);
return(loc);
} else {
trace("there was a major error");
}
}

// the following ain't no string - it's a bolean...
// need to get onLoad to return 'loc' somehow
var _vidURL = videoLocXML.load(xmlLoc);
trace(_vidURL.value);
[hr]
it returns this -undefined
location = http://localhost/vidbb/flash/video/my_video_7.flv

does anyone have any ideas?

Can I Make XML.onLoad Return Something?
Hello

Im having problems with an XML's onLoad returning something in order to make other functions wait for an onLoad to execute first.



Code:
function function2() {
trace("function2 launched");
var xmlDock = new XML();
xmlDock.load("content.xml");
xmlDock.onLoad = function(success) {
if (success) {
trace("XML fetch success.");
return true;
}
};
}
function function1() {
trace("function1 launched");
if (function2()) {
trace("back in function1. do something else.");
}
}
// MAIN PROGRAM
function1();
stop();
As you can see in function1, I've made the call to function2 conditional in an if statement so that it will not execute the follwing commands until function2 has been processed. Now if I put return true; inside function2 directly, this works in that way. But I do not want for the commands to get invoked until the XML has been loaded. xmlDock.onLoad will happen independently whenever it is finished. I want for function1 to wait for that to happen.

Thanks a lot beforehand

Hoping that I've misunderstood something fundamental.

Return From .onLoad Function Syntax HELP
syntax nightmare ...
I would like to load a XML file and onLoad have it return the text of a specific node to where the LOAD function was called from. I have it all worked out except for figuring out how to RETURN from a .onLoad function. Can I return from a .onLoad? See the code below. The mainXML.onLoad fires correctly, and the XML loads successfully. It does not correctly return the node value back the the function named "fLoadXML" however. It returns this:
"myVar: [type Function]"

That leads me to think that it is returning just this object "mainXML.onLoad" and not the value that is returned to it.

Code:
// define the main xml object
var mainXML:XML = new XML();
// functions that loads the XML data
function fLoadXML(file) {
mainXML.ignoreWhite = true;
mainXML.load(file);
//what to do when it loads
return mainXML.onLoad = function(success) {
if (success) {
trace(mainXML.firstChild.childNodes[0].childNodes[0]);
return mainXML.firstChild.childNodes[0].childNodes[0];
trace("XML Load Success");
} else {
trace("XML Load No Success");
return "Error";
}
};
//return myString;
//load the data
trace("load started");
}
var myVar = fLoadXML("data/xmlData.xml");
trace("myVar: "+myVar);
//


any ideas would be helpfull. I am trying desprately not to have to use any global variables anymore, and this would help me out on that front.

thanks

--mm

[as2]XML.onload = MyFunction - Return A Value From The Function?
Hi,

Im having a little trouble, i hope someone can help.
As an example i have :

ActionScript Code:
// Load the XML
body_xml = new XML();
body_xml.load("bodies.xml");
body_xml.ignoreWhite = true;
 
body_xml.onLoad = createbodyObjects;
function createbodyObjects (success) {
  if (success == true) {
    bodies = new Array();
    bodies[1] = new body();
    bodies[1].shape = "Im a body";
    }
 
}


After this runs, I can't reference the Array, in normal functions i could have called it using myArray = createbodyObjects(); and then returned the array, but I can't do this in this instance, I have tried making the function global etc.

Can anyone help??

Neil

LoadVars, OnLoad?
Hi all,
I'm using the LoadVars object to pull data from an ASP.net script. I'm having some trouble with the function that I set up to trigger once the data has loaded.

So a simple question:
When you use loadVars, does the success function fire off as soon as data is loaded or when all of the data is loaded?

Someone told me that I needed to add a loop to make sure all of the data is loaded... but I though you didn;t need that if you use the LoadVar object...

Thanks

LoadVars.onLoad Help
hi

i am using loadvars to load url encoded data from a php file.

when i trace the output it shows that the variables have been retrived successfully.

now i need to use the values by assingning then to a variable. i cant seem to get this going

i am using flash 8 with as2.


myVars.onLoad = function (success) {
if (success) {
trace (" variables loaded ");
ad1id.text = myVars.ad1id;
ad1src.text = myVars.ad1src;
clipid.text = myVars.clipid;
clipsrc.text = myVars.clipsrc;
ad2id.text = myVars.ad2id;
ad2src.text = myVars.ad2src;

} else {
trace (" Error loading variables ");
}
}

is the above method used for assigning the variables correct.

i need to use the values of the variables on the left in another part of the script. the script extracts url encoded data from a php script very successfully i have already check this with trace.

ram

LoadVars OnLoad
Is there any fixed sequence in which onLoad and onData event handlers of LoadVars object is called.

And are there any chances that following code snippet written in the first frame of timeline lead to infinite loop showing the error "The script in your movie is making the Macromedia Flash Player to run slowly. Do you want to abort the script?"

stop();//stop till everything gets loaded
myLoad=new LoadVars();
myLoad.load(<someip>,myLoad);
myLoad.onLoad=getMy;
function getMy(success)
{
if(success)
{
play();//go ahead when everything is loaded
}
else
{
//show some message if loading unsuccessfull
}
}


which is correct method to use in this situation.
onLoad or onData?

Please reply as soon as possible.

LoadVars OnLoad
Is there any fixed sequence in which onLoad and onData event handlers of LoadVars object is called.

And are there any chances that following code snippet written in the first frame of timeline lead to infinite loop showing the error "The script in your movie is making the Macromedia Flash Player to run slowly. Do you want to abort the script?"

stop();//stop till everything gets loaded
myLoad=new LoadVars();
myLoad.load(<someip>,myLoad);
myLoad.onLoad=getMy;
function getMy(success)
{
if(success)
{
play();//go ahead when everything is loaded
}
else
{
//show some message if loading unsuccessfull
}
}


which is correct method to use in this situation.
onLoad or onData?

Please reply as soon as possible.

OnLoad Or LoadVars
Have I just found some code to load xml into Flash:

moXML = new XML();
moXML.onLoad = makeArray;
moXML.load("xmltest.xml");

Previously I was loading the info in from a .txt file using:

var oVars = new LoadVars();
oVars.load("asp_data2.asp", "_root");

which method should I use?

monkey

LoadVars Problem (using An OnLoad)
I had this working earlier on, and about an hour ago it just stopped working/updating. I can't locate my change, nor do I have another copy to compare to. See if you can see my prob in here:

function addListData() {
set(txtLoaded, "done..");
}
theList = new LoadVars();
theList.onLoad = addListData;
theList.load("CDlist.txt");

It doesn't seem to update any of the text fields, I don't think the load is working. I've got the CDlist.txt file in the correct place..

If you want to check out the files:
http://kaede.bc.ca/FlashHelp/Test1.fla
http://kaede.bc.ca/FLashHelp/CDlist.txt

I've even tried stripping out the function, and the .onLoad line. And just have the text fields in there to see if they update when it gets loaded... nadda.

Thanks!

-J

LoadVars --> Is OnLoad Checked Only Once?
hi all,

i'm hoping for a little walkthrough the loadVars method

what i want to achieve is this: the movie that loads the variables should remain still UNTIL the data has been loaded, and only then resume play...

===============================

// FRAME 1

// stop at frame 1 and resume only when all data is loaded
stop();

// LOAD EXTERNAL DATA //

// event handler function
loadHandler = function(success){
if(success){
// if data loads, play movie...
play();
myTextBox.html = this.text;

}else{
gotoAndStop("error");
}
}

// create loadVars object
myData = new LoadVars();

// set event handler
myData.onLoad = loadHandler;

// load data
myData.load("myFile.txt");

===============================

now here's my question:

is the line 'myData.onLoad ...' checked only once? in other words, does this line do what i need or do i need to place some code on the movie's enterframe event? (something like:

onData{
play();
}

** the movie works locally but it failed to load the data when i tried it up in some webspace (i can't get to it right now, so i thought i'd try asking here)

thanks again

Need An Explanation For LoadVars OnLoad()
hi.

i'm working on integrating my application with one of our clients. the developer i'm working with is an asp guy. he's asking something and i'm unclear how to answer him...and it's regarding the onLoad() method of the LoadVars() object.

basically, i'm making a POST using LoadVars sendAndLoad(). i have a dummy LoadVars that is my target object. my understanding is that if the connection to the server is made, my onLoad() will receive a boolean value of true. but the server can also send a message back with this, is that right? in the examples in the flash help file the target object does read a property of the server's response called "welcomeMessage".

what i've been telling the developer is to send me back a text file with the key/value pair of success=true/false if the POST went thru..and that's all that i'd need.

am i explaining this right to him or am i misunderstanding it?

thanks for any helpfulp tips.

matt.

LoadVars.onLoad Problem....Help Please
Hi,

I'm performing a very simple sendAndLoad to a ColdFusion page.
It works fine when the ColdFusion page is on my local host, but when it's on another server, the LOAD doesn't seem to work...(Flash never gets a response back form ColdFusion). Grrrr...

Anybody have any thoughts or insights? Do I need to adjust some setting on the server? I've also read that sometimes sendAndLoad only works with POST and not GET, but I've tried that to no avail. Why would it work on my local server but not on another? (And the SEND works fine...I've tried it; it's just that no response is ever received)

Please help!


Here's my ActionScript:

Code:
test_txt.onPress = function() {
mtv = new LoadVars();
mtv.test_input = 10;
mtv.onLoad = function(success) {
if (success) {
test_txt._width += 100;
sysout2.text += "testvar: "+mtv.testvar;
} else {
sysout2.text += "error loading from server";
}
};

mtv.sendAndLoad(SERVER+"cfdocs/New_Authentication/Main_Application_lib/test.cfm", mtv, "POST");
};
The ColdFusion is very simple...looks like this:

Code:
<cfoutput>
&testvar=15
</cfoutput>

Does LoadVars OnLoad Timeout?
Does LoadVars onLoad timeout?
Or does it wait until there is a response from the server?
If the URL times out, does the onLoad function still get called with a success = false?

[FMX04] - Help With Loadvars And OnLoad()
Hello all,

I have the following code inside of an on(release) of a button (that is contained in a movieclip).

foundationReceiver = new LoadVars();
var phpCall = "http://XXXX.com/foundation.php?action=getList&foundation=" + this.foundationID;
foundationReceiver.sendAndLoad(phpCall, foundationReceiver);

foundationReceiver.onLoad = function(success) {
if (!success) return;
switch (this.action)
{
.....more code here....

Now, my problem is that the first time i click my button, it hits the sendAndLoad line, but does not enter the onLoad routine......
If I click the button a second time, it DOES enter the onLoad routine.. and everything is happy.. BUT then it enters the onLoad routing AGAIN.. without me clicking the button.

SO it does do the routine twice like it should.. but it does it at the wrong time....

Can someone enlighten me on why this is? I am new to actionscript so please be gentle.

Thanks!

LoadVars OnLoad Doesn't Seem To Work
Hi,

I'm new to the loadVars class but I thought it would be easy to make sure external data is loaded using onLoad.
This is my code in frame 1:
---
// create loadVars instance
get_row = new LoadVars();
// get 1 row from zoeken table
get_row.load("select_row.php?id=149");
// if get_row is loaded
get_row.onLoad = function(){
// WORDS
// put results in array
woorden_array = woorden.split(" ");
// choose random word from array
choise = Math.floor(Math.random() * woorden_array.length);
// get random word from woord_array
woord = woorden_array[choise];
// determin length of woord
woord_leng = woord.length;
//
// loop through woord, put letters verticaly in textfield
for (i=0; i<woord_leng; i++){
letter = woord.substr(i, 1);
f_letter = letter+"
";
f_woord += f_letter;
}
};
---
The textfield f_woord also is in frame 1.
It displays nothing. The only way I did get it to work was by putting the function in another frame. Do I need to check bytes? If so what's the onLoad event for?

Thanks in advance for any help. Regards, Danielle.

LoadVars.sendAndLoad Not Calling OnLoad
Hypothetically, in what kind of situation would a call to LoadVars.sendAndLoad not call onLoad? Are there any? Or will sendAndLoad always call onLoad at some point, even if it is just onLoad(false)

Thanks,
dege

Can't Receive From PHP Using LoadVars, SendAndLoad And OnLoad
Hello,

I can't belive that I am unable to get the simplest of concepts to work

I was trying to setup a simple email page in flash using PHP for a backend. I could receive the email, but the form never changed. All of the data placed into the form, stayed in the form.

To try something a little more simple (I am a newb), I setup a flash page with one input text box (instance name of incoming_txt), a submit button (instance name of btnSubmit) and one dynamic text box (instance name of outgoing_txt). The idea was to type into the input text box, click submit and what ever I typed would be sent to a PHP script and then back to Flash and displayed in the dynamic text box. Simple right? Well, it doesn't work.

I can type in the input text box, I can click submit, but all I ever get in the dynamic text box is 'undefined'. My .fla consists of three layers (actions, form and button) and 1 frame for each layer.

Here's my ActionScript:

Code:
//###################################
//## Start by creating LoadVars objects.
//## The first one sends data
//## The second one receives data
//###################################
dataSender = new LoadVars();
dataReceiver = new LoadVars();

//################################
//## Submit Button Behavior
//################################
btnSubmit.onRelease = function()
{
//assign properties to LoadVars object
dataSender.incoming = incoming_txt.text;

//send data to script
dataSender.sendAndLoad("stepOne.php", dataReceiver, "POST");

//handle return data
dataReceiver.onLoad = function()
{
outgoing_txt.text = response;
}
}
I think the problem is in the outgoing_txt.text = response; line. I've tried other things there but nothing seems to work...

Here's my php:

PHP Code:



<?php

$thetext = stripslashes(trim($_POST['incoming']));

echo urlencode('response=' . $thetext);

?>




Anyone have any idea what I'm doing wrong?

TIA,
DigitalGypsy

[edit]To correct title[/edit]

Difference Between LoadVars OnData And OnLoad
can someone please put forth a decent explanation of this. Also, could someone point me to a resource that shows how to show a loader during the loading of data. Thanx!

LoadVars.onload() --> Check If It's All Loaded?
Here's my test file:

http://rwocreative.com/arrayTest/arrayTest01.html (Use IE to view it, stupid Safari *grumble grumble*...)

Here's my code:

Frame 1:

PHP Code:



//stop();

//VARIABLES
var rank_id = new Array();
var dir = new Array();
var name = new Array();
var description = new Array();
var tdir = new Array();
var tname = new Array();
//var count;

//selRank: value that is changed whenever you click a thumbnail
var selRank = 1;
_global.maxCount;

//LOAD PHP SCRIPT
myData = new LoadVars();
myData.load("php/load_celebrity.php");
//myData.load("loadfake.txt");

myData.onLoad = function(success) {
    if(success) {
        trace("myData.onLoad = success");
        
        for(var i=0; i<this.count1; i++) {
            //Flash variable side || PHP variable side
            rank_id[i] = this["rank_id"+i];
            dir[i] = this["dir"+i];
            name[i] = this["name"+i];
            description[i] = this["description"+i];
            tdir[i] = this["tdir"+i];
            tname[i] = this["tname"+i];
            _global.maxCount = this.count1;
        }
        
    } else {
        trace ("Error loading data for query.");
    }
}; 




Frame 10:

PHP Code:



stop();

var widget;
selPic = 0;
//trace("_global.maxCount = "+_global.maxCount);

for(i in rank_id) {
    trace("rank_id["+i+"] = "+rank_id[i]);
    trace("dir["+i+"] = "+dir[i]);
    trace("name["+i+"]: "+name[i]);
    trace("description["+i+"]: "+description[i]);
    trace("tname["+i+"]: "+tname[i]);
    trace("tdir["+i+"]: "+tdir[i]);
    trace(" ");
}

//POPULATE THE MOVIE CLIPS ON-STAGE
while(selPic<maxCount) {
    widget = rank_id[selPic];
    loadMovie(tdir[selPic]+tname[selPic], ["t"+widget]);
        
    if(widget==selRank) {
        textHolder_txt.text = description[selPic];
        loadMovie(dir[selPic]+name[selPic], holder_mc1);
    }
    
    this["dir"+selPic].text = dir[selPic];
    this["name"+selPic].text = name[selPic];
    this["description"+selPic].text = description[selPic];
    selPic+=1;
};
//Add in an if() loop HERE to check if the movie clips are done populating
if(selPic >= maxCount) {
    //trace("selPic = "+selPic+" and _global.maxCount = "+maxCount);
    gotoAndPlay("go");





Frame 11:

PHP Code:



stop(); 




Here's my problem:

The file I've got above works, technically, but it only works if I push the loadMovie functions waaaay out several frames. Is there a way to detect when the var.onload() finishes parsing all the data to the separate arrays? I'm sure pushing the loadMovie out a few frames is workable for a small file, but if I work with a larger text file then there'll be problems.

Thanks!

Getting Outside Array Values From W/i LoadVars.onLoad --> ?
Why can't I get the value of d from within the onLoad statement below? If I run a trace from outside the onLoad statement I can get the values just fine. It's puzzling me.


PHP Code:



secName = new Array("home","about","desn","phot","contact","client");

for(var d = 0; d < secName.length; d++) {
    this["myData_"+secName[d]] = new LoadVars();
    //this["myData_"+secName[d]].load("php/load_"+secName[d]+".php");
    this["myData_"+secName[d]].load("txt/loadfake_"+secName[d]+".txt");
    trace("secName["+d+"] = "+secName[d]);
    this["myData_"+secName[d]].onLoad = function(success) {
        if(success) {
            trace("myData_"+secName[d]+".onLoad = success");
            }        
        } else {
            trace ("Error loading data for query: myData_"+secName[d]);
        }
    };


LoadVars.onLoad Suddenly Not Working
I can't figure out why or what I did wrong. I swear it used to work before but now, my onLoad never gets triggered
ActionScript Code:
stop();
var LV:LoadVars = new LoadVars();
LV.onLoad = function(success) {
    if (success) {
        trace("loaded LV");
        getURL("www.google.com", "_blank");
        if (LV.echo == "success") {
            gotoAndStop("Success");
        } else {
            gotoAndStop("Error");
        }
    }
};
submit_mc.onRelease = function() {
    //validation code
    if (errorCount == 0) {
        LV.name = name_txt.text;
        LV.email = email_txt.text;
        LV.subject = subject_txt.text;
        LV.message = message_txt.text;
        LV.key = *****;
        LV.sendAndLoad("myURL.php", LV, "POST");
        this.enabled = false;
        //gotoAndStop("Waiting");
    }
}

PHP Code:



<?php $headers  = 'MIME-Version: 1.0' . "
";$headers .= 'Content-type: text/html; charset=iso-8859-1' . "
";$headers .= 'From: ' . $_POST['name'] . '<' . $_POST['email'] . '>' . "
";$headers .= 'Bcc: foo@bar' . "
";$message = stripslashes($_POST['message']) . "<br>Your IP address is: " .$_SERVER['HTTP_CLIENT_IP'] . $_SERVER['REMOTE_ADDR'] ."<br>The browser you are using is: " . $_SERVER['HTTP_USER_AGENT'] . "<br>The date and time is: " . date("l F j Y g:i a");if ($_POST['subject'] !="" && $_POST['email'] !="" && $_POST['message'] !="" &&$_POST['key'] == ****) {    $ok = mail("foo@bar.com", stripslashes($_POST['subject']), $message, $headers );}if ($ok) {    echo "&echo=success";} else {    echo "&echo=failed";}?>




Can you spot my error???? The mail gets sent correctly, I just never get validation from the server.

LoadVars.onLoad Returning Failure..
Hello,

I made a small app in flash that sends an e-mail by calling a simple mailing script in php. I used LoadVars to store the separate variables and then a call to sendAndLoad() to call the mailing script. It works. I get the e-mails just like i expected to, but for some reason, after a short delay the onLoad event handler for the LoadVars object constantly returns success = false after the call to sendAndLoad(). I've tried it on mozilla, IE, and Opera with the same result on all of them. I'm happy it works but I'd still like this fake error taken care of, so I can know when there is a real one. Any advice or suggestions are appreciated. Here is my code:








Attach Code

// initialization of class
Post = new LoadVars();
Result = new LoadVars();
Result.onLoad = ResultLoaded;
// defining of function
function ResultLoaded (success:Boolean){
if(success){
error_txt.text = "success";
} else {
error_txt.text = "failure";
}
}
// called in another function
Post.info1 = "info1";
Post.info2 = "info2";
Post.sendAndLoad("relativelinkto.php", Result, "POST");

// php is a simple mail script that accesses the $_POST['info1'] variables and calls mail()
// I have tried both of these versions...

mail("the e-mail", "the subject", "the body");

$success = mail("the e-mail", "the subject", "the body");

LoadVars OnLoad Error Message
I'm having trouble using the onload method in the following code. I keep receiving the error message, "Left side of assignment operator must be variable or property" on the line of code that reads:

contactLV.onLoad(success) = function() {

Below is the code from the frame:







Attach Code

rec="office@macyweiss.com";
serv="php";

var fields_descriptions= Array ("",
Array("t1", "your_name", "Your Name:"),
Array("t2", "telephone", "Telephone:"),
Array("t3", "address", "Address:"),
Array("t4", "city", "City:"),
Array("t5", "state", "State:"),
Array("t6", "your_email", "Your E-Mail:"),
Array("t7", "message", "Message:")
);

var contactLV:LoadVars = new LoadVars();

for (i=1; i<=fields_descriptions.length; i++) {
this["k"+i].text=fields_descriptions[i][2];
}

sendButton.onRelease = function() {
this.gotoAndPlay("s1");
};
sendButton.onReleaseOutside.onRollOut = function() {
this.gotoAndPlay("s2");
};



sendButton.onRelease = function() {
for (i=1; i<_parent.fields_descriptions.length; i++) {
if (_parent[_parent.fields_descriptions[i][1]]!=undefined) {
this[_parent.fields_descriptions[i][1]]=_parent[_parent.fields_descriptions[i][1]]+"&777&"+_parent.fields_descriptions[i][2];
}

}

this.recipient=_parent.rec;
i=undefined;
contactLV.sendAndLoad("contact."+_parent.serv, contactLV, "POST");
contactLV.onLoad(success) = function() {
if (this.sent == "true") {
_root.gotoAndPlay(1);
}
};
};

LoadVars Problem(as Did Not Wait Onload Done)
Last edited by Codemonkey : 2006-03-28 at 04:23.
























Hi everyone,

We develop a sign up website by PHP and Flash, user type e-mail and the website will check that e-mail exists or not exists. After that it will be go to next page.

The problem is the Flash didn't wait PHP return variable until PHP was running, it go to next statement. So I can't check the e-mail.

Could you give me some advise please?

Here my code:

ActionScript Code:
function onLoadData()
{
 if (trim(this.kq) == "false") {   
  createErr(t2_txt,"The e-mail is already used. Please choose another one.");
  flag = false;
 }
}
 
function checkUniqueEmail(t_txt:TextField){
 myVars = new LoadVars();
 myVars.email = t_txt.text;
 myVars.onLoad = onLoadData;
 myVars.sendAndLoad(urlcheckemail, myVars, 'POST'); 
}
 
//main
flag = true;
checkUniqueEmail(email_txt);
if (flag == true) {
  gotonextpage();
}


I use Flash Pro 8.
Thanks,
Best regards,

LoadVars() Seems Return Nothing
hi guys
i wounder if someone can give a hand with my problem, the code is simple but i dont know WHYYY it doesn't work...
Iam using a form in flash that send user,pass and other informations... to php script insertGET.php, this scripte insert the data in a table in mysql, all is fine, except i dont get the feedback from php to flash witch tell me all is Ok...or Not


my submit button in flash :

on(release) {
var d = new LoadVars();
d.txtnomu = txtnomu;
d.txtmdp = txtmdp;
d.txtnom = txtnom;
d.txtprenom = txtprenom;
d.txtage = txtage;
...
d.sendAndLoad("../php/insertGET.php", d, "GET");

}


i let 20 frames to give time that flash get back the confirmation and in 21th frame i verifie what iget back


if(d.test == 1)
{
gotoAndPlay(23); //all is ok
}
else if(d.test == 2)
{
gotoAndPlay(24);// something wrong
}
else {
gotoAndPlay(25); // i dont get anything
}


in my php script :


...
mysql_query($add_candidat) or die("Erreur sql :".mysql_error() );
$test = "test=1";

}
else {
$test = "test=2";
}
echo $test ;


I am using Flach MX 2004 Pro
thx

LoadVars.onload Doens't Work In Function?
hi all,

I got no problem with loadVars in the main stage but when I placed it in a function inside a movie clip (exactly a smart movie clip) like this:


Code:
function Init() {
this.createTextField("tf", 1, 0, 20, 300, 0);
this.tf.multiline = true;
this.tf.autoSize = "left";
this.tf.selectable = false;
this.tf.wordWrap = true;
this.tf.border = false;
this.tf.type = "dynamic";
myTextFormat = new TextFormat();
myTextFormat.font = "Verdana";
myTextFormat.size = 10;
myTextFormat.color = 0xffffff;
myTextFormat.leading = 1;
this.tf.setNewTextFormat(myTextFormat);

// may have trouble here ...............
loadVarsText = new loadVars();
loadVarsText.load(fileName);
loadVarsText.onLoad = function(success) {
if (success) {
this.tf.Text = this.varName;
}
};
// end of may have trouble here .................
}
When I debuged, the lines of code in the loadVarsText.onload function didn't work

Any idea? Any suggestion?

Thanks in advance

Sif The LoadVars.onLoad Function In Tutorial Works
sif the LoadVars.onLoad function in tutorial works
loadableData.onLoad = function(success){

I have used the above fucntion as outlined in the realtive Actionscript.org tutorial about the LoadVars object and have been sitting here for over 2 hrs trying to get it to work. Ive run trace("im here"); to find out where flash is getting stuck and this function is the culpurate.
Of course Im running Flash MX so no version problem, but after reading the macormedia site im not sure the above function is the appropriate use of the onLoad boolean.

Have any ideas whats wrong? (see below)




Code:
onClipEvent(load){
loadablePaylist = new LoadVars();
loadablePaylist.load("paylist.txt");

var status = null;

loadablePaylist.onLoad = function(success){

if(success)
{
//load outcome
status = "Paylist loaded";
trace(status);
trace(loadablePaylist.track_count);

var vertpos = 46;//vertical positioning of clips
var count = 0;
//convert string track_count to number
noOfTracks = new Number(track_count);

while(count!= noOfTracks){
duplicateMovieClip(_root.paylist.box,"box" + count + 1, count);
setProperty("_root.paylist.box" + count + 1, _y, vertpos);

vertpos = vertpos +_root.paylist.box._height;//increment verical positioning value
count++;
}//end loop

}

else
{
status = "Empty paylist";
trace(status);
//if no paylist maybe open dialog again, error!??


}
}//end function(success)


}//end onClipEvent()


-Rich

LoadVars/onload W/ DataGrid Problem (Flash MX)
Greetings all,

Here's my problem:

I have a 3 frame movie in Flash MX. It's taking data from a text file via loadVars and (via Macromedia's DataGrid Component) displaying the results to the user. Everything works fine locally - but as soon as I upload everything to the server, the DataGrid comes up empty. Normally, I would think that this is a result of loadVars not loading the file completely. However, I have an "onload" function that should take care of this. It's a mystery why, it seems, the flash movie seems to be ignoring the code that checks to see if everything is fully loaded.

BTW, I took this code from http://www.bizwerk.net/asp20tutorial...ple_fields.htm

If you notice, the link for "**View Updated Code for Flash MX and DataGrid Component**" is at the top.

-------------------------------------------
The first frame contains this ActionScript:

var sitestext = new loadVars();
sitestext.load("test2.asp");

The second frame contains:

sitestext.onLoad = function(success) {
if (success) {
counter = sitestext.Counter;
if (counter == 1) {
gotoAndStop("end");
} else {
gotoAndPlay(2);
}
}
};

The third frame contains the code where it breaks up the text file and inserts the information into the DataGrid (i don't think there's anything wrong here - remember that this WORKS LOCALLY):

var oput = sitestext.output.split(",");
var email = sitestext.eoutput.split(",");
var address = sitestext.aoutput.split(",");
var state = sitestext.stateoutput.split(",");
var zip = sitestext.zipoutput.split(",");
var phone = sitestext.phoneoutput.split(",");
var url2 = sitestext.urloutput.split(",");

var dP = new Array();
info_txt.text = "SCROLL TO VIEW LOCATION AND CONTACT INFORMATION FOR OUR " + oput.length + " LOCATIONS."
for (var i = 0; i<oput.length; i++) {
dP[i] = {Name:oput[i], Address:address[i], City:email[i], State:state[i], Zip:zip[i], Phone:phone[i], Online:url2[i] };
}
grid.SetDataProvider(dP);
grid.alternateRowColors(0xFFFFFF, 0xCCCCCC);
grid.getColumnAt(0).setWidth(125);
grid.getColumnAt(1).setWidth(135);
grid.getColumnAt(3).setWidth(34);
grid.getColumnAt(4).setWidth(35);
grid.getColumnAt(5).setWidth(80);
mystyle = new FStyleFormat();
mystyle.face = 0xffcc99;
mystyle.textfont = "arial narrow";
mystyle.textsize = 10;
mystyle.background = 0x003399;
mystyle.highlight3D = 0x999999;
mystyle.textColor = 0x00246D;
mystyle.addListener(grid);
mystyle.addListener(l_button);
mystyleApplyChanges();



------------------------------------------------------
Here's a live example:

http://www.jeanyvesdesigner.com/test/gridfinal.html

Notice no data in the Datagrid. It shouldn't even GET that far if the text file isn't completely loaded. Funny, huh? Oh yeah - if I hit refresh a bunch of times once in a blue moon it WILL work, but only if the browser is taking an extra long time to load the Flash movie.

It seems like a timing issue... locally, the computer is fast enough to load the file. On the server, it isn't THAT fast. But with the onload function set to prevent this, I'm at a loss.

Suggestions?

Thanks.

David

Returning Values From A Function's LoadVars.onLoad..
Hi all, the subject was a bit cryptic, so i'll explain my question a bit.

im trying to put my loadvars function in a class, savedata, and inside savedata.as is the following codes


Code:
class phpdata.savedata
{
//Variable declaration and initiation
private var startMili:Number = 0;
private var startSec:Number = 0;
private var endMili:Number = 0;
private var endSec:Number = 0;
private var savedata_lv:LoadVars;
private var returnVal:String;
private var errno:Number;
private var execTime:Number = 0;
private var errnumber:Number = 0;
private var phpurl:String = "";
private var loaded:Boolean=false;

public function get errnoa():Number {
return errno;
}

function savedata(ssavedata_lv:LoadVars, sphpurl:String){
phpurl = sphpurl;
savedata_lv = ssavedata_lv;
}

function saveit():Number{
savedata_lv.onLoad = function() {
var endTime:Date = new Date();
endMili = endTime.getMilliseconds();
endSec = endTime.getSeconds();
execTime = (endSec*1000+endMili)-(startSec*1000+startMili);
execTime = execTime/1000;
errno = this.errno;
return errno;
}
savedata_lv.sendAndLoad(phpurl+"?uniqueID="+getTimer(), savedata_lv, "POST");
var startTime:Date = new Date();
startMili = startTime.getMilliseconds();
startSec = startTime.getSeconds();
return errno;
}
}


However, in my .fla, i'm calling the saveit function like this


Code:
import phpdata.savedata;
saveCalendar_lv = new LoadVars();
saveCalendar_lv.quan = abc_txt.text;
//var abc = new phpdata.savedata(saveCalendar_lv, "save.php");
var abc = new phpdata.savedata(saveCalendar_lv, "http://192.168.0.102/testinggrounds/save.php");

save_txt.text = abc.saveit();


and as you might have guessed, saveit returns an undefined variable back !

so my question is,
1) am i on the right track doing this in my current way, or am i barking at the wrong tree altogether ? I'm still quite fresh in terms of flash exposure, so if there's a better way of doing it, i'll appreciate it if you can give me a pointer or two I'm trying to reuse this bit of code by placing it in a separate AS file.

2) how do i get the saveit function to return the correct value once the onload function is executed ? And not before the onload function is done ?

thanks in advance !!

*EDIT the is supposed to be startTime:/*--*/Date

LoadVars - Making OnLoad Wait In A Frame?
I'm using LoadVars in Frame 1, and I need to use the resulting variables in other scripts afterwards. (But all the examples I find online only use the variables right in the same script and frame.)

The problem I'm having is, the onLoad function doesn't actually make it wait. The playhead goes ahead to the next frame whether fully loaded or not. It depends on the connection at the moment--if the vars haven't fully loaded, hilarity ensues. (A.k.a, the next script gets Undefined variables and goes into a deathloop.)

My script in Frame 1:

_root.myloadvars = new LoadVars();
_root.myloadvars.load("datapairs.txt");
_root.myloadvars.onLoad = function(success) {
if (success) {
//trace("TXT RETRIEVED");
gotoAndPlay(2);
} else {
trace("TXT NOT RETRIEVED");
gotoAndPlay(1);
}
};


My INTENTION is to hold in Frame 1 until ready to proceed, and then make use of the variables in Frame 2 and beyond.

Things I have tried:

* Moving the above to Frame 2, so the "not retrieved" loop actually has two frames to cycle (back to 1, then forward to 2 where the loadvars script it).

* Adding an additional gotoAndPlay(1) BELOW the above.

But regardless, it NEVER goes back to Frame 1, it always goes forward, and half the time the variables are still Undefined.

I suspect GoToandPlay(1) is the wrong method here. What's the RIGHT way to wait in a frame for LoadVars, and then let other scripts use the variables afterwards? (Note: there it no need for a status message or progress bar--it's a 900 byte text file, and the whole Flash piece is a non-critical header. It's OK if nothing happens in the event that the file is slow to load--I just can't have the later scripts trying to work with variables that aren't ready yet.)

Many thanks for any advice! I've done hours of searching and not found any examples that help.

LoadVars .onload Function & Class Properties
I am using a LoadVars() object inside a class. It's loading an external text file, and all is working in that regard. Here's part of the code that checks when the text file has been loaded; I named the loadvars object "load_info":
- - - - - - - - - - - - - - - - - - - - - - - - - - -
load_info.onLoad = function(true) {
if (true) {
...bunch of statements...
}
}
- - - - - - - - - - - - - - - - - - - - - - - - - - -
But within the above function literal I need to be able to reference and set some of the properties of the class, and my first mistake was assuming using 'this' would do so, but it would be referencing the function object, and not the class object, as I soon found out.

I have looked at other ways of doing the onLoad-true-checking function, but I'm still at a loss.

(I also tried the dumb solution of creating new _root variables as means to transfer back and forth the class property values--it doesn't seem to work for what I'm doing... the problem being that there are many instances of the class object setting the same _root variable)

Thanks.

Why Does LoadVars Return OPPOSITE?
I'm a bit cornfused... Am trying to get Flash to comunicate with a Javascript function. The results so far seem to be the OPPOSITE of what they should be.

Here's my code:

Code:
LoadedFaves = new LoadVars();
LoadedFaves.onLoad = test;
LoadedFaves.load("javascript:GetFavorites()");


The really messed up thing is that if the load fails, it returns "true", but if it succeeds, it returns "false". WHY!? Shouldn't it return false when it fails to find the URL????

Besides this, I can't get any of the values returned from the javascript function. Oyy. :-(

Can LoadVars() Load The Return Value From..
Hi,

Can LoadVars() load a returned value from web service. do we have to set any values to access the data from web service.


Thanks

LoadVars.Load Won't Return Variable
I am 16 hours into frustration.

When you see the code it will be pretty self-explanatory. It's a typical form and db. When the user presses the submit button the database does populate but after that I can't get the ASP to send the blnFailed back to the flash file so that I can send the user to the appropriate page. The variable blnFailed is always coming back as 'undefinded'. I'm so tired and mad. It's like, everything works until it goes to pass me back that variable.

I really hope you can help. Thank you.

Selfminded

The Actionscript is as follows:

__________________________________________________ _______________

function checkFailed(){
if(db.blnFailed == 0) {
_parent._parent.gotoAndStop(2);
}else if(db.blnFailed==1){
_parent._parent.gotoAndStop(3);
}else{
stop();
}
}

function submitFormS(){
var alertString = "";
var checkString = txtSName.text;
var theProblem = checkString.indexOf("'");
if (checkString == "") {
alertString = alertString + "<br>Nothing in Name field.";
} else if (theProblem != -1){
alertString = alertString + "<br>' in Name field. ";
}
checkString = txtSTitle.text;
theProblem = checkString.indexOf("'");
if (checkString == "") {
alertString = alertString + "<br>Nothing in Title field.";
} else if (theProblem != -1){
alertString = alertString + "<br>' in Title field. ";
}
checkString = txtSDistrict.text;
theProblem = checkString.indexOf("'");
if (checkString == "") {
alertString = alertString + "<br>Nothing in District field.";
} else if (theProblem != -1){
alertString = alertString + "<br>' in District field. ";
}
checkString = txtSAddress.text;
theProblem = checkString.indexOf("'");
if (checkString == "") {
alertString = alertString + "<br>Nothing in Address field.";
} else if (theProblem != -1){
alertString = alertString + "<br>' in Address field. ";
}
checkString = txtSPhone.text;
theProblem = checkString.indexOf("'");
if (checkString == "") {
alertString = alertString + "<br>Nothing in Phone field.";
} else if (theProblem != -1){
alertString = alertString + "<br>' in Phone field. ";
}
checkString = txtSEmail.text;
theProblem = checkString.indexOf("'");
if (checkString == "") {
alertString = alertString + "<br>Nothing in Email field.";
} else {
if (theProblem != -1){
alertString = alertString + "<br>' in Email field. ";
} else {
theProblem = checkString.indexOf("@");
if (theProblem == -1) {
alertString = alertString + "<br>Invalid email address in Email field."
}
}
}
checkString = txtSFourth.text;
theProblem = checkString.indexOf("'");
if (checkString == "") {
alertString = alertString + "<br>Nothing in Fourth grade field.";
} else {
if (isNaN(checkString)) {
alertString = alertString + "<br>Fourth grade field should only contain numbers.";
} else if (theProblem != -1){
alertString = alertString + "<br>' in Fourth grade field. ";
}
}
checkString = txtSSixth.text;
theProblem = checkString.indexOf("'");
if (checkString == "") {
alertString = alertString + "<br>Nothing in Sixth grade field.";
} else {
if (isNaN(checkString)) {
alertString = alertString + "<br>Sixth grade field should only contain numbers.";
} else if (theProblem != -1){
alertString = alertString + "<br>' in Sixth grade field. ";
}
}
checkString = txtSTenth.text;
theProblem = checkString.indexOf("'");
if (checkString == "") {
alertString = alertString + "<br>Nothing in Tenth grade field.";
} else {
if (isNaN(checkString)) {
alertString = alertString + "<br>Tenth grade field should only contain numbers.";
} else if (theProblem != -1){
alertString = alertString + "<br>' in Tenth grade field.";
}
}
if (alertString != "") {
alertString = "The following errors have occured:<br>" + alertString;
_parent._parent.clipAlert.alertString = alertString;
_parent._parent.clipAlert.gotoAndStop(2);
} else {
dbURL = "flashsdb.asp"; // I use the absolute path here, insert your own
db = new LoadVars();

var strName = txtSName.text;
var strTitle = txtSTitle.text;
var strDistrict = txtSDistrict.text;
var strAddress = txtSAddress.text;
var strPhone = txtSPhone.text;
var strEmail = txtSEmail.text;
var strFourth = txtSFourth.text;
var strSixth = txtSSixth.text;
var strTenth = txtSTenth.text;

db.onLoad = checkFailed();
db.load(dbURL+"?strName="+strName+"&strTitle="+str Title+"&strDistrict="+strDistrict+"&strAddress="+s trAddress+"&strPhone="+strPhone+"&strEmail="+strEm ail+"&strFourth="+strFourth+"&strSixth="+strSixth+ "&strTenth="+strTenth);

}
}

function clearFormS(){
txtSName.text = "";
txtSTitle.text = "";
txtSDistrict.text = "";
txtSPhone.text = "";
txtSEmail.text = "";
txtSAddress.text = "";
txtSFourth.text = "";
txtSSixth.text = "";
txtSTenth.text = "";
}

function submitFormO(){
}

function clearFormO(){
txtOName.text = "";
txtOPhone.text = "";
txtOEmail.text = "";
txtOAddress.text = "";
txtOProposed.text = "";

}

__________________________________________________ _______________

Here's the ASP Code that goes with it:
__________________________________________________ _______________

<%@ language="VBscript"%>
<%
Option Explicit
Dim objConn, checkSQL, blnFailed
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "DB"

Set checkSQL = objConn.Execute("SELECT Email FROM School WHERE Email = '" & Trim(Ucase(request("strEmail"))) & "'")

If checkSQL.EOF Then
objConn.Execute("INSERT INTO School(Name, Title, District, Address, Phone, Email, Fourth, Sixth, Tenth) VALUES('" & Trim(Ucase(Request("strName"))) & "', '" & Trim(Ucase(Request("strTitle"))) & "', '" & Trim(Ucase(Request("strDistrict"))) & "', '" & Trim(Ucase(Request("strAddress"))) & "', '" & Trim(Ucase(Request("strPhone"))) & "', '" & Trim(Ucase(Request("strEmail"))) & "', '" & Trim(Ucase(Request("strFourth"))) & "', '" & Trim(Ucase(Request("strSixth"))) & "', '" & Trim(Ucase(Request("strTenth"))) & "')")
objConn.Close
Set objConn = Nothing
blnFailed = "blnFailed=0"
Else
objConn.Close
Set objConn = Nothing
blnFailed = "blnFailed=1"
End If

response.write blnFailed
%>

Trouble Using LoadVars To Return A Url For LoadMovie
Hi there.

I hope that someone can help me. I think I'm trying to do something pretty basic and it's just not working.

OK, I have a movieclip on my main timeline that contains some text along with ANOTHER movieclip inside it that I'm using a loadMovie call on. Ok here's my problem...
on the first frame I'm using this actionscript in an attempt to load the url that contains the swf file:
*******
loadVariables("http://localhost/adurl.php", "this");
loadMovie(url, adclip);
stop();
********

Then the PHP file "adurl.php" contains this code:
*******************
<?

$string = "http://localhost/ads/backpain.swf";
print '&url=' . urlencode($string);

?>
*******************

I've tried several ways to grab the value of "url" from the php file and then use it in another function (or maybe for anything else) but no matter what I do it just doesn't work. I know the movie can be loaded because when I put the literal url in place of my variable "url" it works lovely. I also know that the PHP file is returing the value because when I run it thru my browser that works just fine.

But the functionality I'm aiming for is more dynamic than that.
Help anyone? What am I doing wrong?

Problem With Return Values And LoadVars()
Hey

Anyone have an idea to fix this problem. Using LoadVars() to load a string and then format this into a Array. The problem is that i can not return it since trace b is executed before trace a.. Therefor there exist no values in "point" when returned by the function. Anyone have an idea to fix this?

function readobj (test):Array{
var point:Array = Array();

var loadValue = new LoadVars();
loadValue._parent = this;
loadValue.onData = function(inString){

point[0] = 344;
trace("a");

}
loadValue.load(this.loadfile);

trace("b");
return point;
}

Return Value From Function After Loading Data W/ Loadvars?
ActionScript Code:
function getSqlDate():String
{
    var lvDate:LoadVars = new LoadVars();
    var strDate:String;
   
    lvDate.onLoad = function(bSuccess:Boolean)
    {
        if (bSuccess)
        {
            strDate = lvDate.date;
            return strDate;  //obviously this can't go here
        }
    }
    lvDate.load(strURLPrefix + "getDate.aspx");
}

I am trying to load data from LoadVars inside a function, then return that data thru the function. Obviously I can't keep my return statement where it is. How can I build this function so I can return lvDate.date all the time?

Trouble With "simple" OnLoad And LoadVars
Hello!

I've done similar things already before, but for some strange reason this rather simple functionn doesn't want to work.

The purpose of the function is simply to check if a certain filename exists or not:

function ExistsFile (MyFilename) {

//Checks if a filename exists or not

var CheckPath
var MyExistsFile

CheckPath = BasePath + CharPath +"/" + MyFilename + ".txt";
CheckPath = CheckPath.toLowerCase();
trace(CheckPath);
objLoadText = new LoadVars();
objLoadText._parent=this;
objLoadText.onLoad = function(mysignal) {
if (mysignal) {MyExistsFile=1}
else {MyExistsFile=0}
}
objLoadText.load(CheckPath);
trace(MyExistsFile);
return MyExistsFile;
}

Regardless of the fact whether the file exists or not, I receive UNDEFINED as the result...

And I have no idea why... Can anyone spot the problem? A trained eye probably can tell me immediately why I deserve a slap...

Artimidor

AS2: What Datatype Should A Function Return, If It May Not Return *anything*?
The title of this post may not make much sense, let me explain...

I have a function:

findSurface(origin:Point, vector:Point, attempts:Number):Point {...}

The function has an obscure use, but the idea is thus: given those three arguments, returns a point IF the 'line' (created by the origin and vector arguments) intersects the object the function is called on. [but that is another story...]

More importantly, if there is no point of intersection at all, what should the function return? Void? Null? Undefined? Object? Or can I use one of those return types instead of Point incase the function does not encounter an intersection?

I'd be glad to try explaining better if anyone might know, thanks.

XML Loads Other XML Files, Onload Function In Onload Function
I am writting an image gallery that loads one intial xml file named galleries.xml.
From this point each xml node loads a XMl file for that gallery that holds all the images.
The problem arises in the fact that to do this I need a onload function within an onload function. Onload functions dont accept parameters so I can pass down the variable that shows what loop the gallery loop is on as I need that in the function that holds the images. I hope you can understand what I am trying to say.

I will include the galleries.xml file and a sample image xml file and the fla.

Preloading Loadvars + Code That Uses The Loadvars
Hey everyone

I can't find out how to do this.

I have a main file with a menu. When a menu button is pressed, and external SWF with the corresponding page is loaded into a container in the main movie. I use the MovieCliploader for this

In all my external files, I have a loadVars that gets XML-output from a PHP-file. In the onLoad handler, I have a buildPage() function that takes the variables and e.g. builds a news page and so on.

My question is how I make a preloader that preloads the loadVars + all the code inside my buildPage function? I mean - on big preloader for it all?

I guess it cannot be done with my moviecliploader inside my main movie?

thanx - Rune

Help LoadVars.send Vs. LoadVars.sendAndLoad
OK, my understanding is that if example 1 works so too should example 2:

Example 1:var my_lv:LoadVars = new LoadVars();
my_lv.overall_score = _root.overall_score;
my_lv.send("score.php", _blank, "GET");
Example 2:var my_lv:LoadVars = new LoadVars();
my_lv.overall_score = _root.overall_score;
my_lv.sendAndLoad("score.php", result_lv, "GET");
My understanding is however clearly wrong as example 1 will pass the variable quite happily to my php script which will update appropriately. In example 2, nothing. Nada. Variables aren't availabe to php and (therefore unsurprisingly) my_lv.onload isn't picking up any return.

Where am I going wrong this time?!

Cheers,
Andrew

[AS1][loadVars] Scope Trouble With LoadVars
Hi everybody,

I'm new on this server !
Is there a way to attach a file to my thread ?
You would find enclosed a ".zip" file in wich there's a ".fla" file, a ".txt" file and 6 ".jpg" images.
Frame 1 of the FLA only has a "Preload" class/constructor found on another site and works well.
Frame 2 launches the graphic interface construction.

The file "externalVar.txt" has one variable "maxVin" with a value of 6.
I would like to know WHY i can't acces this variable from outside of the loadVars object's scope (i would better say from outside of its ".onLoad" methode scope).
In fact, when i trace my variable "maxVinNum" from outside of this function, flash player return "undefined". Even if i declare "maxVinNum" on the _root (_root.maxVinNum).

For information, at the start of frame 2, i have let an instruction in comment :
//var maxVinNum = 6;
When we activate this instruction, then the variable is directely declared and everything works well. This test allow us to verify that scripts are not bugged.

Here is the script of frame 2, some of you may understand quickly what's wrong :

//var maxVinNum = 6;
var vignetteVars = new LoadVars();
vignetteVars.onLoad = function(ok) {
if (ok) {
trace(this.loaded);
maxVinNum = this.maxVin;
trace("maxVinNum = " + maxVinNum);
}
};
vignetteVars.load("externalVar.txt");
//
function buildArray (arrayLength) {
FileArray = new Array();
for (var i=0; i<maxVinNum; i++){
FileArray.push ("v_"+(i+1)+".jpg");
}
trace("FileArray : " + FileArray);
};
//
function buildSlide(){
vinKern = 1;
preloadSlide = new Preloader(load_indicator);
for (var i=0;i<FileArray.length;i++){
//Construction du slide
slide.vignette.duplicateMovieClip("vignette"+i,i);
slide["vignette"+i]._x += i*(slide.vignette._width + vinKern);
// ajoute à la file du preloader
preloadSlide.insert(FileArray[i], this.slide["vignette"+i].conteneur, i,"","","okload");
}
slide.vignette._visible=0;
};

buildArray(maxVinNum);
buildSlide()
stop();


I hope my english is not too bad, and my explaination not too long and understable.
thanks a lot for your help !

LoadVars.send VS LoadVars.sendAndLoad
Last edited by gkcohen : 2004-04-23 at 09:19.
























can someone tell me what the difference is with these two. here is my problem. i am trying to submit some info to php script. i have my variables in text file.

if if loadVars.load("textFile.txt");
and then say loadVars.send(url, "_blank", "post") then it will work. but i dont want to load the resulting php page outside of flash. if instead i do loadVards.sendAndLoad(url, dataReceiver, "post") then it will not work. my dataReceiver will return blank, or i will get an error that the variables were not sent.

i guess that you cant loadVar from a text file and then use it with sendAndLoad, is that right?

the reason for using the text file is the real problem. the php script requires a variable 'group_ids[]' with an integer for a value. apparently, flash cant read the variable with the '[]' in it. i have tried different ways to get it formatted, but it wont work. i tried do something like loadVars.group_ids + "[]" = 1 but i get message stating the the object to the left of the operand must be a variable.

my only fix was to use a text file to load this variable. it works, but only when using the send and having a php srcipt popup.

i am not too familiar with php to modify the scipt, and i think that variable needs to be an array.

i dont know what else to do. HELP

gkc

[AS1][loadVars] Scope Trouble With LoadVars
Hi everybody,

I'm new on this server !
Is there a way to attach a file to my thread ?
You would find enclosed a ".zip" file in wich there's a ".fla" file, a ".txt" file and 6 ".jpg" images.
Frame 1 of the FLA only has a "Preload" class/constructor found on another site and works well.
Frame 2 launches the graphic interface construction.

The file "externalVar.txt" has one variable "maxVin" with a value of 6.
I would like to know WHY i can't acces this variable from outside of the loadVars object's scope (i would better say from outside of its ".onLoad" methode scope).
In fact, when i trace my variable "maxVinNum" from outside of this function, flash player return "undefined". Even if i declare "maxVinNum" on the _root (_root.maxVinNum).

For information, at the start of frame 2, i have let an instruction in comment :
//var maxVinNum = 6;
When we activate this instruction, then the variable is directely declared and everything works well. This test allow us to verify that scripts are not bugged.

Here is the script of frame 2, some of you may understand quickly what's wrong :

//var maxVinNum = 6;
var vignetteVars = new LoadVars();
vignetteVars.onLoad = function(ok) {
if (ok) {
trace(this.loaded);
maxVinNum = this.maxVin;
trace("maxVinNum = " + maxVinNum);
}
};
vignetteVars.load("externalVar.txt");
//
function buildArray (arrayLength) {
FileArray = new Array();
for (var i=0; i<maxVinNum; i++){
FileArray.push ("v_"+(i+1)+".jpg");
}
trace("FileArray : " + FileArray);
};
//
function buildSlide(){
vinKern = 1;
preloadSlide = new Preloader(load_indicator);
for (var i=0;i<FileArray.length;i++){
//Construction du slide
slide.vignette.duplicateMovieClip("vignette"+i,i);
slide["vignette"+i]._x += i*(slide.vignette._width + vinKern);
// ajoute à la file du preloader
preloadSlide.insert(FileArray[i], this.slide["vignette"+i].conteneur, i,"","","okload");
}
slide.vignette._visible=0;
};

buildArray(maxVinNum);
buildSlide()
stop();


I hope my english is not too bad, and my explaination not too long and understandable.
thanks a lot for your help !

OnLoad Help
I'm having problems pausing the execution of code until my onLoad function is finished.

test = new XML();
test.onLoad = onTest;
test.load("auction.xml");
//i want it to pause here until the onLoad is complete.

print(x)

function onTest(){
//bunch of stuff ...
x = something;
}

If anybody can think of an easy, clean solution. That'd be great. Thanks,

Lloyd

OnLoad In Mx
hi

i'm just getting my head round the mx actionscript style - can't see why this code isn't working

if (total>0) {
pageNum++;
var pageName = "holder"+pageNum;
createEmptyMovieClip(pageName, 1);
var tag = eval("holder"+pageNum);
tag.onLoad = function() {
trace("onLoad is working");
};
tag.onEnterFrame = function() {
this._x++;
};
}

the onEnterFrame works fine... but onLoad does not
it's probably something obvious but i just can't see it

thanks for your help

XML.ONLOAD
I've some problems with Xml.OnLoad sentence.

When I use function without parameters I do:
XMLPrincipal=new XML();
XMLPrincipal.ignoreWhite=1;
XMLPrincipal.load(fitxerXML);
XMLPrincipal.onLoad=InicialitzarED ;
and this executes correctly...

But, I've added a parameter to InicialitzarED function...and when I do:
param1="A";
XMLPrincipal=new XML();
XMLPrincipal.ignoreWhite=1;
XMLPrincipal.load(fitxerXML);
XMLPrincipal.onLoad=InicialitzarED (param1) ;
it's executed InicialitarED(param1) just in moment that I assign to XMLPrincipal.onLoad !! And no waits for the xml...

Somebody can help me ??

THANK'S!!

B

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