[flexcoders] Re: Extending UIComponent memory issues.

2008-10-17 Thread flexaustin
Michael, I have tried using Flexsprite but throws errors about needing
to implementing IUIcomponent. Did I miss something and give up to early?



--- In flexcoders@yahoogroups.com, Michael Schmalle
[EMAIL PROTECTED] wrote:

 Doug, Jason,
 Since I am a self-centered person that doesn't like to be misunderstood,
 ;-), I could have brought up the 4000 object issue. In previous
threads with
 Jason, he said this was a requirement from the higher order. So I
left it
 where it was, 4000 objects.
 
 As far as the IUIComponent issue, it is Container that requires them not
 'Flex' itself.
 
 This is where as flex projects, Web 2.0 and performance are reaching
a point
 where it's not just making a Flash IDE animation anymore.
 
 When the requirements of these projects come to this level there is more
 engineering involved and Flex out of the box is not going to handle
 situations like this.
 
 The absolute way to do this is creating a UIComponent subclass that
is the
 container, creating your layout algorithm in this component. Subclass
 FlexSprite, make that your content loader component.
 
 Then instantiate the content components in the UIComponent
container. This
 is the lean version of your design I envision. You could even
recycle the
 content renderers in your container component Lot's of things
you could
 do ;-)
 
 Mike
 
 
 On Wed, Oct 15, 2008 at 10:47 PM, flexaustin [EMAIL PROTECTED] wrote:
 
Doug, what would you go with? Sprite?
 
  I thought sprite, but you need to implement all the IUIComponent stuff
  or use composition correct? Wouldn't composition reduce the benefits
  gained by using Sprite?
 
  Doug, if you message me and I can tell you where to see the component.
 
  jason (underscore) newport {at) hot mail
 
  --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com,
Doug
  McCune doug@ wrote:
  
   You've got 4,000 things all moving around at once? Are all 4,000 of
  those
   actually visible? 4,000 UI components seems like a lot for any
layout
   manager to have to deal with. I'd try to focus on figuring out how
  to reduce
   the number of UIComponents before I worried about how much memory
  each one
   is taking up. I may be totally off base, but I can't imagine a
scenario
   where you want 4,000 images all on the screen at the same time.
  
   And if you do really need to load 4,000 swfs all at the same time
  then you
   probably want something that's lighter than custom UIComponent
classes,
   which would keep those 4,000 objects out of the normal
   invalidation/validation cycles of the display list.
  
   Doug
  
   On Wed, Oct 15, 2008 at 1:34 PM, Michael Schmalle
   teoti.graphix@wrote:
  
A side note,
You are doing some very expensive leg work in the 'content'
setter.
   
You need to break that out into commitProperties() and
  updateDisplayList().
   
You would get a huge performance increase for sure.
   
As far as the memory, doesn't look to weird, event listeners
  without weak
references can make thing hang around as well.
   
Mike
   
   
On Wed, Oct 15, 2008 at 3:08 PM, flexaustin flexaustin@ wrote:
   
So I have this base component, that when running profiler,
says its
eating up tons of memory. I have about 4000 of these at one
time in
my Flex app (see component code below). This base component is
extended by two other components, which are then extended by
two more
components each so 3 or 4 levels above this base component.
   
1. My first question is does the profiler just point to the base
  class
or are there actually 4000 of these being created outside of
their
extended children?
   
2. My 2nd question is is their anything wrong with the code
  below? Why
is it eatin memory? The parameter content when pulled in is
a swf
file (icon) that is 5kb each so 5kb * 4000... you get the math.
   
When I run this progam the CarouselImage's are using up 30%
to 35% of
my apps memory usage. And my app is eating up 725,000kb of
mem usage,
thus crashing my pretty decent computer.
   
