PDA

View Full Version : Can i use multiple HTTPService in one flex application?



dimiorla
February 21st, 2009, 04:28 PM
Hey everyone,

Can i use multiple HTTPService in one flex application?
I have tried the following but it can have only one creationComplete= " "
Is their any work around?

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="1024" height="800" backgroundColor="white" creationComplete= "menu.send()">

<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
[Bindable]
private var menuarray:ArrayCollection;
private function menuhandler (event:ResultEvent):void
{
menuarray=event.result.response.data.row;
}
[Bindable]
private var ordersarray:ArrayCollection;
private function ordershandler (event:ResultEvent):void
{
ordersarray=event.result.response.data.row;
}
]]>
</mx:Script>

<mx:HTTPService id="menu" url="http://localhost/kassa/menu.php?method=FindAll" result="menuhandler(event)" />
<mx:HTTPService id="orders" url="http://localhost/kassa/orders.php?method=FindAll" result="ordershandler(event)" />

<mx:DataGrid y="68.95" editable="false" enabled="true" width="490" height="682.05" fontFamily="Times New Roman" fontSize="25" id="menudataGrid" dataProvider="{menuarray}" left="10">
<mx:columns>
mx:DataGridColumn headerText="id" dataField="id" width="50"/>
<mx:DataGridColumn headerText="name" dataField="name" />
<mx:DataGridColumn headerText="price" dataField="price" width="100"/>
</mx:columns>
</mx:DataGrid>

<mx:DataGrid y="68.95" width="490" height="392.05" id="ordersdataGrid" dataProvider="{ordersarray}" fontFamily="Times New Roman" fontSize="25" editable="false" enabled="true" right="10">
<mx:columns>
<mx:DataGridColumn headerText="id" dataField="id" width="50"/>
<mx:DataGridColumn headerText="name" dataField="name" />
<mx:DataGridColumn headerText="price" dataField="price" width="100"/>
</mx:columns>
</mx:DataGrid>

</mx:Application>

dimiorla
February 22nd, 2009, 05:53 AM
Hoi everyone,

Someone might find this interesting.
The solutiotion is

Cal a init function by creationComplete:

creationComplete= "init()"

and in the script:

private function init():void
{
menu.send();
orders.send();
}


With a big thanks to eugene_se.

senol
July 24th, 2009, 08:04 AM
xml design may be difficulties in


sample



<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="733" height="300" borderColor="#EDEDED" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #DBDADA]" creationComplete="egtimlerimiz.send()">
<mx:Style>

ApplicationControlBar {
highlightAlphas: 0, 0;
fillAlphas: 1, 0.4;
fillColors: #cccccc, #ffffff;
backgroundColor: #cccccc;
backgroundAlpha: 0.93;
cornerRadius: 6;
dropShadowEnabled: true;
shadowDistance: 2;
shadowDirection: left;
dropShadowColor: #000000;
}
ComboBox {
cornerRadius: 0;
highlightAlphas: 0.6, 0.5;
fillColors: #ffffff, #cccccc, #ffffff, #eeeeee;
arrowButtonWidth: 0;
backgroundAlpha: 1;
openDuration: 600;
closeDuration: 611;
letterSpacing: 2;
dropdownStyleName: "myComboBoxDropDowns";
}


</mx:Style>

<mx:Script>
<![CDATA[



import mx.binding.utils.BindingUtils;

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

[Bindable]
private var xmldata_:ArrayCollection;



private function yol(event:ResultEvent):void{
xmldata_ = event.result.dersler.ders;
xcombo.dataProvider = xmldata_;
xcombo.labelField = "ad";
bannerG.source = "../flex/" + xcombo.selectedItem.banner;
SAAT.text = xcombo.selectedItem.saat;
ozel.text = xcombo.selectedItem.ozel;
Fiyat.text = xcombo.selectedItem.TL;
program.text=xcombo.selectedItem.program;
kisi.text=xcombo.selectedItem.kisi;
uyelik.text=xcombo.selectedItem.uye;

}

private function change_combo():void{

bannerG.source = "../flex/" + xcombo.selectedItem.banner;
SAAT.text = xcombo.selectedItem.saat;
ozel.text = xcombo.selectedItem.ozel;
Fiyat.text = xcombo.selectedItem.TL;
program.text=xcombo.selectedItem.program;
kisi.text=xcombo.selectedItem.kisi;
uyelik.text=xcombo.selectedItem.uye;
}


]]>
</mx:Script>

<mx:HTTPService id="egtimlerimiz" result="yol(event)" url="http://localhost:2005/ozel/egitimler.aspx" />
<mx:Image x="219" y="0" width="514" height="300" id="bannerG" source="../flex/SAP2000.png"/>
<mx:ApplicationControlBar x="10" y="65" width="201" styleName="ApplicationControlBar" height="41">
<mx:ComboBox id="xcombo" width="187" styleName="ComboBox" change="change_combo()"> </mx:ComboBox>
</mx:ApplicationControlBar>
<mx:Label x="208" y="5" width="161" height="52" fontSize="45" color="#FF0000" id="Fiyat" text="300 TL" fontFamily="Georgia" textAlign="left"/>
<mx:Label x="117" y="37" text="54 + X saat" fontSize="12" width="83" fontWeight="bold" id="SAAT"/>
<mx:Label x="10" y="10" text="Tekrar Garanti" width="158" color="#0B193C" fontSize="19"/>
<mx:Label x="351" y="8" text="27 Saatlik Özel Eğitim 1 Kişi 800 TL 2 Kişi 500 TL 3 Kişi 400 TL" color="#FF0000" fontWeight="bold" fontSize="10" id="ozel"/>
<mx:Label x="10" y="114" text="BOL BOL İNDİRİM" width="201" textAlign="center" fontSize="15" color="#D90000" fontWeight="bold"/>
<mx:Text x="10" y="139" text="2 programa birden aynı anda kayıt olanlar için %40 indirim" width="201" height="36" textAlign="center" color="#690060" fontSize="12" id="program"/>
<mx:Text x="10" y="175" text="En az 2 kişi aynı kursa kayıt olanlar için %40 indirim." width="201" height="39" textAlign="center" fontSize="12" id="kisi"/>
<mx:Text x="12" y="210" text="Eski ve yeni üyelerimize %35 indirim yapıyoruz." width="201" height="41" fontSize="12" textAlign="center" color="#690060" id="uyelik"/>
<mx:Button x="11" y="268" label="DETAYLAR" borderColor="#616161" themeColor="#181818" fillAlphas="[1.0, 1.0]" fillColors="[#6A6A6A, #A7A7A7, #ABABAB, #ABABAB]" color="#FFFFFF"/>
<mx:Button x="107" y="268" label="ÜYE OL" borderColor="#616161" themeColor="#181818" fillAlphas="[1.0, 1.0]" fillColors="[#6A6A6A, #A7A7A7, #ABABAB, #ABABAB]" color="#FFFFFF" width="93"/>

</mx:Application>