开发者

How to delay a screen component to be drawn until HttpService response callback returns?

I have a Group screen component with some Path elements inside. The Group has a (default) style, and the Path has a (default) stroke. When the program starts, (on initialize) loads from a server (via HTTPService) some data that includes different styles for the Group, and it may also include different color/width for the Path stroke. If the styles/stroke attributes are not included in the server response, then the component will be shown with the defaults.

<s:Group id="aaa" mouseEnabledWhereTransparent="false" styleName="style1">
    <s:Path x="1218.15" y="268.126" data="M23.6755 80.0898C18.1824 58.54 29.1824 66.8735 23.6755 80.0898Z" >
     <s:stroke>
        <s:SolidColorStroke color="#ff12ae" weight="1" joints="miter" miterLimit="4"/>
    开发者_如何学C</s:stroke>
  </s:Path> 
.....
.....
.....
</s:Group> 

The problem is that when the server returns a different style/stroke, the application first shows the defaults on the screen and after the HttpService returns, it refreshes the final screen.

I read about component life cycle but struggling to figure out exactly how this logic should be coded. Should CallLater be included to delay the screen update? Should the component be created only after the HTTPService callback function ends?

thanks Peter


I think that you should add the component after the HTTPService responded. So if you have something like this:

<mx:HTTPService id="theService" url="http://localhost/bla.php"
  method="GET" resultFormat="text"
  result="resultHandler(event)" fault="faultHandler(event)"/>

then the code that will display the component should be in resultHandler() or this function should call the one that displays the component

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