// --- BEGIN CODE --
package com.mysite.views.components
{
   
import flash.display.DisplayObject;
import flash.system.ApplicationDomain;
   
import mx.core.UIComponent;
import mx.events.ResizeEvent;
   
public class CarouselImage extends UIComponent
{
// Content
private var _content:DisplayObject;
private var _contentWidth:Number;
private var _contentHeight:Number;
   
public function CarouselImage(content:*=null)
{
super();
   
// Set content
this.content = content;
}
   
// Properties
[Inspectable]
public function get content():DisplayObject
{
return _content;
}
   
public function set content(value:*):void
{
if (_content != null)
{
removeChild(_content)
removeEventListener(ResizeEvent.RESIZE, handleResize);
}
   
if (value is 

Re: [flexcoders] Re: Extending UIComponent memory issues.

2008-10-17 Thread Michael Schmalle
Jason,
What I suggested is probably a bit to complex for what you need. It's kind
of a reimplementation of what you are doing.

1. Subclass UIComponent to make your container.
2. Create the layout algorithm in that component.
3. Create a subclass of FlexSprite that is your loader component.
4. Add the FlexSprite subclass instances (your content) to your UIComponent
container class with custom layout.
5. Add the UIComponent class to a Container.

The above is not really a solution for you right now I'm sure, I was just
saying this is what I would do to get maximum performance and memory
management.

The reason I say this is I have no idea how you are laying out those
instances with reflection etc. How are you laying them out (with what layout
algorithm) ?

Mike


On Fri, Oct 17, 2008 at 10:21 AM, flexaustin [EMAIL PROTECTED] wrote:

   Michael, I have tried using Flexsprite but throws errors about needing
 to implementing IUIcomponent. Did I miss something and give up to early?

 --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, Michael
 Schmalle

 [EMAIL PROTECTED] wrote:
 
  Doug, Jason,
  Since I am a self-centered person that doesn't like to be misunderstood,
  ;-), I could have brought up the 4000 object issue. In previous
 threads with
  Jason, he said this was a requirement from the higher order. So I
 left it
  where it was, 4000 objects.
 
  As far as the IUIComponent issue, it is Container that requires them not
  'Flex' itself.
 
  This is where as flex projects, Web 2.0 and performance are reaching
 a point
  where it's not just making a Flash IDE animation anymore.
 
  When the requirements of these projects come to this level there is more
  engineering involved and Flex out of the box is not going to handle
  situations like this.
 
  The absolute way to do this is creating a UIComponent subclass that
 is the
  container, creating your layout algorithm in this component. Subclass
  FlexSprite, make that your content loader component.
 
  Then instantiate the content components in the UIComponent
 container. This
  is the lean version of your design I envision. You could even
 recycle the
  content renderers in your container component Lot's of things
 you could
  do ;-)
 
  Mike
 
 
  On Wed, Oct 15, 2008 at 10:47 PM, flexaustin [EMAIL PROTECTED] wrote:
 
   Doug, what would you go with? Sprite?
  
   I thought sprite, but you need to implement all the IUIComponent stuff
   or use composition correct? Wouldn't composition reduce the benefits
   gained by using Sprite?
  
   Doug, if you message me and I can tell you where to see the component.
  
   jason (underscore) newport {at) hot mail
  
   --- In flexcoders@yahoogroups.com 
   flexcoders%40yahoogroups.comflexcoders%
 40yahoogroups.com,

 Doug
   McCune doug@ wrote:
   
You've got 4,000 things all moving around at once? Are all 4,000 of
   those
actually visible? 4,000 UI components seems like a lot for any
 layout
manager to have to deal with. I'd try to focus on figuring out how
   to reduce
the number of UIComponents before I worried about how much memory
   each one
is taking up. I may be totally off base, but I can't imagine a
 scenario
where you want 4,000 images all on the screen at the same time.
   
And if you do really need to load 4,000 swfs all at the same time
   then you
probably want something that's lighter than custom UIComponent
 classes,
which would keep those 4,000 objects out of the normal
invalidation/validation cycles of the display list.
   
Doug
   
On Wed, Oct 15, 2008 at 1:34 PM, Michael Schmalle
teoti.graphix@wrote:
   
 A side note,
 You are doing some very expensive leg work in the 'content'
 setter.

 You need to break that out into commitProperties() and
   updateDisplayList().

 You would get a huge performance increase for sure.

 As far as the memory, doesn't look to weird, event listeners
   without weak
 references can make thing hang around as well.

 Mike


 On Wed, Oct 15, 2008 at 3:08 PM, flexaustin flexaustin@ wrote:

 So I have this base component, that when running profiler,
 says its
 eating up tons of memory. I have about 4000 of these at one
 time in
 my Flex app (see component code below). This base component is
 extended by two other components, which are then extended by
 two more
 components each so 3 or 4 levels above this base component.

 1. My first question is does the profiler just point to the base
   class
 or are there actually 4000 of these being created outside of
 their
 extended children?

 2. My 2nd question is is their anything wrong with the code
   below? Why
 is it eatin memory? The parameter content when pulled in is
 a swf
 file (icon) that is 5kb each so 5kb * 4000... you get the math.

 When I run this progam the CarouselImage's are using up 30%
 to 35% of
 my apps memory 

[flexcoders] Re: Extending UIComponent memory issues.

2008-10-17 Thread flexaustin
Well my container is about 4 classes deep. What I am focused on now is
the CarouselImage class as each carousel comp contains up to 8 of
these and their can be 2000 carousel components...see my delim? I know
at best it will be next to impossible to use but it has to be done. 

I tried converting my CarouselImage to a flexsprite but Flex rejects
it saying it needs to implement IUIComponent.



--- In flexcoders@yahoogroups.com, Michael Schmalle
[EMAIL PROTECTED] wrote:

 Jason,
 What I suggested is probably a bit to complex for what you need.
It's kind
 of a reimplementation of what you are doing.
 
 1. Subclass UIComponent to make your container.
 2. Create the layout algorithm in that component.
 3. Create a subclass of FlexSprite that is your loader component.
 4. Add the FlexSprite subclass instances (your content) to your
UIComponent
 container class with custom layout.
 5. Add the UIComponent class to a Container.
 
 The above is not really a solution for you right now I'm sure, I was
just
 saying this is what I would do to get maximum performance and memory
 management.
 
 The reason I say this is I have no idea how you are laying out those
 instances with reflection etc. How are you laying them out (with
what layout
 algorithm) ?
 
 Mike
 
 
 On Fri, Oct 17, 2008 at 10:21 AM, flexaustin [EMAIL PROTECTED] wrote:
 
Michael, I have tried using Flexsprite but throws errors about
needing
  to implementing IUIcomponent. Did I miss something and give up to
early?
 
  --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com,
Michael
  Schmalle
 
  teoti.graphix@ wrote:
  
   Doug, Jason,
   Since I am a self-centered person that doesn't like to be
misunderstood,
   ;-), I could have brought up the 4000 object issue. In previous
  threads with
   Jason, he said this was a requirement from the higher order. So I
  left it
   where it was, 4000 objects.
  
   As far as the IUIComponent issue, it is Container that requires
them not
   'Flex' itself.
  
   This is where as flex projects, Web 2.0 and performance are reaching
  a point
   where it's not just making a Flash IDE animation anymore.
  
   When the requirements of these projects come to this level there
is more
   engineering involved and Flex out of the box is not going to handle
   situations like this.
  
   The absolute way to do this is creating a UIComponent subclass that
  is the
   container, creating your layout algorithm in this component.
Subclass
   FlexSprite, make that your content loader component.
  
   Then instantiate the content components in the UIComponent
  container. This
   is the lean version of your design I envision. You could even
  recycle the
   content renderers in your container component Lot's of things
  you could
   do ;-)
  
   Mike
  
  
   On Wed, Oct 15, 2008 at 10:47 PM, flexaustin flexaustin@ wrote:
  
