[Flashcoders] (AS3) Object to an Array

2008-04-29 Thread SJM - Flash
Hi Guys

Im in need of finding out how or even if its possible to convert an object to 
an array?

Basically I am trying to output some vars from flash to an PHP script, yet when 
PHP recieves the $_POST['textVars'] as [object Object] which is a string and 
not an array so I can't access it with $_POST['textVars'][0]['x'], which should 
output the value of textBox1.x.

var textVars:Object = new Object;

textVars[0] = {
 x  :textBox1.x,
 y  :textBox1.y,
 width  :textBox1.width,
 height  :textBox1.height,
 rotation :textBox1.rotation
};

textVars[1] = {
 x  :textBox2.x,
 y  :textBox2.y,
 width  :textBox2.width,
 height  :textBox2.height,
 rotation :textBox2.rotation
};

sendVars.textVars = textVars;

sendRequest.data = setVars;
sendRequest.url = process.php;
sendRequest.method = URLRequestMethod.POST;
sendToURL(sendRequest);

Thanks
SM
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] (AS3) Object to an Array

2008-04-29 Thread Glen Pike

Hi,

   You could create a loop to look through each object and then make up 
your arrays a bit like this - untested:


   sendVars.textVars = new Array();

   var numVars:int = textVars.length;
   for(var i:int = 0;i  numVars;i++) {
  
  var obj:Object = textVars[i];
  
  for(item:String in obj) {

 trace(itm +  =  + obj[itm]);
 sendVars.textVars[i][itm] = obj[itm];
  }
   }
   //then send your data...

   SWXFormat handles this sort of thing quite nicely, but they were 
still working on AS3 when I last looked.


   HTH

   Glen

SJM - Flash wrote:

Hi Guys

Im in need of finding out how or even if its possible to convert an object to 
an array?

Basically I am trying to output some vars from flash to an PHP script, yet when 
PHP recieves the $_POST['textVars'] as [object Object] which is a string and 
not an array so I can't access it with $_POST['textVars'][0]['x'], which should 
output the value of textBox1.x.

var textVars:Object = new Object;

textVars[0] = {
 x  :textBox1.x,
 y  :textBox1.y,
 width  :textBox1.width,
 height  :textBox1.height,
 rotation :textBox1.rotation
};

textVars[1] = {
 x  :textBox2.x,
 y  :textBox2.y,
 width  :textBox2.width,
 height  :textBox2.height,
 rotation :textBox2.rotation
};

sendVars.textVars = textVars;

sendRequest.data = setVars;
sendRequest.url = process.php;
sendRequest.method = URLRequestMethod.POST;
sendToURL(sendRequest);

Thanks
SM
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


  


--

Glen Pike
01326 218440
www.glenpike.co.uk http://www.glenpike.co.uk

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] (AS3) Object to an Array

2008-04-29 Thread Muzak

use remoting:
http://www.amfphp.org/

- Original Message - 
From: SJM - Flash [EMAIL PROTECTED]

To: Flash Coders List flashcoders@chattyfig.figleaf.com
Sent: Tuesday, April 29, 2008 2:19 PM
Subject: [Flashcoders] (AS3) Object to an Array


Hi Guys

Im in need of finding out how or even if its possible to convert an object to 
an array?

Basically I am trying to output some vars from flash to an PHP script, yet when PHP recieves the $_POST['textVars'] as [object 
Object] which is a string and not an array so I can't access it with $_POST['textVars'][0]['x'], which should output the value of 
textBox1.x.


var textVars:Object = new Object;

textVars[0] = {
x  :textBox1.x,
y  :textBox1.y,
width  :textBox1.width,
height  :textBox1.height,
rotation :textBox1.rotation
   };

textVars[1] = {
x  :textBox2.x,
y  :textBox2.y,
width  :textBox2.width,
height  :textBox2.height,
rotation :textBox2.rotation
   };

sendVars.textVars = textVars;

sendRequest.data = setVars;
sendRequest.url = process.php;
sendRequest.method = URLRequestMethod.POST;
sendToURL(sendRequest);

Thanks
SM
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] (AS3) Object to an Array

2008-04-29 Thread Pete Hotchkiss
Or SWX format

