首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Flex + SOAP webservice延迟了组件更新

Flex + SOAP webservice延迟了组件更新
EN

Stack Overflow用户
提问于 2009-06-24 12:19:27
回答 1查看 1K关注 0票数 0

我的flex项目有以下mxml文件:

代码语言:javascript
复制
<?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>

因此,我使用Java创建了一个虚拟web服务,它在tomcat上运行。使用wsdl文件的url,我在此项目中为web服务生成了actionscript类。

现在我调用web服务的一个方法(registerSearchSet(1)),它返回一个数字。目前它只返回1234。

启动应用程序后,面板的标题显示为"Mxml title“,大约两分钟后更改为"1234”。

对延迟的原因有什么见解吗?有没有更好的方法让我这样做呢?

更新:现在看来,该小组的标题正在立即更新,不再有延迟。这很奇怪,因为我没有更改代码,我刚刚关闭了flex builder几个小时!

我仍然对使用SOAP、Flex和tomcat时的最佳实践感兴趣。

谢谢。

EN

回答 1

Stack Overflow用户

发布于 2009-06-24 15:56:54

出于好奇,您为什么要像这样在enterFrame上手动调度更新完成事件?我没有你的整个应用程序的运行样本,所以我不能确定它是否与你正在经历的行为本身有关,但在我看来,这似乎不太对劲。当您删除该属性时,Web服务调用会发生什么?

此外,您是否尝试过在结果处理程序上设置断点,或者甚至使用其中的跟踪语句来查看结果实际返回的时间,以确定延迟是在网络中断发生之前还是之后发生的?

您需要做的是隔离延迟发生的位置--请求之前、请求期间或请求之后--然后从那里开始。当这一切发生的时候,你的CPU发生了什么?你在跑步的时候有没有注意到一个尖峰?WebService调用的工作方式并没有什么真正的魔力,所以在您的机器上、服务器上,或者在您编写的代码中,或者在项目中的其他地方使用的代码中,一定有什么东西在运行。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1038016

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档