Doug, what would you go with? Sprite?
   
I thought sprite, but you need to implement all the
IUIComponent stuff
or use composition correct? Wouldn't composition reduce the
benefits
gained by using Sprite?
   
Doug, if you message me and I can tell you where to see the
component.
   
jason (underscore) newport {at) hot mail
   
--- In flexcoders@yahoogroups.com
flexcoders%40yahoogroups.comflexcoders%
  40yahoogroups.com,
 
  Doug
McCune doug@ wrote:

 You've got 4,000 things all moving around at once? Are all
4,000 of
those
 actually visible? 4,000 UI components seems like a lot for any
  layout
 manager to have to deal with. I'd try to focus on figuring
out how
to reduce
 the number of UIComponents before I worried about how much
memory
each one
 is taking up. I may be totally off base, but I can't imagine a
  scenario
 where you want 4,000 images all on the screen at the same time.

 And if you do really need to load 4,000 swfs all at the same
time
then you
 probably want something that's lighter than custom UIComponent
  classes,
 which would keep those 4,000 objects out of the normal
 invalidation/validation cycles of the display list.

 Doug

 On Wed, Oct 15, 2008 at 1:34 PM, Michael Schmalle
 teoti.graphix@wrote:

  A side note,
  You are doing some very expensive leg work in the 'content'
  setter.
 
  You need to break that out into commitProperties() and
