Hi Kris,
When a MXML component is converted to ActionScript code,
compiler inserts a init(...) method in it. Since MXML components are for
developers looking for quick solution, things have been made easier where
developer doesn't have to override required methods like init(..) etc. If you
know about flex component framework, having an init(..) method with super.init()
call is at minimum for any custom component. But developer doesn't have to do if
it is custom mxml component.
If you really need an init(..) method, I would suggest you
to create component using ActionScript....
If you are curious to know, what ActionScript code is
generated out of your MXML component, follow the steps mentioned at Manish's
blog, I just don't want to repeat 'em here again.
You can change init(..) method in generated
actionscript code and compile it back using mxmlc? I guess, it is appropriate
for pre-compiled swf scenario...
-abdul
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Kristopher Schultz
Sent: Tuesday, May 24, 2005 3:06 AM
To: [email protected]
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 }
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?
Yahoo! Groups Links
- To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