http://www.swxformat.org/

Pete 


 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Muzak
Sent: 29 April 2008 14:09
To: Flash Coders List
Subject: Re: [Flashcoders] (AS3) Object to an Array

use remoting:
http://www.amfphp.org/

- Original Message -
From: SJM - Flash [EMAIL PROTECTED]
To: Flash Coders List flashcoders@chattyfig.figleaf.com
Sent: Tuesday, April 29, 2008 2:19 PM
Subject: [Flashcoders] (AS3) Object to an Array


Hi Guys

Im in need of finding out how or even if its possible to convert an
object to an array?

Basically I am trying to output some vars from flash to an PHP script,
yet when PHP recieves the $_POST['textVars'] as [object 
Object] which is a string and not an array so I can't access it with
$_POST['textVars'][0]['x'], which should output the value of 
textBox1.x.

var textVars:Object = new Object;

textVars[0] = {
 x  :textBox1.x,
 y  :textBox1.y,
 width  :textBox1.width,
 height  :textBox1.height,
 rotation :textBox1.rotation
};

textVars[1] = {
 x  :textBox2.x,
 y  :textBox2.y,
 width  :textBox2.width,
 height  :textBox2.height,
 rotation :textBox2.rotation
};

sendVars.textVars = textVars;

sendRequest.data = setVars;
sendRequest.url = process.php;
sendRequest.method = URLRequestMethod.POST;
sendToURL(sendRequest);

Thanks
SM
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] (AS3) Object to an Array

2008-04-29 Thread SJM - Flash
Hey Glen thanks for your speedy response its much appriciated! Ive tried the 
code you provided but am still getting the same output.

   var textVars = new Array();
   
   textVars[0] = {
a   :0,
b   :1,
c   :2
   };
   textVars[1] = {
d   :3,
e   :4,
f   :5
   };
   
   var numVars:int = textVars.length;
   for(var i:int = 0;i  numVars;i++)
   {
  var obj:Object = textVars[i];
   
  for (var itm:String in obj)
  {
  trace(itm +  =  + obj[itm]);
  textVars[i][itm] = obj[itm];
  }
   }
   
   
   var sendRequest:URLRequest = new URLRequest(process.php);
   var setVars:URLVariables = new URLVariables();
   
   setVars.textVars = textVars;
  
   sendRequest.data = setVars;
   sendRequest.method = URLRequestMethod.POST;
   
   sendToURL(sendRequest);

Basically we are trying to output a $_POST array that is formated similar to 
below...


Array
(
 [textVars] = Array
  (
   [0] = Array
   (
[a] = 0
[b] = 1
[c] = 2
)

   [1] = Array
   (
[d] = 3
[e] = 4
[f] = 5
   )
  
  )

)

instead we are getting:

Array
(
 [textVars] = [object Object]
)


Thanks
SM
  - Original Message - 
  From: Glen Pike 
  To: Flash Coders List 
  Sent: Tuesday, April 29, 2008 1:43 PM
  Subject: Re: [Flashcoders] (AS3) Object to an Array


  Hi,

  You could create a loop to look through each object and then make up 
  your arrays a bit like this - untested:

  sendVars.textVars = new Array();

  var numVars:int = textVars.length;
  for(var i:int = 0;i  numVars;i++) {
 
 var obj:Object = textVars[i];
 
 for(item:String in obj) {
trace(itm +  =  + obj[itm]);
sendVars.textVars[i][itm] = obj[itm];
 }
  }
  //then send your data...

  SWXFormat handles this sort of thing quite nicely, but they were 
  still working on AS3 when I last looked.

  HTH

  Glen

  SJM - Flash wrote:
   Hi Guys
  
   Im in need of finding out how or even if its possible to convert an object 
to an array?
  
   Basically I am trying to output some vars from flash to an PHP script, yet 
