[flexcoders] Re: A very simple component in AS :(

2008-06-30 Thread Amy
--- In flexcoders@yahoogroups.com, Josh McDonald [EMAIL PROTECTED] wrote:

 It might work, but you really should look into reading some 
tutorials on the
 lifecycle of Flex components. Here's a few brief things:
 
 * You want to create child components in the createChildren() 
method, not in
 your constructor. Your component may be instantiated long before it 
needs to
 have its children created.
 * Override the measure() function to set measuredWidth and 
measuredHeight,
 but the actual size will be set by your container
 * Override updateDisplaylist() to size and move your child 
components. Get
 their preferred sizes using child.getExplicitOrMeasuredWidth / 
Height in
 measure(), but set them using setActualSize(), not by setting the 
width and
 height. Position them with move()
 * There's a lot of good tutorials out there, google is your 
friend :)

I found it very difficult to find a tutorial that took me from the 
level of understanding where I was asking the kinds of questions the 
OP asked to where I was able to write my own components extending 
UIComponent.  The best one that I have found is this one 
http://weblogs.macromedia.com/pent/archives/2006/07/writing_flex_2.htm
l.

HTH;

Amy



[flexcoders] Re: A very simple component in AS :(

2008-06-30 Thread flexawesome
I appreciate all your feedback in this topic. :)

Thank you

--- In flexcoders@yahoogroups.com, Stephen Gilson [EMAIL PROTECTED] 
wrote:

 The doc describes the procedure for creating a component in AS. You 
can
 see it here:
 http://livedocs.adobe.com/flex/3/html/Part3_as_components_1.html
 http://livedocs.adobe.com/flex/3/html/Part3_as_components_1.html 
  
 Stephen
 
 
 
 From: flexcoders@yahoogroups.com 