updateDisplayList().
 
  You would get a huge performance increase for sure.
 
  As far as the memory, doesn't look to weird, event listeners
without weak
  references can make thing hang around as well.
 
  Mike
 
 
  On Wed, Oct 15, 2008 at 3:08 PM, flexaustin flexaustin@
wrote:
 
  So I have this base component, that when running profiler,
  says its
  eating up tons of memory. I have about 4000 of these at one
  time in
  my Flex app (see component code below). This base
component is
  extended by two other components, which are then 

Re: [flexcoders] Re: Extending UIComponent memory issues.

2008-10-16 Thread Michael Schmalle
Doug, Jason,
Since I am a self-centered person that doesn't like to be misunderstood,
;-), I could have brought up the 4000 object issue. In previous threads with
Jason, he said this was a requirement from the higher order. So I left it
where it was, 4000 objects.

As far as the IUIComponent issue, it is Container that requires them not
'Flex' itself.

This is where as flex projects, Web 2.0 and performance are reaching a point
where it's not just making a Flash IDE animation anymore.

When the requirements of these projects come to this level there is more
engineering involved and Flex out of the box is not going to handle
situations like this.

The absolute way to do this is creating a UIComponent subclass that is the
container, creating your layout algorithm in this component. Subclass
FlexSprite, make that your content loader component.

Then instantiate the content components in the UIComponent container. This
is the lean version of your design I envision. You could even recycle the
content renderers in your container component Lot's of things you could
do ;-)

Mike