when PHP recieves the $_POST['textVars'] as [object Object] which is a string 
and not an array so I can't access it with $_POST['textVars'][0]['x'], which 
should output the value of textBox1.x.
  
   var textVars:Object = new Object;
  
   textVars[0] = {
x  :textBox1.x,
y  :textBox1.y,
width  :textBox1.width,
height  :textBox1.height,
rotation :textBox1.rotation
   };
  
   textVars[1] = {
x  :textBox2.x,
y  :textBox2.y,
width  :textBox2.width,
height  :textBox2.height,
rotation :textBox2.rotation
   };
  
   sendVars.textVars = textVars;
  
   sendRequest.data = setVars;
   sendRequest.url = process.php;
   sendRequest.method = URLRequestMethod.POST;
   sendToURL(sendRequest);
  
   Thanks
   SM
   ___
   Flashcoders mailing list
   Flashcoders@chattyfig.figleaf.com
   http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
  
  
 

  -- 

  Glen Pike
  01326 218440
  www.glenpike.co.uk http://www.glenpike.co.uk

  ___
  Flashcoders mailing list
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] (AS3) Object to an Array

2008-04-29 Thread SJM - Flash
Unfortunalty we are only testing in PHP, the application is going to be on an 
ASP coded website so we really need to fix this from flash! :o(
  - Original Message - 
  From: Muzak 
  To: Flash Coders List 
  Sent: Tuesday, April 29, 2008 2:09 PM
  Subject: Re: [Flashcoders] (AS3) Object to an Array


  use remoting:
  http://www.amfphp.org/

  - Original Message - 
  From: SJM - Flash [EMAIL PROTECTED]
  To: Flash Coders List flashcoders@chattyfig.figleaf.com
  Sent: Tuesday, April 29, 2008 2:19 PM
  Subject: [Flashcoders] (AS3) Object to an Array


  Hi Guys

  Im in need of finding out how or even if its possible to convert an object to 
an array?

  Basically I am trying to output some vars from flash to an PHP script, yet 
when PHP recieves the $_POST['textVars'] as [object 
  Object] which is a string and not an array so I can't access it with 
$_POST['textVars'][0]['x'], which should output the value of 
  textBox1.x.

  var textVars:Object = new Object;

  textVars[0] = {
   x  :textBox1.x,
   y  :textBox1.y,
   width  :textBox1.width,
   height  :textBox1.height,
   rotation :textBox1.rotation
  };

  textVars[1] = {
   x  :textBox2.x,
   y  :textBox2.y,
   width  :textBox2.width,
   height  :textBox2.height,
   rotation :textBox2.rotation
  };

  sendVars.textVars = textVars;

  sendRequest.data = setVars;
  sendRequest.url = process.php;
  sendRequest.method = URLRequestMethod.POST;
  sendToURL(sendRequest);

  Thanks
  SM
  ___
  Flashcoders mailing list
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

  ___
  Flashcoders mailing list
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] (AS3) Object to an Array

2008-04-29 Thread Glen Pike

Hi,

   This may be a formatting thing with how you post arrays and my 
answer may need revising:


   Look in the PHP manual for Variables from outside PHP and see that 
you can post arrays from HTML forms, by having the fields named as an 
array..


   so my original code below is a bit wrong, sorry.

   The loop will have to build the pseudo array for each text var 
object so you can post textVars[0][a]=0textVars[0][b]=1, etc.:


   setVars = new Object();

textVars[0] = {
   a   :0,
   b   :1,
   c   :2
  };
  textVars[1] = {
   d   :3,
   e   :4,
   f   :5
  };
  
  var numVars:int = textVars.length;

  for(var i:int = 0;i  numVars;i++)
  {
 var obj:Object = textVars[i];
  
 for (var itm:String in obj)

 {
trace(itm +  =  + obj[itm]);
//check the quotes and braces carefully, but basically you want to end up 
with setVars.textVars[0][a] = 0, etc
setVars[textVars[ + i + ][ + itm + ]] = obj[itm];
 }
  }

I think that may fix it...

You probably also want to make sure your PHP script is behaving by temporarily changing 
$_POST to $_REQUEST then writing a manual query string as above...

HTH

Glen


SJM - Flash wrote:

