List Info

Thread: RE: Is the object passed back... Working!




RE: Is the object passed back... Working!
country flaguser name
Switzerland
2007-08-25 03:00:46
> Now, any worries or issues I may have with the above?
No, sounds ok.

However, I wouldn't recommend it as a 'Best Practice' -
basically the 'one
call with many variables' is preferred over the 'many
simultaneous calls
with one variable'.
Imagine a high-traffic site - each of the numerous
simultaneous users
triggers many simultaneous server calls. 
In a worst case scenario this homebrew 'Denial of Service
Attack' could
bring the server to its knees.

I fail to see in which scenario simultaneous server calls
are really
necessary.
To me this looks like working around the limitations of the
LoadVars object
- mainly the fact that only Strings can be sent back and
forth and that
complex datastructures like Arrays have to be reduced to
Strings, 'exploded'
into Arrays again, its contents typecast etc. - and this
possibly several
times (server-side and client-side). 
The perfect alternative: Remoting (e.g. http://www.amfphp.org/).

Leaving 'Best Practice' considerations aside, your solution
might work
perfectly in your scenario.

hth
-------------
Andreas Weber


-----Original Message-----
From: flashnewbie-bounceschattyfig.figleaf.com
[mailto:flashnewbie-bounceschattyfig.figleaf.com] On
Behalf Of George
Langley
Sent: Saturday, August 25, 2007 1:45 AM
To: Flashnewbie Mailing List
Subject: Re: [Flashnewbie] Is the object passed back...
Working!


On 24-Aug-07, at 2:48 PM, George Langley wrote:
> 	Thanks. What I'm trying to do is to dynamically create
an unknown
> number of unique "phpObj" objects, that can
all exist at the same  
> time, and receive their appropriate PHP-returned info.
---------------------
	Got it!

_global.theArray = new Array (); // stores numbers to send
to PHP
_global.varNumber = 1; // a counter for unique names

sendArray = function () {
	theLength = theArray.length;
	if (theLength > 0) { // have numbers to send
   		for(var i=0; i<theLength; i++){
			var currNum = theArray[i];
			sendToPHP(currNum);
		}
	}
	theArray = []; // clear out the array for the next time
}

sendToPHP = function (pNum) { // pass a number
	// first, create a unique dynamically-named variable using
the this 
["name"] technique
	this["myPHPcall"+varNumber] = new LoadVars();
	// HERE#1: point to another variable - is easier to call,
but also  
may be required for syntax?!
	var currObj = this["myPHPcall"+varNumber];
	// set the function to call when PHP returns info
	currObj.onLoad = function() {
		// HERE#2: passing it sends it to the correct object!
		PHPReturn(currObj.returnValue); // NOTE:
"&returnValue=xxx"
is what  
I return in my PHP
	};
	// add variables to the loadVars() object to pass to the
PHP
	currObj.passedNum = String(pNum);
	currObj.notCached = Math.floor(random(1000000) /
random(1000)); //  
prevents cached results
	// now call PHP and get back results
	currObj.sendAndLoad("PHPScript.php",currObj,"
;POST");
	varNumber = varNumber + 1; // update for next call
}

PHPReturn = function (theResult) {
	// do whatever with theResult
}


	So, I can now create and send any number of LoadVars()
objects  
simultaneously, without having to wait for the first object
to get  
its reply before making the next one. AND I don't have to
know the  
object's name when I get a reply back, as I could get them
back in a  
different order than sent due to Internet traffic
fluctuations.
	Of course, this is a bare-bones experiment - have to see if
it works

with the real PHP script and info I need to pass/send. But
the keys are:

#1) creating the initial object, then using another variable
to point  
to it vrs always using the this["name"] format
(MAY have been syntax  
errors on my part, but I don't think so!)
#2) passing the returned info as part of the onLoad function
itself  
(thanks Andreas!) so the correct object receives it's proper
call.

	Now I "probably" could have programmed it to pass
all the numbers as

one call, and receive just one reply back and parse it all
for my  
current project. But I can see this concurrent ability being
required  
in other scenarios, so was good to do, and can be used here
just as  
well.

	Thanks everyone! Now, any worries or issues I may have with
the
above?


George Langley

http://www.georgelangley.
ca

Mary Langley
13 November, 1938 - 14 August, 2007
R.I.P.


_______________________________________________
Flashnewbiechattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashnewb
ie

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training http://www.figleaf.com
http://training.figleaf.c
om

_______________________________________________
Flashnewbiechattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashnewb
ie

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.c
om

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )