[flexcoders] Implementing a CheckBox array..

2007-04-14 Thread tommyhaych
I posted this as a reply in one of my other questions, so I apologize in
advance if I appear to be spamming things. I've modified the question,
anyway.

--


Hey all.. I just have a question about forms in FLEX 2:

I've got a repeater populated by a list of musicians taken from an XML
file. Each artist is represented by a checkbox and when a submit button
is clicked, I want that array to be sent over to a php script.

This is the vbox containing the artist info and checkbox:


mx:VBox
mx:Text text={artistRepeat.currentItem.name} /
mx:Image source =
{artistRepeat.currentItem.image} scaleContent=true /



mx:CheckBox data={artistRepeat.currentItem.name} id=cBox
click=modifyArray(Object) /
mx:Text text={cBox.data} /

/mx:VBox


And the function for handling this is:



   public function modifyArray(item:Object):String{
 if(cBox.data != null){
 return artistlist.text;

 }
 return artistlist.text = (artist = +cBox.data+);;


 }


This registers the artist as 'undefined'. Am I going the right direction
here?


Thanks,
Tom.



Again, i'm sorry if im being repetitive here.





[flexcoders] Re: Default Decoder could not decode result?

2007-04-13 Thread tommyhaych
--- In [EMAIL PROTECTED], tommyhaych [EMAIL PROTECTED] wrote:

 Ooo you helped! The php address made me realise something - I
 wasn't running this on my localhost. 
 
 It's adding something to the database!!! 
 
 Just a cheeky question now - am I going the right direction with that
 checkbox array? I think i've just pasted random things in there hoping
 it would work!
 
 Thanks a lot!
 
 Tom H


.. I'll build on that more...

If my checkbox for each band was called 'cBox' and the information I
wanted to pass on was found in the label, would I be assuming the
following code is the right direction?:

public function modifyArray(item:Object):String{
if(cBox.Label != null){
return cBox.label;
}

return (artist = +cBox.label+);;
}

Basically, when I click the checkbox, it adds/removes it from this ^
array. (code - cBox click=modifyArray(artist))

Just wondering if i'm doing the right thing here to acheive what I
want (being able to pass it on via HTTPService).

Annnyway. Thanks for the help so far!

Tom
x





[flexcoders] Default Decoder could not decode result?

2007-04-12 Thread tommyhaych
Hi all,

I'm having some major trouble with FLEX at the moment, even more so
since it's for university!

Anyway:

Basically, what I'm doing is using this XML:
http://ws.audioscrobbler.com/1.0/user/tommyhaych/topartists.xml and
displaying the top 10 artists in a repeater. Each artist is
represented by a checkbox and added to an array when ticked. 

That array is eventually sent to a php file for subsequent decoding.

For the last few days however, when I try submitting that array, I get
this:


==

[RPC Fault faultString=Default decoder could not decode result
faultCode=Client.CouldNotDecode faultDetail=null]

..which is really hard to understand what I'm doing wrong. 

I'll post my code anyway and hopefully someone might see whats going
here...

?xml version=1.0 encoding=utf-8?
mx:Application xmlns:mx=http://www.adobe.com/2006/mxml;
layout=absolute 
creationComplete=lastListened.send();
viewSourceURL=srcview/index.html


mx:Script
![CDATA[

import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;



[Bindable]
private var tracks:ArrayCollection = new ArrayCollection();

[Bindable]
 private var artistList:ArrayCollection;


  
private function trackRPCResult (event:ResultEvent):void{
tracks = event.result.topartists.artist;

}

   public function modifyArray(item:Object):String{
if(cBox.data != null){
return cBox.data;
}

return cBox.data+  ( artist = +cBox.data+);;
}

   
]]

/mx:Script
mx:HTTPService id=lastListened
   
url=http://ws.audioscrobbler.com/1.0/user/tommyhaych/topartists.xml;
result=trackRPCResult(event)
/

mx:HTTPService id=addArtist url=php/addArtist.php
useProxy=false method=POST


 mx:request xmlns=


band
{cBox.data}
/band
  

 /mx:request
 
 /mx:HTTPService

mx:ApplicationControlBar x=0 y=0 dock=true width=100%
height=90

  mx:Form
mx:FormItem label = Last.Fm Username: direction=vertical
mx:TextInput id=lastfm /
mx:Button label=Get Artists! 
click=this.currentState='artists' /

/mx:FormItem
 /mx:Form
   /mx:ApplicationControlBar

mx:states
mx:State name=artists
 mx:AddChild position=lastChild
 
 
 
mx:HBox width=100% height=100% id=bodyBox
bottom=0 horizontalCenter=0
 
 mx:VBox width=100 height=100% /
 mx:VBox width=90% height=100% id=artists x=4
y=82   
mx:Tile
mx:Repeater id=artistRepeat
dataProvider={tracks} count=10
 mx:VBox  
   mx:Text text={artistRepeat.currentItem.name}  /
   mx:Image source =
{artistRepeat.currentItem.image}  scaleContent=true / 
  

 
   mx:CheckBox
data={artistRepeat.currentItem.name} id=cBox
click=modifyArray(Object) /
  
  
  /mx:VBox
  
  
/mx:Repeater  
   
mx:Button label=SUBMIT id=submit width=140
height=75 click={addArtist.send();} /

   
 /mx:Tile   
  /mx:VBox
   mx:VBox height=100% width=20% id=cartBox
backgroundColor=#80 backgroundAlpha=0.08
   mx:HBox

mx:VBox height=100% 
   
/mx:VBox  
/mx:HBox

/mx:VBox
  /mx:HBox
 /mx:AddChild
/mx:State
/mx:states
/mx:Application

=

I'm very new to FLEX so I'm panicking like hell!

Could anyone pleeaassseee shed some light on this?

It would be a very big help!

Thanks,

Tom Harding




[flexcoders] Re: Default Decoder could not decode result?

2007-04-12 Thread tommyhaych
Ooo you helped! The php address made me realise something - I
wasn't running this on my localhost. 

It's adding something to the database!!! 

Just a cheeky question now - am I going the right direction with that
checkbox array? I think i've just pasted random things in there hoping
it would work!

Thanks a lot!

Tom H