PDA

View Full Version : How to populate a comboBox with AS 3.0 in flex


ryosaeb4
02-10-2009, 03:43 PM
Dear Actionscript.org friends


I've try to make this comboBox where I try to populate it with a HTTPService calling


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init(event)">

<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
import mx.collections.ArrayCollection;
import mx.events.FlexEvent;


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

//private static var urlBase: String = new String(ConfigUrl.getInstance().dataProvider) + "Service.asmx/GetAllApps";
private var urlBase:String = "assets/prova.xml";

private function init(evt:FlexEvent):void{
unitRPC.url = urlBase;
unitRPC.resultFormat = "e4x";
unitRPC.send()
}


//Array per popolare la ComboBox di selezione viste per applicazione
public function unitRPCResult(event:ResultEvent):void
{
units=event.result.itemCollection.item;
comboBOXX.dataProvider = units;
}

]]>
</mx:Script>

<mx:HTTPService id="unitRPC" result="unitRPCResult(event)"/>
<mx:ComboBox id="comboBOXX" y="28" right="169"/>

</mx:Application>



I've debug it but the comboBox is not populate and I've this error



[SWF] Users:walterfantauzzi:Documents:Flex Builder 3:ProvaComboBox:bin-debug:ProvaComboBox.swf - 1,014,624 bytes after decompression
*** Security Sandbox Violation ***
Connection to assets/prova.xml halted - not permitted from file://localhost/Users/walterfantauzzi/Documents/Flex Builder 3/ProvaComboBox/bin-debug/ProvaComboBox.swf


WHY?

Peter Cowling
02-11-2009, 02:49 PM
Looking only at the error message, my initial response would be: is this a crossdomain.xml file issue?

ryosaeb4
02-11-2009, 06:22 PM
No the crossdomani.xml is on my server...

Peter Cowling
02-11-2009, 06:46 PM
Okay, looking at the relative url you use, you are going to have a problem when testing. To overcome this problem, use an absolute URL or follow this approach:

In Eclipse, go to Project Properties and select the Flex Compiler. Add -use-network=false to the "additional compiler options".

OR, If using the command line compiler, add -use-network=false to your build command.

Note that this will prevent you from accessing network resources.

ryosaeb4
02-11-2009, 06:55 PM
wow now it work good Peter!!!!

:D