[mailto:[EMAIL PROTECTED] On
 Behalf Of Josh McDonald
 Sent: Sunday, June 29, 2008 8:11 PM
 To: flexcoders@yahoogroups.com
 Subject: Re: [flexcoders] A very simple component in AS :(
 
 
 
 A few things:
 
 You'll need to override measure(), like so:
 
 protected override function measure() : void {
   measuredWidth = _txt.measuredWidth;
   measuredHeight = _txt.measuredHeight;
 }
 
 and updateDisplayList(), like so:
 
 protected override function updateDisplayList(w:Number, h:Number) : 
void
 {
   _txt.move(0,0);
   _txt.setActualSize(Math.min(_txt.measuredWidth, w),
 Math.min(_txt.measuredHeight, h));
 }
 
 That should do it. But this is typed in gmail, not Flex so it's 
probably
 got typos in it :)
 
 -Josh
 
 
 On Mon, Jun 30, 2008 at 9:50 AM, flexawesome [EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED]  wrote:
 
 
 
   Hey there,
   
   I was trying to create a very simple component in as, there 
was
 no error
   in compiling. However, I was unable to see the text. :( can 
you
 take a
   quick look? thank you
   
   === AS 
   
   package
   {
import mx.controls.Text;
import mx.core.UIComponent;
   
public class Footer extends UIComponent
{
 public var title:String;
 private var _txt:Text;
   
 public function Footer()
 {
  super.setActualSize(50 , 20 );
   
  _txt= new Text();
  _txt.text = title;
  addChild( _txt );
 }
}
   }
   
    in main.mxml ===
   
   local:newText title=asdfasdfa /
   
   
   
   
   
   --
   Flexcoders Mailing List
   FAQ:
 http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
 http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt 
   Search Archives:
 http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo
 http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo ! 
Groups
 Links
   
   
  (Yahoo! ID required)
   
  mailto:[EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED] 
   
   
   
   
 
 
 
 
 -- 
 Therefore, send not to know For whom the bell tolls. It tolls for
 thee.
 
 :: Josh 'G-Funk' McDonald
 :: 0437 221 380 :: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]





[flexcoders] Re: A very simple component in AS :(

2008-06-29 Thread Bjorn Schultheiss
Basically thats not how to create a component for flex.
The value for title has not been set at the time the constructor runs.

You should look at Flex's component invalidation cycle.

createChildren();
commitProperties();

Its all in the docs.

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

 
 Hey there,
 
 I was trying to create a very simple component in as, there was no error
 in compiling. However, I was unable to see the text. :( can you take a
 quick look? thank you
 
 === AS 
 
 package
 {
   import mx.controls.Text;
   import mx.core.UIComponent;
 
   public class Footer extends UIComponent
   {
public var title:String;
private var _txt:Text;
 
public function Footer()
{
 super.setActualSize(50 , 20 );
 
 _txt= new Text();
 _txt.text = title;
 addChild( _txt );
}
   }
 }
 
  in main.mxml ===
 
 local:newText title=asdfasdfa /





[flexcoders] Re: A very simple component in AS :(

2008-06-29 Thread flexawesome
thank you Josh, I am give a try.

--- In flexcoders@yahoogroups.com, Josh McDonald [EMAIL PROTECTED] wrote:

 A few things:
 
 You'll need to override measure(), like so:
 
 protected override function measure() : void {
   measuredWidth = _txt.measuredWidth;
   measuredHeight = _txt.measuredHeight;
 }
 
 and updateDisplayList(), like so:
 
 protected override function updateDisplayList(w:Number, h:Number) : 
void {
   _txt.move(0,0);
   _txt.setActualSize(Math.min(_txt.measuredWidth, w),
 Math.min(_txt.measuredHeight, h));
 }
 
 That should do it. But this is typed in gmail, not Flex so it's 
probably got
 typos in it :)
 
 -Josh
 
 On Mon, Jun 30, 2008 at 9:50 AM, flexawesome [EMAIL PROTECTED] 
wrote:
 
 
  Hey there,
 
  I was trying to create a very simple component in as, there was 
no error
  in compiling. However, I was unable to see the text. :( can you 
take a
  quick look? thank you
 
  === AS 
 
  package
  {
   import mx.controls.Text;
   import mx.core.UIComponent;
 
   public class Footer extends UIComponent
   {
public var title:String;
private var _txt:Text;
 
public function Footer()
{
 super.setActualSize(50 , 20 );
 
 _txt= new Text();
 _txt.text = title;
 addChild( _txt );
}
   }
  }
 
   in main.mxml ===
 
  local:newText title=asdfasdfa /
 
 
 
  
 
  --
  Flexcoders Mailing List
  FAQ: 
http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
  Search Archives:
  http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! 
Groups
  Links
 
 
 
 
 
 
 -- 
 Therefore, send not to know For whom the bell tolls. It tolls for 
thee.
 
 :: Josh 'G-Funk' McDonald
 :: 0437 221 380 :: [EMAIL PROTECTED]





Re: [flexcoders] Re: A very simple component in AS :(

2008-06-29 Thread Josh McDonald
It might work, but you really should look into reading some tutorials on the
lifecycle of Flex components. Here's a few brief things:

* You want to create child components in the createChildren() method, not in
your constructor. Your component may be instantiated long before it needs to
have its children created.
* Override the measure() function to set measuredWidth and measuredHeight,
but the actual size will be set by your container
* Override updateDisplaylist() to size and move your child components. Get
their preferred sizes using child.getExplicitOrMeasuredWidth / Height in
measure(), but set them using setActualSize(), not by setting the width and
height. Position them with move()
* There's a lot of good tutorials out there, google is your friend :)

-Josh

On Mon, Jun 30, 2008 at 12:03 PM, flexawesome [EMAIL PROTECTED] wrote:

 thank you Josh, I am give a try.

 --- In flexcoders@yahoogroups.com, Josh McDonald [EMAIL PROTECTED] wrote:
 
  A few things:
 
  You'll need to override measure(), like so:
 
  protected override function measure() : void {
measuredWidth = _txt.measuredWidth;
measuredHeight = _txt.measuredHeight;
  }
 
  and updateDisplayList(), like so:
 
  protected override function updateDisplayList(w:Number, h:Number) :
 void {
_txt.move(0,0);
_txt.setActualSize(Math.min(_txt.measuredWidth, w),
  Math.min(_txt.measuredHeight, h));
  }
 
  That should do it. But this is typed in gmail, not Flex so it's
 probably got
  typos in it :)
 
  -Josh
 
  On Mon, Jun 30, 2008 at 9:50 AM, flexawesome [EMAIL PROTECTED]
 wrote:
 
  
   Hey there,
  
   I was trying to create a very simple component in as, there was
 no error
   in compiling. However, I was unable to see the text. :( can you
 take a
   quick look? thank you
  
   === AS 
  
   package
   {
import mx.controls.Text;
import mx.core.UIComponent;
  
public class Footer extends UIComponent
{
 public var title:String;
 private var _txt:Text;
  
 public function Footer()
 {
  super.setActualSize(50 , 20 );
  
  _txt= new Text();
  _txt.text = title;
  addChild( _txt );
 }
}
   }
  
    in main.mxml ===
  
   local:newText title=asdfasdfa /
  
  
  
   
  
   --
   Flexcoders Mailing List
   FAQ:
 http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
   Search Archives:
   http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo!
 Groups
   Links
  
  
  
  
 
 
  --
  Therefore, send not to know For whom the bell tolls. It tolls for
 thee.
 
  :: Josh 'G-Funk' McDonald
  :: 0437 221 380 :: [EMAIL PROTECTED]
 



 

 --
 Flexcoders Mailing List
 FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
 Search Archives:
 http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups
 Links






-- 
Therefore, send not to know For whom the bell tolls. It tolls for thee.

:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: [EMAIL PROTECTED]


[flexcoders] Re: A very simple component in AS :(

2008-06-29 Thread flexawesome
right, I am reading the help file. :) If you could poste some 
tutorials of components in AS, that would be great :) ( I didn't find 
2 much tutorials about this )

Thanks

--- In flexcoders@yahoogroups.com, Josh McDonald [EMAIL PROTECTED] wrote:

 It might work, but you really should look into reading some 
tutorials on the
 lifecycle of Flex components. Here's a few brief things:
 
 * You want to create child components in the createChildren() 
method, not in
 your constructor. Your component may be instantiated long before it 
needs to
 have its children created.
 * Override the measure() function to set measuredWidth and 
measuredHeight,
 but the actual size will be set by your container
 * Override updateDisplaylist() to size and move your child 
components. Get
 their preferred sizes using child.getExplicitOrMeasuredWidth / 
Height in
 measure(), but set them using setActualSize(), not by setting the 
width and
 height. Position them with move()
 * There's a lot of good tutorials out there, google is your 
friend :)
 
 -Josh
 
 On Mon, Jun 30, 2008 at 12:03 PM, flexawesome [EMAIL PROTECTED] 
wrote:
 
  thank you Josh, I am give a try.
 
  --- In flexcoders@yahoogroups.com, Josh McDonald dznuts@ 
wrote:
  
   A few things:
  
   You'll need to override measure(), like so:
  
   protected override function measure() : void {
 measuredWidth = _txt.measuredWidth;
 measuredHeight = _txt.measuredHeight;
   }
  
   and updateDisplayList(), like so:
  
   protected override function updateDisplayList(w:Number, 
h:Number) :
  void {
 _txt.move(0,0);
 _txt.setActualSize(Math.min(_txt.measuredWidth, w),
   Math.min(_txt.measuredHeight, h));
   }
  
   That should do it. But this is typed in gmail, not Flex so it's
  probably got
   typos in it :)
  
   -Josh
  
   On Mon, Jun 30, 2008 at 9:50 AM, flexawesome flexawesome@
  wrote:
  
   
Hey there,
   
I was trying to create a very simple component in as, there 
was
  no error
in compiling. However, I was unable to see the text. :( can 
you
  take a
quick look? thank you
   
=== AS 
   
package
{
 import mx.controls.Text;
 import mx.core.UIComponent;
   
 public class Footer extends UIComponent
 {
  public var title:String;
  private var _txt:Text;
   
  public function Footer()
  {
   super.setActualSize(50 , 20 );
   
   _txt= new Text();
   _txt.text = title;
   addChild( _txt );
  }
 }
}
   
 in main.mxml ===
   
local:newText title=asdfasdfa /
   
   
   

   
--
Flexcoders Mailing List
FAQ:
  http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives:
http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo!
  Groups
Links
   
   
   
   
  
  
   --
   Therefore, send not to know For whom the bell tolls. It tolls 
for
  thee.
  
   :: Josh 'G-Funk' McDonald
   :: 0437 221 380 :: josh@
  
 
 
 
  
 
  --
  Flexcoders Mailing List
  FAQ: 
http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
  Search Archives:
  http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! 
Groups
  Links
 
 
 
 
 
 
 -- 
 Therefore, send not to know For whom the bell tolls. It tolls for 
thee.
 
 :: Josh 'G-Funk' McDonald
 :: 0437 221 380 :: [EMAIL PROTECTED]





Re: [flexcoders] Re: A very simple component in AS :(

2008-06-29 Thread Josh McDonald
Kinda busy today, but here's a couple:

http://msimtiyaz.wordpress.com/flex/adobe-flex-component-instantiation-life-cycle/

http://nwebb.co.uk/blog/?p=46

http://www.adobe.com/devnet/flex/quickstart/building_components_in_as/

A really good place to start is looking into the API docs for UIComponent
and Canvas, and just sort of browsing around, reading up on any method that
you don't understand.

A lot of custom component creation is about overriding protected methods,
because there's a lot of glue in UIComponent that you want to be able to
rely on, so pay particular attention to the protected overrides, and to the
invalidateXXX() methods.

-Josh

On Mon, Jun 30, 2008 at 1:45 PM, flexawesome [EMAIL PROTECTED] wrote:

 right, I am reading the help file. :) If you could poste some
 tutorials of components in AS, that would be great :) ( I didn't find
 2 much tutorials about this )

 Thanks

 --- In flexcoders@yahoogroups.com, Josh McDonald [EMAIL PROTECTED] wrote:
 
  It might work, but you really should look into reading some
 tutorials on the
  lifecycle of Flex components. Here's a few brief things:
 
  * You want to create child components in the createChildren()
 method, not in
  your constructor. Your component may be instantiated long before it
 needs to
  have its children created.
  * Override the measure() function to set measuredWidth and
 measuredHeight,
  but the actual size will be set by your container
  * Override updateDisplaylist() to size and move your child
 components. Get
  their preferred sizes using child.getExplicitOrMeasuredWidth /
 Height in
  measure(), but set them using setActualSize(), not by setting the
 width and
  height. Position them with move()
  * There's a lot of good tutorials out there, google is your
 friend :)
 
  -Josh
 
  On Mon, Jun 30, 2008 at 12:03 PM, flexawesome [EMAIL PROTECTED]
 wrote:
 
   thank you Josh, I am give a try.
  
   --- In flexcoders@yahoogroups.com, Josh McDonald dznuts@
 wrote:
   
A few things:
   
You'll need to override measure(), like so:
   
protected override function measure() : void {
  measuredWidth = _txt.measuredWidth;
  measuredHeight = _txt.measuredHeight;
}
   
and updateDisplayList(), like so:
   
protected override function updateDisplayList(w:Number,
 h:Number) :
   void {
  _txt.move(0,0);
  _txt.setActualSize(Math.min(_txt.measuredWidth, w),
Math.min(_txt.measuredHeight, h));
}
   
That should do it. But this is typed in gmail, not Flex so it's
   probably got
typos in it :)
   