On Wed, Oct 15, 2008 at 10:47 PM, flexaustin [EMAIL PROTECTED] wrote:

   Doug, what would you go with? Sprite?

 I thought sprite, but you need to implement all the IUIComponent stuff
 or use composition correct? Wouldn't composition reduce the benefits
 gained by using Sprite?

 Doug, if you message me and I can tell you where to see the component.

 jason (underscore) newport {at) hot mail

 --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, Doug
 McCune [EMAIL PROTECTED] wrote:
 
  You've got 4,000 things all moving around at once? Are all 4,000 of
 those
  actually visible? 4,000 UI components seems like a lot for any layout
  manager to have to deal with. I'd try to focus on figuring out how
 to reduce
  the number of UIComponents before I worried about how much memory
 each one
  is taking up. I may be totally off base, but I can't imagine a scenario
  where you want 4,000 images all on the screen at the same time.
 
  And if you do really need to load 4,000 swfs all at the same time
 then you
  probably want something that's lighter than custom UIComponent classes,
  which would keep those 4,000 objects out of the normal
  invalidation/validation cycles of the display list.
 
  Doug
 
  On Wed, Oct 15, 2008 at 1:34 PM, Michael Schmalle
  [EMAIL PROTECTED]wrote:
 
   A side note,
   You are doing some very expensive leg work in the 'content' setter.
  
   You need to break that out into commitProperties() and
 updateDisplayList().
  
   You would get a huge performance increase for sure.
  
   As far as the memory, doesn't look to weird, event listeners
 without weak
   references can make thing hang around as well.
  
   Mike
  
  
   On Wed, Oct 15, 2008 at 3:08 PM, flexaustin [EMAIL PROTECTED] wrote:
  
   So I have this base component, that when running profiler, says its
   eating up tons of memory. I have about 4000 of these at one time in
   my Flex app (see component code below). This base component is
   extended by two other components, which are then extended by two more
   components each so 3 or 4 levels above this base component.
  
   1. My first question is does the profiler just point to the base
 class
   or are there actually 4000 of these being created outside of their
   extended children?
  
   2. My 2nd question is is their anything wrong with the code
 below? Why
   is it eatin memory? The parameter content when pulled in is a swf
   file (icon) that is 5kb each so 5kb * 4000... you get the math.
  
   When I run this progam the CarouselImage's are using up 30% to 35% of
   my apps memory usage. And my app is eating up 725,000kb of mem usage,
   thus crashing my pretty decent computer.
  
   // --- BEGIN CODE --
   package com.mysite.views.components
   {
  
   import flash.display.DisplayObject;
   import flash.system.ApplicationDomain;
  
   import mx.core.UIComponent;
   import mx.events.ResizeEvent;
  
   public class CarouselImage extends UIComponent
   {
   // Content
   private var _content:DisplayObject;
   private var _contentWidth:Number;
   private var _contentHeight:Number;
  
   public function CarouselImage(content:*=null)
   {
   super();
  
   // Set content
   this.content = content;
   }
  
   // Properties
   [Inspectable]
   public function get content():DisplayObject
   {
   return _content;
   }
  
   public function set content(value:*):void
   {
   if (_content != null)
   {
   removeChild(_content)
   removeEventListener(ResizeEvent.RESIZE, handleResize);
   }
  
   if (value is String)
   {
   try
   {
   value = ApplicationDomain.currentDomain.getDefinition(value);
   }
   catch (error:*)
   {
   // Do nothing
   }
   }
  
   if (value is Class)
   value = new value();
  
   _content = value as DisplayObject;
  
   if (_content != null)
   {
   _contentWidth = _content.width;
   _contentHeight = _content.height;
  
   

[flexcoders] Re: Extending UIComponent memory issues.

2008-10-15 Thread flexaustin
Doug, what would you go with? Sprite? 

I thought sprite, but you need to implement all the IUIComponent stuff
or use composition correct? Wouldn't composition reduce the benefits
gained by using Sprite?

Doug, if you message me and I can tell you where to see the component.

jason (underscore) newport {at) hot mail 


 

 



--- In flexcoders@yahoogroups.com, Doug McCune [EMAIL PROTECTED] wrote:

 You've got 4,000 things all moving around at once? Are all 4,000 of
those
 actually visible? 4,000 UI components seems like a lot for any layout
 manager to have to deal with. I'd try to focus on figuring out how
to reduce
 the number of UIComponents before I worried about how much memory
each one
 is taking up. I may be totally off base, but I can't imagine a scenario
 where you want 4,000 images all on the screen at the same time.
 
 And if you do really need to load 4,000 swfs all at the same time
then you
 probably want something that's lighter than custom UIComponent classes,
 which would keep those 4,000 objects out of the normal
 invalidation/validation cycles of the display list.
 
 Doug
 
 On Wed, Oct 15, 2008 at 1:34 PM, Michael Schmalle
 [EMAIL PROTECTED]wrote:
 
A side note,
  You are doing some very expensive leg work in the 'content' setter.
 
  You need to break that out into commitProperties() and
updateDisplayList().
 
  You would get a huge performance increase for sure.
 
  As far as the memory, doesn't look to weird, event listeners
without weak
  references can make thing hang around as well.
 
  Mike
 
 
  On Wed, Oct 15, 2008 at 3:08 PM, flexaustin [EMAIL PROTECTED] wrote:
 
So I have this base component, that when running profiler, says its
  eating up tons of memory. I have about 4000 of these at one time in
  my Flex app (see component code below). This base component is
  extended by two other components, which are then extended by two more
  components each so 3 or 4 levels above this base component.
 
  1. My first question is does the profiler just point to the base
class
  or are there actually 4000 of these being created outside of their
  extended children?
 
  2. My 2nd question is is their anything wrong with the code
below? Why
  is it eatin memory? The parameter content when pulled in is a swf
  file (icon) that is 5kb each so 5kb * 4000... you get the math.
 
  When I run this progam the CarouselImage's are using up 30% to 35% of
  my apps memory usage. And my app is eating up 725,000kb of mem usage,
  thus crashing my pretty decent computer.
 
  // --- BEGIN CODE --
  package com.mysite.views.components
  {
 
  import flash.display.DisplayObject;
  import flash.system.ApplicationDomain;
 
  import mx.core.UIComponent;
  import mx.events.ResizeEvent;
 
  public class CarouselImage extends UIComponent
  {
  // Content
  private var _content:DisplayObject;
  private var _contentWidth:Number;
  private var _contentHeight:Number;
 
  public function CarouselImage(content:*=null)
  {
  super();
 
  // Set content
  this.content = content;
  }
 
  // Properties
  [Inspectable]
  public function get content():DisplayObject
  {
  return _content;
  }
 
  public function set content(value:*):void
  {
  if (_content != null)
  {
  removeChild(_content)
  removeEventListener(ResizeEvent.RESIZE, handleResize);
  }
 
  if (value is String)
  {
  try
  {
  value = ApplicationDomain.currentDomain.getDefinition(value);
  }
  catch (error:*)
  {
  // Do nothing
  }
  }
 
  if (value is Class)
  value = new value();
 
  _content = value as DisplayObject;
 
  if (_content != null)
  {
  _contentWidth = _content.width;
  _contentHeight = _content.height;
 
  addChild(_content);
  addEventListener(ResizeEvent.RESIZE, handleResize);
 
  scaleContent();
  }
 
  this.invalidateDisplayList();
  this.invalidateProperties();
  this.invalidateSize();
  }
 
  public function get contentWidth():Number
  {
  return _contentWidth;
  }
 
  public function get contentHeight():Number
  {
  return _contentHeight;
  }
 
  // Measure and draw
  private function scaleContent():void
  {
  if (_content != null  width  0  height  0)
  {
  // Width
  _content.scaleX = width / contentWidth;
  // Center the image
  _content.x = (width - (contentWidth * _content.scaleX)) * 0.5;
 
  // Height
  _content.scaleY = height / contentHeight;
  // Center the image
  _content.y = (height - (contentHeight * _content.scaleY)) * 0.5;
  }
  }
 
  // Event handlers
  private function handleResize(event:ResizeEvent):void
  {
  scaleContent();
  this.invalidateDisplayList();
  this.invalidateProperties();
  this.invalidateSize();
  }
 
  }
  }
  // - END CODE 
 
 
 
 
  --
  Teoti Graphix, LLC
  http://www.teotigraphix.com
 
  Teoti Graphix Blog
  http://www.blog.teotigraphix.com
 
  You can find more by solving the problem then by 'asking the
question'.