[flexcoders] Constructor not called when calling myClass

2005-08-18 Thread trumpet1971
Hi all,

I am pretty new at Flex and working on my first project. 
I read some Macromedia tutorials and in one of them they created their
own CalculatorHandler-class and instantiated this through a
CalculatorHandler tag in the main mxml file. 

I tried something similar by building my own class and found out the
constructor is not called at all when i instantiate it with a
myClass tag.

I need this constructor to be called to initialize some of the
properties of my class.
I also tried this code:

mx:Script
![CDATA[
var myInstance = new myClass();
]]
/mx:Script

but then i get some compilation error a class's instance variable may
not be initialized to compile-time constant expressions.

Can someone tell me how to create an instance of myClass ?

Thanks in advance,

Chiel Pauw
Amsterdam






 Yahoo! Groups Sponsor ~-- 
font face=arial size=-1a 
href=http://us.ard.yahoo.com/SIG=12hpdggqf/M=362335.6886445.7839731.1510227/D=groups/S=1705007207:TM/Y=YAHOO/EXP=1124385839/A=2894361/R=0/SIG=13jmebhbo/*http://www.networkforgood.org/topics/education/digitaldivide/?source=YAHOOcmpgn=GRPRTP=http://groups.yahoo.com/;In
 low income neighborhoods, 84% do not own computers. At Network for Good, help 
bridge the Digital Divide!/a./font
~- 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
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:
http://docs.yahoo.com/info/terms/
 




RE: [flexcoders] Constructor not called when calling myClass

2005-08-18 Thread grady.haynes
Hi, Chiel.

Could you post some of the code from your myClass tag whose
constructor wasn't being called?  afaik, the no-args constructor should
have been called; is there a possibility of a typo (or incorrect
capitalization) in the constructor name?  Also, make sure that your
constructor isn't declared with a return type -- otherwise it's not
really a constructor and won't be called!

Your mx:Script code isn't working because all statements have to be
inside of a method -- try this instead (note the change of myClass to
MyClass -- capitalization of class names is strongly encouraged in
AS):

mx:Script
![CDATA[
private var myInstance: MyClass;

private function createMyClassObject(): Void
{
myInstance = new myClass();
}
]]
/mx:Script

Then, to get createMyClassObject() to be called when your form's
elements are finished being created, add
creationComplete=createMyClassObject()
as an attribute to your root MXML tag.

HTH.

Grady Haynes
Senior Systems Engineer, IT Services
817.252.4891
[EMAIL PROTECTED]

Practitioners Publishing Company
A Thomson Business
801 Cherry Street, Suite 1300
Fort Worth, Texas 76102
ppc.thomson.com


-Original Message-
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of trumpet1971
Sent: Thursday, August 18, 2005 10:13 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Constructor not called when calling myClass

Hi all,

I am pretty new at Flex and working on my first project. 
I read some Macromedia tutorials and in one of them they created their
own CalculatorHandler-class and instantiated this through a
CalculatorHandler tag in the main mxml file. 

I tried something similar by building my own class and found out the
constructor is not called at all when i instantiate it with a myClass
tag.

I need this constructor to be called to initialize some of the
properties of my class.
I also tried this code:

mx:Script
![CDATA[
var myInstance = new myClass();
]]
/mx:Script

but then i get some compilation error a class's instance variable may
not be initialized to compile-time constant expressions.

Can someone tell me how to create an instance of myClass ?

Thanks in advance,

Chiel Pauw
Amsterdam






 Yahoo! Groups Sponsor ~--
font face=arial size=-1a
href=http://us.ard.yahoo.com/SIG=12hpdggqf/M=362335.6886445.7839731.151
0227/D=groups/S=1705007207:TM/Y=YAHOO/EXP=1124385839/A=2894361/R=0/SIG=1
3jmebhbo/*http://www.networkforgood.org/topics/education/digitaldivide/?
source=YAHOOcmpgn=GRPRTP=http://groups.yahoo.com/;In low income
neighborhoods, 84% do not own computers. At Network for Good, help
bridge the Digital Divide!/a./font
~- 

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



 




 Yahoo! Groups Sponsor ~-- 
font face=arial size=-1a 
href=http://us.ard.yahoo.com/SIG=12h4h5lle/M=362329.6886308.7839368.1510227/D=groups/S=1705007207:TM/Y=YAHOO/EXP=1124386605/A=2894321/R=0/SIG=11dvsfulr/*http://youthnoise.com/page.php?page_id=1992
Fair play? Video games influencing politics. Click and talk back!/a./font
~- 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
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:
http://docs.yahoo.com/info/terms/