Hey Glen thanks for your speedy response its much appriciated! Ive tried the 
code you provided but am still getting the same output.

   var textVars = new Array();
   
   textVars[0] = {

a   :0,
b   :1,
c   :2
   };
   textVars[1] = {
d   :3,
e   :4,
f   :5
   };
   
   var numVars:int = textVars.length;

   for(var i:int = 0;i  numVars;i++)
   {
  var obj:Object = textVars[i];
   
  for (var itm:String in obj)

  {
  trace(itm +  =  + obj[itm]);
  textVars[i][itm] = obj[itm];
  }
   }
   
   
   var sendRequest:URLRequest = new URLRequest(process.php);

   var setVars:URLVariables = new URLVariables();
   
   setVars.textVars = textVars;
  
   sendRequest.data = setVars;

   sendRequest.method = URLRequestMethod.POST;
   
   sendToURL(sendRequest);


Basically we are trying to output a $_POST array that is formated similar to 
below...


Array
(
 [textVars] = Array
  (
   [0] = Array
   (
[a] = 0
[b] = 1
[c] = 2
)

   [1] = Array

   (
[d] = 3
[e] = 4
[f] = 5
   )
  
  )

)

instead we are getting:

Array

(
 [textVars] = [object Object]
)


Thanks

SM
  - Original Message - 
  From: Glen Pike 
  To: Flash Coders List 
  Sent: Tuesday, April 29, 2008 1:43 PM

  Subject: Re: [Flashcoders] (AS3) Object to an Array


  Hi,

  You could create a loop to look through each object and then make up 
  your arrays a bit like this - untested:


  sendVars.textVars = new Array();

  var numVars:int = textVars.length;
  for(var i:int = 0;i  numVars;i++) {
 
 var obj:Object = textVars[i];
 
 for(item:String in obj) {

trace(itm +  =  + obj[itm]);
sendVars.textVars[i][itm] = obj[itm];
 }
  }
  //then send your data...

  SWXFormat handles this sort of thing quite nicely, but they were 
  still working on AS3 when I last looked.


  HTH

  Glen

  SJM - Flash wrote:
   Hi Guys
  
   Im in need of finding out how or even if its possible to convert an object 
to an array?
  
   Basically I am trying to output some vars from flash to an PHP script, yet 
