相当于什么?在伟创力?

发布于 2024-12-23 17:53:41 字数 240 浏览 1 评论 0原文

我是一名长期的 CF 开发人员,正在尝试使用 Flash Builder 进行 Flex 移动开发,但在尝试从简单的数据库查询输出结果时我感到很沮丧。

我想做一些类似的事情......

<cfoutput query="myQ">
  <s:Button label="#title#" click="myFunction(#id#)">
</cfoutput>

I'm a longtime CF developer that is trying to get into to Flex mobile development with Flash Builder but I've become frustrated in trying to output results from a simple database query.

I'm looking to do something along the lines of this...

<cfoutput query="myQ">
  <s:Button label="#title#" click="myFunction(#id#)">
</cfoutput>

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

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

发布评论

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

评论(1

沧桑㈠ 2024-12-30 17:53:41

您将最适合使用基于列表的类和 itemRenderer。概念上是这样的:

<sList dataProvider="myQ">
 <s:itemRenderer>
  <fx:Component>
    <s:ItemRenderer dataChange="onDataChange(event)">
     <fx:Script>
         protected function onDataChange(event:FlexEvent):void{
            myButton.label = data.title;
         }
         protected function myFunction(event:MouseEvent):void{
           // access the ID using data.id
         }
     </fx:Script>
     <s:Button id="myButton" click="myFunction(event)" />
    <s:ItemRenderer>
  </fx:Component>
 </s:itemRenderer>

</s:List>

这段代码是在浏览器中编写的;所以它可能并不完美,但应该给你一个近似值。要了解基于列表的类,您应该研究渲染器在 Flex 中的工作原理;特别是渲染器回收。

如果我们要创建一个像您所显示的那样的循环,那么如果循环中有 100 个项目,100 个按钮可能会导致性能问题。相反,我们使用列表和渲染器。仅渲染屏幕上显示的项目。当您滚动列表时,其他项目会在滚动到视图中时呈现;并且不再渲染滚出视图的项目。因此,屏幕上实际显示的不是 100 个挂在内存中的对象,而是 10 个左右。这就是为什么我的内联 itemRenderer 监听数据更改事件;因此当数据改变时渲染将会更新。

当您滚动列表时,会将下一个数据项发送到已创建的渲染器中。

我理解需要在您已经理解的上下文中构建事物,但 UI 开发 (Flex) 与服务器端开发 (ColdFusion) 不同;所以你可能会遇到很多差异。这是其中之一。

You're going to be best suited to use a List based class with an itemRenderer. Conceptually like this:

<sList dataProvider="myQ">
 <s:itemRenderer>
  <fx:Component>
    <s:ItemRenderer dataChange="onDataChange(event)">
     <fx:Script>
         protected function onDataChange(event:FlexEvent):void{
            myButton.label = data.title;
         }
         protected function myFunction(event:MouseEvent):void{
           // access the ID using data.id
         }
     </fx:Script>
     <s:Button id="myButton" click="myFunction(event)" />
    <s:ItemRenderer>
  </fx:Component>
 </s:itemRenderer>

</s:List>

This code was written in the browser; so it probably isn't perfect, but should give you an approximation. To understand list based classes, you should research how renderers work in Flex; specifically renderer recycling.

If we were to create a loop like what you have display, then if you had 100 items in the loop, 100 buttons would could cause performance issues. Instead we use lists and renderers. Only the items displayed on screen are rendered. As you scroll through the list, the other items are rendered as they scroll into view; and the items that roll out of view are no longer renderered. So instead of 100 objects hanging out in memory, you have 10 or so that are actually displayed on screen. This is why my in-line itemRenderer listens to the data change event; so the render will update when the data changes.

As you scroll the list will send the next data item into the already created renderer.

I understand the need to frame things in a context you already understand, but UI Development (Flex) is not the same as server side development (ColdFusion); so you'll probably run into a lot of differences. This is one of them.

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