| Member List |
| Posted: 05 Apr 2007 13:45 Last Edited By: tomharding | ||
|
Registered User Currently Offline |
Posts: 26 Join Date: Feb 2007 |
|
|
Hey again,
I'm just wondering how hard it would be to send a checkbox array to a php script via flex? Bascially, I have a repeater which gets the first 10 nodes from this file: http://ws.audioscrobbler.com/1.0/user/tommyhaych/topartists.xml and I want the user select the ones they want(using a checkbox) and then move the artists into a database. Any help would be much appreciated. Thanks, Tom |
||
| Posted: 06 Apr 2007 12:03 Last Edited By: danielneri | ||
|
Administrator Currently Offline |
Posts: 157 Join Date: Oct 2006 |
|
|
tomharding - what you could probably do is have a bunch of checkboxes, and add a click tag to them.
for example: Code:
<mx:CheckBox id="chk1" label="milk" click="modifyArray()"/> Then all the modifyArray() function does is check if the item is already in the array, if yes, remove it, if not, add it
To search arrays take a look at this example - http://labs.flexcoders.nl/?p=53 I'm sure you can figure it out! If you need more help don't hesitate to ask ![]() __________________ ![]() |
||
| Posted: 06 Apr 2007 12:27 | ||
|
Registered User Currently Offline |
Posts: 26 Join Date: Feb 2007 |
|
| Cool stuff.. thanks for the reply! | ||
| Posted: 08 Apr 2007 12:21 Last Edited By: tomharding | ||
|
Registered User Currently Offline |
Posts: 26 Join Date: Feb 2007 |
|
|
Hey dude, sorry to bother you again,
I assume you mean this code: Code:
public function labelFunction(item:Object):String{ if(item.title != null){ return item.title; } return item.name+ " ( id = "+item.id+" ";;
} ..I've implemented that, but I get an error now which says "Incorrect number of arguments, expected 1" Also, while I'm here - do you perchance know what this error means: Code:
[RPC Fault faultString="Default decoder could not decode result" faultCode="Client.CouldNotDecode" faultDetail="null"] ..This happens when I press my submit button. I tried this with both a normal text form and with the checkboxes and its both the same. Thanks again! Tom
|
||
| Posted: 08 Apr 2007 14:38 | ||
|
Administrator Currently Offline |
Posts: 157 Join Date: Oct 2006 |
|
|
The first error is what happens when you call labelFunction and don't supply the object...
this is the way you have to do it: Code:
click="labelFunction(object)" and replace object with the actual object, not too sure how that works
As far as the second error I recommend using [url=www.getcharles.com]Charles[/url] - An AMAZING http decoder to see whats going on and why you cannot decode the result. __________________ ![]() |
||
| Posted: 10 Apr 2007 14:32 | ||
|
Registered User Currently Offline |
Posts: 26 Join Date: Feb 2007 |
|
Hey again
Charles doesn't want to play, he doesn't give me anything at all when I do anything. Would it be ok if I posted my full code - there must be something i've completely fucked up on and it's making me lose hair.. Code:
<?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+" ";;
} /* private function trackRPCResult (event:ResultEvent):void{ var prodArray:Array = new Array(); for each (var p:XML in event.result.topartists.artist){ var prod:Product = new Product ( String(p.@name), String(p.@thumbnail)); prodArray.push(prod); } artistList=new ArrayCollection(prodArray); } */ ]]> </mx:Script> <mx:HTTPService id="addArtist" url="php/addArtist.php" useProxy="false" method="POST"> <mx:request xmlns=""> <band> {cBox.data} </band> </mx:request> </mx:HTTPService> <mx:HTTPService id="lastListened" url="http://ws.audioscrobbler.com/1.0/user/tommyhaych/topartists.xml" result="trackRPCResult(event)" /> <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="#800000" 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> Thanks. and sorry YET AGAIN to bother you
|
||
| Posted: 12 Apr 2007 16:57 | ||
|
Administrator Currently Offline |
Posts: 157 Join Date: Oct 2006 |
|
|
tom - The best way to figure out whats going on is to use some program like Charles.
Did you try using different browsers with Charles? __________________ ![]() |
||
| Posted: 12 Apr 2007 18:58 | ||
|
Registered User Currently Offline |
Posts: 26 Join Date: Feb 2007 |
|
Never mind dude, i sorted it out
The error is posted in the flex forum now. Thanks again man
|
||
| Posted: 13 Apr 2007 17:48 | ||
|
Administrator Currently Offline |
Posts: 157 Join Date: Oct 2006 |
|
|
What was the problem?
Sorry I couldn't help you, I've been swamped with stuff to do!!! I was going to tell you to go ahead and try the Flex forum over at Adobe or the flexcoders mailing list or something... Glad you found the problem and sorted it out though ![]() __________________ ![]() |
||
| Posted: 14 Apr 2007 06:02 | ||
|
Registered User Currently Offline |
Posts: 26 Join Date: Feb 2007 |
|
|
I realised that the php form i was using wasnt on my localhost. Such a simple problem backed up by an extremely vague error message.
A simple "The source you are sending this to isn't valid" would have been a much nicer error message. Tch! Bloody Adobe! Anyway, my next problem is that checkbox array, but i'll try and sort that one out. Tough stuff. |
||
| Posted: 14 Apr 2007 11:17 | ||
|
Administrator Currently Offline |
Posts: 157 Join Date: Oct 2006 |
|
|
Oh I see. Glad you fixed it though!
I too have had some really annoying error messages like those pop up ![]() __________________ ![]() |
||