-Josh
   
On Mon, Jun 30, 2008 at 9:50 AM, flexawesome flexawesome@
   wrote:
   

 Hey there,

 I was trying to create a very simple component in as, there
 was
   no error
 in compiling. However, I was unable to see the text. :( can
 you
   take a
 quick look? thank you

 === AS 

 package
 {
  import mx.controls.Text;
  import mx.core.UIComponent;

  public class Footer extends UIComponent
  {
   public var title:String;
   private var _txt:Text;

   public function Footer()
   {
super.setActualSize(50 , 20 );

_txt= new Text();
_txt.text = title;
addChild( _txt );
   }
  }
 }

  in main.mxml ===

 local:newText title=asdfasdfa /



 

 --
 Flexcoders Mailing List
 FAQ:
   http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
 Search Archives:
 http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo!
   Groups
 Links




   
   
--
Therefore, send not to know For whom the bell tolls. It tolls
 for
   thee.
   
:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: josh@
   
  
  
  
   
  
   --
   Flexcoders Mailing List
   FAQ:
 http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
   Search Archives:
   http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo!
 Groups
   Links
  
  
  
  
 
 
  --
  Therefore, send not to know For whom the bell tolls. It tolls for
 thee.
 
  :: Josh 'G-Funk' McDonald
  :: 0437 221 380 :: [EMAIL PROTECTED]
 



 

 --
 Flexcoders Mailing List
 FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
 Search Archives:
 http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups
 Links






-- 
Therefore, send not to know For whom the bell tolls. It tolls for thee.

:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: [EMAIL PROTECTED]