如何延迟绘制屏幕组件直到 HttpService 响应回调返回?

发布于 2024-11-11 20:48:24 字数 747 浏览 9 评论 0原文

我有一个组屏幕组件,里面有一些路径元素。组具有(默认)样式,路径具有(默认)描边。当程序启动时,(在初始化时)从服务器(通过 HTTPService)加载一些数据,其中包括组的不同样式,并且还可能包括路径描边的不同颜色/宽度。如果样式/描边属性未包含在服务器响应中,则组件将以默认值显示。

<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"/>
    </s:stroke>
  </s:Path> 
.....
.....
.....
</s:Group> 

问题是,当服务器返回不同的样式/笔划时,应用程序首先在屏幕上显示默认值,然后在 HttpService 返回后刷新最终屏幕。

我阅读了有关组件生命周期的内容,但很难弄清楚应该如何编码该逻辑。是否应该包含 CallLater 以延迟屏幕更新?是否应该在 HTTPService 回调函数结束后才创建组件?

谢谢 彼得

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"/>
    </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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

_失温 2024-11-18 20:48:24

我认为您应该在 HTTPService 响应后添加该组件。
因此,如果您有这样的代码:

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

那么显示组件的代码应该位于 resultHandler() 中,或者此函数应该调用显示组件的代码

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文