My flex project has the following mxml file:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:coverflow="com.dougmccune.coverflow.*"
layout="vertical" horizontalAlign="center" verticalAlign="middle"
viewSourceURL="srcview/index.html" xmlns:containers="com.dougmccune.containers.*" xmlns:ns1="com.blitzagency.xray.logger.*"
creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.events.FlexEvent;
import generated.webservices.*;
[Bindable]
public var numResults: int = 0;
private function init() : void
{
var service:ICarouselService = new CarouselService();
service.addregisterSearchSetEventListener(registerSearchSetListener);
// library_id
service.registerSearchSet(1);
}
private function registerSearchSetListener(event:RegisterSearchSetResultEvent):void
{
var searchData:SearchMetaData = event.result;
numResults = searchData.noOfResults;
if(testpanel != null)
{
testpanel.title = "" + numResults;
}
//customerItem = new CustomerItem(custData.customerName, custData.customerLogo);
//g.add(customerItem);
}
]]>
</mx:Script>
<mx:Style>
Panel {
borderColor: #99CDEE;
borderAlpha: 1;
borderThickness: 1;
borderThicknessLeft: 1;
borderThicknessTop: 0;
borderThicknessBottom: 1;
borderThicknessRight: 1;
roundedBottomCorners: false;
cornerRadius: 5;
headerColors: #b5e6f3, #81b3e6;
dropShadowEnabled: false;
titleStyleName: "mypanelTitle";
vertical-align:middle;
horizontal-align:center;
}
.mypanelTitle {
letterSpacing: 1;
color: #333333;
fontSize: 12;
fontWeight: bold;
}
</mx:Style>
<mx:VBox id="box" verticalGap="0" height="306" width="100%" maxWidth="600" maxHeight="300" >
<containers:CoverFlowContainer id="coverflow" width="100%" height="244"
horizontalGap="40" borderStyle="inset" backgroundColor="0x000000"
segments="6" reflectionEnabled="true">
<mx:Panel width="200" height="200" title="ZOMGZ! Look at the 3D!">
<mx:DateChooser width="90%" height="90%"/>
</mx:Panel>
<mx:Panel id="testpanel" width="200" height="200" title="Mxml title">
<mx:DataGrid width="100%" height="100%">
<mx:columns>
<mx:DataGridColumn headerText="Column 1" dataField="col1"/>
<mx:DataGridColumn headerText="Column 2" dataField="col2"/>
<mx:DataGridColumn headerText="Column 3" dataField="col3"/>
</mx:columns>
</mx:DataGrid>
</mx:Panel>
<mx:Panel id="buttonpanel" width="200" height="200" title="Mxml title">
<mx:Button id="myButton" label="Change title" click="buttonpanel.title = ('hello') "/>
</mx:Panel>
<!-- here we're dispatching an UPDATE_COMPLETE event every frame. This is so our PV3D material will
update itself properly for this component, since we want the animation to show correctly.
-->
<mx:Panel width="200" height="200" title="Showing Animation"
enterFrame="event.currentTarget.dispatchEvent(new FlexEvent(FlexEvent.UPDATE_COMPLETE))">
<mx:ProgressBar width="90%" indeterminate="true" trackHeight="30" labelPlacement="center" />
</mx:Panel>
</containers:CoverFlowContainer>
<mx:Grid width="100%">
<mx:GridRow width="100%" height="100%">
<mx:GridItem width="33%" height="100%" horizontalAlign="left">
<mx:Text text="1" id="textLeft"/>
</mx:GridItem>
<mx:GridItem width="33%" height="100%" horizontalAlign="center">
<mx:Text text="{coverflow.selectedIndex + 1}" id="textCenter"/>
</mx:GridItem>
<mx:GridItem width="33%" height="100%" horizontalAlign="right">
<mx:Text text="{coverflow.numChildren}" id="textRight"/>
</mx:GridItem>
</mx:GridRow>
</mx:Grid>
<mx:HScrollBar id="scrollbar" width="600" pageSize="1" maxScrollPosition="{coverflow.numChildren - 1}"
scrollPosition="{coverflow.selectedIndex}"
scroll="coverflow.selectedIndex = Math.round(scrollbar.scrollPosition)" />
<mx:HBox width="100%">
<mx:Text text="Text" textAlign="left"/>
<mx:Spacer width="100%"/>
<mx:Text text="Text" textAlign="center"/>
<mx:Spacer width="100%"/>
<mx:Text text="Text" textAlign="right"/>
</mx:HBox>
</mx:VBox>
</mx:Application>
So I've created a dummy web service using Java and it is running on tomcat. Using the wsdl file's url I generated the actionscript classes in this project for the web service.
Now I'm calling one of the web service's methods (registerSearchSet(1)) which returns a number. At the moment it just returns 1234.
After launching the application the panel's title says "Mxml title" and then after about two minutes it changes to "1234".
Any insights into why there is a delay? Is there a better way I should be doing this?
UPDATE: It seems now that the panel's title is being updated straight away there is no delay anymore. This is strange as I haven't changed the code, I have just closed flex builder for a few hours!
I would still be interested in hearing about best practises when using SOAP, Flex and tomcat.
Thanks.