RE: [flexcoders] Re: Custom Component Width when 100%?

2007-03-28 Thread Alex Harui
measure requires some math, usually.  you will never call
getExplicitOrMeasuredWidth() on yourself since that just reads the
meausredWidht property you are trying to set.
 
If I had a component that drew a circle and a triangle next to it, my
measure would look like
 
measuredWidth= circle.getExplicitOrMeasuredWidth() +
triangle.getExplicitOrMeasuredWidth();
measuredHeight = Math.max( circle.getExplicitOrMeasuredHeight(),
triangle.getExplicitOrMeasuredHeight();
 
In other situations I know I want to be 100 wide so I just set
measuredWidth = 100.
 
You'll have to find a way to know how big you want to be.



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Nate Pearson
Sent: Wednesday, March 28, 2007 9:43 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Custom Component Width when 100%?



In my measure function I have:

override protected function measure():void{
measuredWidth = getExplicitOrMeasuredWidth()
measuredHeight = getExplicitOrMeasuredHeight()
} 

That makes them both zero though. although my updateDisplayList gets
called twice my measure function is only called once. How should I be
setting my measure function? If we get this worked out I think I'll
be good to go, if not ill post the code. Thanks so much for your help
Alex.

--- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
, Alex Harui [EMAIL PROTECTED] wrote:

 In theory, if you started with UIComponent, you need to implement a
 measure() method to tell the parent how big you want to be. That
parent
 will then call setActualSize which should result in your
 updateDisplayList being called with non-zero values. Again, if
 extending UIComponent, you should be able to draw or add shapes in
 updateDisplayList without causing a second call to updateDisplayList
 providing that your measure() method returns the same values and
nobody
 else called invalidateDisplayList.
 
 It feels like you're not quite following the formula somehwere. You
 could post the class code I suppose...
 
 
 
 From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
[mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
] On
 Behalf Of Nate Pearson
 Sent: Tuesday, March 27, 2007 4:37 PM
 To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com 
 Subject: [flexcoders] Re: Custom Component Width when 100%?
 
 
 
 Ahhh HA! I was reading the adobe documentation and it turns out that
 when you do addchild() it calls updateDisplayList again. This is why
 my program wasn't working, I had an infinite loop when I called
 addchild.
 
 I fixed it by adding an if function with a flag.
 if (_newBackground){
 ...
 }
 
 Since my updatedisplaylist was being called twice, once with 0
 unscaledWidth and once with an unscaledWidth, I had to add another
 condition.
 if (_newBackground  unscaledWidth != 0) {
 ...
 }
 
 Now I can't seem to get the component to scale with the rest of the
 app when the browser window opens. I'm going to start a new thread
 for that question.
 
 -Nate
 
 --- In flexcoders@yahoogroups.com
mailto:flexcoders%40yahoogroups.com
mailto:flexcoders%40yahoogroups.com
 , Nate Pearson napearson99@ wrote:
 
  So I think i got unScaledWidth to work during UpdateDisplayList.
When
  I debug it seems like it's called twice. Once with 0 unscaledWidth
  and once with the correct unScaledWidth. Should I be worrying about
  this? I didn't override the measure function. Should I?
  
  So to draw in UpdateDisplayList you have to manipulate graphics like
 this:
  graphics.lineStyle(0,0x00, 0);
  graphics.beginFill(0xff, 1);
  graphics.drawRect(0,0,unscaledWidth/2,unscaledHeight);
  graphics.endFill(); 
  
  But what if I want to draw shapes or UIcomponents? That's why It
  wasn't working for me before, i was drawing like this:
  var shape:Shape = new Shape();
  shape.graphics.lineStyle(0,0x00, 0);
  shape.graphics.beginFill(0xff, 1);
  shape.graphics.drawRect(0,0,unscaledWidth/2,unscaledHeight);
  shape.graphics.endFill();
  //When i do the add child my program won't load!
  //addChild(shape);
  
  I watched Ely's component video and it says I can add UIComponents,
  sprites and shapes to UpdateDisplayList. Does anyone know what I'm
  doing wrong?
  
  Thanks!
  
  -Nate
  
  
  --- In flexcoders@yahoogroups.com
mailto:flexcoders%40yahoogroups.com 
 mailto:flexcoders%40yahoogroups.com , Alex Harui aharui@ wrote:
  
   You can always call validateNow() to force validation, but you
 shouldn't
   be drawing in commitProperties in most cases. Most drawing should
 be in
   updateDisplayList
   
   
   
   From: flexcoders@yahoogroups.com
mailto:flexcoders%40yahoogroups.com 
 mailto:flexcoders%40yahoogroups.com 
 [mailto:flexcoders@yahoogroups.com
mailto:flexcoders%40yahoogroups.com
mailto:flexcoders%40yahoogroups.com
 ] On
   Behalf Of Nate Pearson
   Sent: Monday, March 26, 2007 3:53 PM
   To: 

RE: [flexcoders] Re: Custom Component Width when 100%?

2007-03-27 Thread Alex Harui
In theory, if you started with UIComponent, you need to implement a
measure() method to tell the parent how big you want to be.  That parent
will then call setActualSize which should result in your
updateDisplayList being called with non-zero values.  Again, if
extending UIComponent, you should be able to draw or add shapes in
updateDisplayList without causing a second call to updateDisplayList
providing that your measure() method returns the same values and nobody
else called invalidateDisplayList.
 
It feels like you're not quite following the formula somehwere.  You
could post the class code I suppose...



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Nate Pearson
Sent: Tuesday, March 27, 2007 4:37 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Custom Component Width when 100%?



Ahhh HA! I was reading the adobe documentation and it turns out that
when you do addchild() it calls updateDisplayList again. This is why
my program wasn't working, I had an infinite loop when I called
addchild.

I fixed it by adding an if function with a flag.
if (_newBackground){
...
}

Since my updatedisplaylist was being called twice, once with 0
unscaledWidth and once with an unscaledWidth, I had to add another
condition.
if (_newBackground  unscaledWidth != 0) {
...
}

Now I can't seem to get the component to scale with the rest of the
app when the browser window opens. I'm going to start a new thread
for that question.

-Nate

--- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
, Nate Pearson [EMAIL PROTECTED] wrote:

 So I think i got unScaledWidth to work during UpdateDisplayList. When
 I debug it seems like it's called twice. Once with 0 unscaledWidth
 and once with the correct unScaledWidth. Should I be worrying about
 this? I didn't override the measure function. Should I?
 
 So to draw in UpdateDisplayList you have to manipulate graphics like
this:
 graphics.lineStyle(0,0x00, 0);
 graphics.beginFill(0xff, 1);
 graphics.drawRect(0,0,unscaledWidth/2,unscaledHeight);
 graphics.endFill(); 
 
 But what if I want to draw shapes or UIcomponents? That's why It
 wasn't working for me before, i was drawing like this:
 var shape:Shape = new Shape();
 shape.graphics.lineStyle(0,0x00, 0);
 shape.graphics.beginFill(0xff, 1);
 shape.graphics.drawRect(0,0,unscaledWidth/2,unscaledHeight);
 shape.graphics.endFill();
 //When i do the add child my program won't load!
 //addChild(shape);
 
 I watched Ely's component video and it says I can add UIComponents,
 sprites and shapes to UpdateDisplayList. Does anyone know what I'm
 doing wrong?
 
 Thanks!
 
 -Nate
 
 
 --- In flexcoders@yahoogroups.com
mailto:flexcoders%40yahoogroups.com , Alex Harui aharui@ wrote:
 
  You can always call validateNow() to force validation, but you
shouldn't
  be drawing in commitProperties in most cases. Most drawing should
be in
  updateDisplayList
  
  
  
  From: flexcoders@yahoogroups.com
mailto:flexcoders%40yahoogroups.com 
[mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
] On
  Behalf Of Nate Pearson
  Sent: Monday, March 26, 2007 3:53 PM
  To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com

  Subject: [flexcoders] Re: Custom Component Width when 100%?
  
  
  
  I can't seem to get the width/height at measure() or
  updateDisplayList(). Is there a specific function I have to call?
  
  Isn't there a way to get the height/width before measure? I'm
drawing
  during commit properties so I would like to get it then. 
  
  Thanks for your reply.
  
  --- In flexcoders@yahoogroups.com
mailto:flexcoders%40yahoogroups.com 
mailto:flexcoders%40yahoogroups.com
  , Alex Harui aharui@ wrote:
  
   It depends on when you ask. Components have a multi-stage
validation
   mechanism. Their properties get set in stage1, measured in stage2,
   layed out in stage 3. Until measurement, they are zero
width/height
   
   
   
   From: flexcoders@yahoogroups.com
mailto:flexcoders%40yahoogroups.com 
mailto:flexcoders%40yahoogroups.com
  [mailto:flexcoders@yahoogroups.com
mailto:flexcoders%40yahoogroups.com 
mailto:flexcoders%40yahoogroups.com
  ] On
   Behalf Of Nate Pearson
   Sent: Monday, March 26, 2007 1:09 PM
   To: flexcoders@yahoogroups.com
mailto:flexcoders%40yahoogroups.com 
mailto:flexcoders%40yahoogroups.com 
   Subject: [flexcoders] Custom Component Width when 100%?
   
   
   
   I created a custom component that works great when the width is
   specified. However, when I try to set the width to a percent (of
the
   parent) it returns 0. How to I reference the parent's width? I
tried
   getExplicitOrMeasuredWidth but it didn't work.
   
   Thanks in advance for the help.
  
 




 


RE: [flexcoders] Re: Custom Component Width when 100%?

2007-03-26 Thread Alex Harui
You can always call validateNow() to force validation, but you shouldn't
be drawing in commitProperties in most cases.  Most drawing should be in
updateDisplayList



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Nate Pearson
Sent: Monday, March 26, 2007 3:53 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Custom Component Width when 100%?



I can't seem to get the width/height at measure() or
updateDisplayList(). Is there a specific function I have to call?

Isn't there a way to get the height/width before measure? I'm drawing
during commit properties so I would like to get it then. 

Thanks for your reply.

--- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
, Alex Harui [EMAIL PROTECTED] wrote:

 It depends on when you ask. Components have a multi-stage validation
 mechanism. Their properties get set in stage1, measured in stage2,
 layed out in stage 3. Until measurement, they are zero width/height
 
 
 
 From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
[mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
] On
 Behalf Of Nate Pearson
 Sent: Monday, March 26, 2007 1:09 PM
 To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com 
 Subject: [flexcoders] Custom Component Width when 100%?
 
 
 
 I created a custom component that works great when the width is
 specified. However, when I try to set the width to a percent (of the
 parent) it returns 0. How to I reference the parent's width? I tried
 getExplicitOrMeasuredWidth but it didn't work.
 
 Thanks in advance for the help.