The MXML compiler generates an init() method for any MXML class.  The initialize event might be fine but depending on your other code it might execute too late.  I think using commitProperties() might be OK (assign your values and then call super.commitProperties() at the end of your method).

 

Matt

 


From: [email protected] [mailto:[email protected]] On Behalf Of JesterXL
Sent: Monday, May 23, 2005 5:53 PM
To: [email protected]
Subject: Re: [flexcoders] implementing init() in subclass

 

Actually, unless you want to override the vars by re-claring them with default values up top, yoou are better off just doing a plain AS solution.  If you do that (non MXML), the compiler won't bitch about init.

 

----- Original Message -----

From: JesterXL

Sent: Monday, May 23, 2005 5:42 PM

Subject: Re: [flexcoders] implementing init() in subclass

 

I never figured that out.  What I do is use the contructor in my init, so:

 

function initYourCanvas()

{

 

}

 

And then, in your Canvas' attributes, do:

 

initialize="initYourCanvas();"

----- Original Message -----

Sent: Monday, May 23, 2005 5:36 PM

Subject: [flexcoders] implementing init() in subclass

 

I'm trying to create an MXML component that is a subclass of <mx:Canvas>. I would like to provide my own implementation of mx.core.UIComponent's init() method so that I can set some default values for my custom component properties. However, when I try this (as illustrated below) I get the following odd error:

 

 

   line 52     The member name, init, may not be repeated more than once.

   line 85     The member name, init, may not be repeated more than once.

 

 

My code looks like this...

 

 

51  public function init() :Void
52  {
53      super.init();
54      // Use default property values if necessary.
55      if (selected == undefined)
56      {
57          selected = false;
58      }
59  }

 

 

Note, this code is all inline in my MXML file. My <mx:Script> block ends at line 62. Line 85 is in the middle of my MXML tags!

 

What is really causing this error? How do I resolve it? Is overriding the init() method not the best approach for setting default property values?

 

 

Kris

 

--

 

Kristopher Schultz

Developer

 

Resource Interactive

p: 614.410.2123

 

 



Yahoo! Groups Links

Reply via email to