开发者

flex: relative sizing and performance

开发者 https://www.devze.com 2023-03-05 16:19 出处:网络
We are building a flex project and would like it to render faster. We do have situations where we reference parent module size properties to size current module containers, as well as current module s

We are building a flex project and would like it to render faster. We do have situations where we reference parent module size properties to size current module containers, as well as current module size properties for a bunch of attributes including font size and element positions and sizes.

Would it help to create temporary variables for a) pcw=parentcontainer.width, pch= parentcontainer.height b) ccw=currentcontainer.width, cch=currentcontainer.height

and refe开发者_开发知识库rence to pcw,pch,ccw and cch while doing positioning. Will that help?

Also given the bulk of the positioning will be done in mxml, will setting these interim variables in initialization function, allow them to be used in mxml such that they will resize as browser size is changed. Thanks for pointers


I'm not sure if you're using the term "Module" a a generic term to refer to a component, or if you are explicitly referring to classes of the Module class.

It breaks encapsulation if a container is aware of it's parents. In Flex, a parent is always responsible for sizing it's children; and a child should never size itself.

You had code like this to access the parent's height and width:

pcw=parentcontainer.width
parentcontainer.height

I can't imagine how saving the parent's height and width values would speed anything up.

I also find it hard to envision a situation where knowing the parent container's width and height is helpful. Often a container has more than one children. It is important to know how much size a component has for laying out it's own children, not how much space the parent has.

The appropriate way to size and position a component's children is to override updateDisplayList(). updateDisplayList() has two parameters: unscaledWidth and unscaledHeight; that is, in essence, the height and width of the component. You should size and position the component's children based on those two values.

Of course, doing so often relies on ActionScript; not MXML.

Your primary question seemed to want to improve performance. There are many factors involved in the performance of an app. Using ActionScript for layout instead of MXML could be one factor that may help improve performance. Minimize your use on binding is another thing that can sometimes help performance.

Have you used the Flex Profiler? Have you stepped through code? Does doing these things help you determine what exactly the performance issue is?


Unless your application changes it's shape a lot, there shouldn't be any problems laying out with Flex if you use proper skinning/component/layout standards.

Most of the problem isn't from Flex, but the code most people add onto their own application that renders the whole system slow. Make sure you brush up on Flash performance improvements (like data structures, limiting binding, proper architecture, object lifecycle, etc).

0

精彩评论

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