when PHP recieves the $_POST['textVars'] as [object Object] which is a string and 
not an array so I can't access it with $_POST['textVars'][0]['x'], which should 
output the value of textBox1.x.
  
   var textVars:Object = new Object;
  
   textVars[0] = {
x  :textBox1.x,
y  :textBox1.y,
width  :textBox1.width,
height  :textBox1.height,
rotation :textBox1.rotation
   };
  
   textVars[1] = {
x  :textBox2.x,
y  :textBox2.y,
width  :textBox2.width,
height  :textBox2.height,
rotation :textBox2.rotation

Re: [Flashcoders] (AS3) Object to an Array

2008-04-29 Thread Juan Pablo Califano
You can also use JSON, a format close to javascript syntax, used for
serializing / deserializing objects. It's rather standard and you can find
libraries for parsing it in most mainstream languages (including, of course,
AS 2.0  AS 3.0, and PHP)


Cheers
Juan Pablo Califano



2008/4/29, SJM - Flash [EMAIL PROTECTED]:

 Hey Glen thanks for your speedy response its much appriciated! Ive tried
 the code you provided but am still getting the same output.

   var textVars = new Array();

   textVars[0] = {
a   :0,
b   :1,
c   :2
   };
   textVars[1] = {
d   :3,
e   :4,
f   :5
   };

   var numVars:int = textVars.length;
   for(var i:int = 0;i  numVars;i++)
   {
  var obj:Object = textVars[i];

  for (var itm:String in obj)
  {
  trace(itm +  =  + obj[itm]);
  textVars[i][itm] = obj[itm];
  }
   }


   var sendRequest:URLRequest = new URLRequest(process.php);
   var setVars:URLVariables = new URLVariables();

   setVars.textVars = textVars;

   sendRequest.data = setVars;
   sendRequest.method = URLRequestMethod.POST;

   sendToURL(sendRequest);

 Basically we are trying to output a $_POST array that is formated similar
 to below...


Array
(
 [textVars] = Array
  (
   [0] = Array
   (
[a] = 0
[b] = 1
[c] = 2
)

   [1] = Array
   (
[d] = 3
[e] = 4
[f] = 5
   )

  )

)

 instead we are getting:

Array
(
 [textVars] = [object Object]
)


 Thanks
 SM
 - Original Message -
 From: Glen Pike
 To: Flash Coders List
 Sent: Tuesday, April 29, 2008 1:43 PM
 Subject: Re: [Flashcoders] (AS3) Object to an Array


 Hi,

  You could create a loop to look through each object and then make up
 your arrays a bit like this - untested:

  sendVars.textVars = new Array();

  var numVars:int = textVars.length;
  for(var i:int = 0;i  numVars;i++) {

 var obj:Object = textVars[i];

 for(item:String in obj) {
trace(itm +  =  + obj[itm]);
sendVars.textVars[i][itm] = obj[itm];
 }
  }
  //then send your data...

  SWXFormat handles this sort of thing quite nicely, but they were
 still working on AS3 when I last looked.

  HTH

  Glen

 SJM - Flash wrote:
  Hi Guys
 
  Im in need of finding out how or even if its possible to convert an
 object to an array?
 
  Basically I am trying to output some vars from flash to an PHP script,
 yet when PHP recieves the $_POST['textVars'] as [object Object] which is a
 string and not an array so I can't access it with
 $_POST['textVars'][0]['x'], which should output the value of textBox1.x.
 
  var textVars:Object = new Object;
 
  textVars[0] = {
   x  :textBox1.x,
   y  :textBox1.y,
   width  :textBox1.width,
   height  :textBox1.height,
   rotation :textBox1.rotation
  };
 
  textVars[1] = {
   x  :textBox2.x,
   y  :textBox2.y,
   width  :textBox2.width,
   height  :textBox2.height,
   rotation :textBox2.rotation
  };
 
  sendVars.textVars = textVars;
 
  sendRequest.data = setVars;
  sendRequest.url = process.php;
  sendRequest.method = URLRequestMethod.POST;
  sendToURL(sendRequest);
 
  Thanks
  SM
  ___
  Flashcoders mailing list
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
 
 
 

 --

 Glen Pike
 01326 218440
 www.glenpike.co.uk http://www.glenpike.co.uk

 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] (AS3) Object to an Array

2008-04-29 Thread Muzak

ASP .NET ?

use remoting ;-)
http://www.themidnightcoders.com/weborb/dotnet/

- Original Message - 
From: SJM - Flash [EMAIL PROTECTED]

To: Flash Coders List flashcoders@chattyfig.figleaf.com
Sent: Tuesday, April 29, 2008 3:52 PM
Subject: Re: [Flashcoders] (AS3) Object to an Array


Unfortunalty we are only testing in PHP, the application is going to be on an ASP coded website so we really need to fix this from 
flash! :o(
 - Original Message - 
 From: Muzak

 To: Flash Coders List
 Sent: Tuesday, April 29, 2008 2:09 PM
 Subject: Re: [Flashcoders] (AS3) Object to an Array


 use remoting:
 http://www.amfphp.org/


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] (AS3) Object to an Array

2008-04-29 Thread SJM - Flash
Thanks for your help guys i went down the JSON route and won! :o)


  - Original Message - 
  From: Muzak 
  To: Flash Coders List 
  Sent: Tuesday, April 29, 2008 3:35 PM
  Subject: Re: [Flashcoders] (AS3) Object to an Array


  ASP .NET ?

  use remoting ;-)
  http://www.themidnightcoders.com/weborb/dotnet/

  - Original Message - 
  From: SJM - Flash [EMAIL PROTECTED]
  To: Flash Coders List flashcoders@chattyfig.figleaf.com
  Sent: Tuesday, April 29, 2008 3:52 PM
  Subject: Re: [Flashcoders] (AS3) Object to an Array


  Unfortunalty we are only testing in PHP, the application is going to be on an 
ASP coded website so we really need to fix this from 
  flash! :o(
- Original Message - 
From: Muzak
To: Flash Coders List
Sent: Tuesday, April 29, 2008 2:09 PM
Subject: Re: [Flashcoders] (AS3) Object to an Array


use remoting:
http://www.amfphp.org/


  ___
  Flashcoders mailing list
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders