One more suggestion: In the Application tag, declare the default namespace: xmlns="*"
-----Original Message----- From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Jeff Tapper Sent: Friday, August 26, 2005 9:31 AM To: [email protected] Subject: Re: [flexcoders] Re: Loading classes Above and beyond that, there are a few bugs which need to be fixed. 1. Case Sensitivity - DrawIcons has properties xValue and yValue, but yet the constructor references Xvalue and YValue 2. Scope issues. - DrawIcons has no concept of MyCanves (referenced in createSquare()). By adding an argument to createSquare, in which you pass the canvas can solve this. 3. DrawIcons isnt a subclass of MovieClip, UIObject or any other class which has a method called getNextHighestDepth(). We'll need to change that reference to the canvas passed into createSquare. The modified codebase, which works fine, looks like this: DrawIcons.as ===== //Class definition class DrawIcons{ var xValue:Number; var yValue:Number; //Contractor function DrawIcons(cordiX:Number,cordiY:Number){ this.xValue=cordiX; this.yValue=cordiY; } //Drawing square function createSquare(mc) { var square_mc:MovieClip; square_mc = mc.createEmptyMovieClip("square_mc",mc.getNextHighestDepth()); square_mc.lineStyle(1, 0x000000, 100); square_mc.beginFill(0xFF0000, 100); square_mc.moveTo(0, 0); square_mc.lineTo(50, 0); square_mc.lineTo(50, 50); square_mc.lineTo(0, 50); square_mc.lineTo(0, 0); square_mc.endFill(); square_mc._x = this.Xvalue; square_mc._y = this.Yvalue; } } Square.mxml ===== <mx:Application width="800" height="600" xmlns:mx="http://www.macromedia.com/2003/mxml"> <mx:Script> <![CDATA[ function callDrawIcons(){ var Square1:DrawIcons = new DrawIcons(100, 200); var Square2:DrawIcons = new DrawIcons(100, 300); Square1.createSquare(MyCanves); Square2.createSquare(MyCanves); } ]]> </mx:Script> <mx:Canvas id="MyCanves" width="600" height="400" initialize="callDrawIcons()"/> </mx:Application> At 08:53 AM 8/26/2005, Kevin Broce wrote: >The Flex server is not compiling your Class file because FlexBuilder >is not copying it to the Flex server. Only "squares.mxml" is >getting compliled and since there is no "DrawIcons" Class present, >it "could not be loaded". > >Add the following code to the top of your Script block >in "squares.mxml": > > import DrawIcons.as; > >This triggers FlexBuilder to copy your Class file to the Flex server >whenever it changes. > >Once the Flex server has a copy of DrawIcons.as, it will compile it >and show you your errors. For example, Flex is "case-sensitive", >and your variable names are not, so Flex will complain about that. > > >--- In [email protected], Prasad Dhananjaya <[EMAIL PROTECTED]> >wrote: > > Hi All, > > > > I want to draw two squares inside the canves. > > I define "DrawIcons"class. My class file and MXML file is in the >same > > directory. When I run this, it says "The class "DrawIcons()"could >not > > be loaded" (line of error is "var Square1:DrawIcons = new DrawIcons >(100, 200);") > > Can someone please tell me what's the wrong with this code? > > > > Thanks, > > Prasad > > (Absolute beginner of > > Flex & ActionScript, > > Studying using of classes) > > > > ------------------square.mxml----------------------- > > <mx:Application width="800" height="600" >xmlns:mx="<http://www.macromedia.com/2003/mxml>http://www.macromedia.co m/2003/mxml"> > > > > > > <mx:Script> > > <![CDATA[ > > function callDrawIcons(){ > > var Square1:DrawIcons = new DrawIcons(100, 200); > > var Square2:DrawIcons = new DrawIcons(100, 300); > > Square1.createSquare(); > > Square2.createSquare(); > > } > > ]]> > > </mx:Script> > > > > <mx:Canvas id="MyCanves" width="600" height="400" >initialize="callDrawIcons()"></mx:Canvas> > > </mx:Application> > > > > ------------------------------------------------------- > > > > > > -----------------DrawIcons.as-------------------------- > > //Class definition > > class DrawIcons { > > var xValue:Number; > > var yValue:Number; > > > > //Contractor > > function DrawIcons(cordiX:Number,cordiY:Number){ > > this.Xvalue=cordiX; > > this.Yvalue=cordiY; > > } > > //Drawing square > > function createSquare() { > > var square_mc:MovieClip; > > square_mc = MyCanves.createEmptyMovieClip >("square_mc",getNextHighestDepth()); > > square_mc.lineStyle(1, 0x000000, 100); > > square_mc.beginFill(0xFF0000, 100); > > square_mc.moveTo(0, 0); > > square_mc.lineTo(50, 0); > > square_mc.lineTo(50, 50); > > square_mc.lineTo(0, 50); > > square_mc.lineTo(0, 0); > > square_mc.endFill(); > > > > square_mc._x = this.Xvalue; > > square_mc._y = this.Yvalue; > > } > > } > > ------------------------------------------------------------ > > > > > >-- >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.com>http://www.ma il-archive.com/flexcoders%40yahoogroups.com > > > > >---------- >YAHOO! GROUPS LINKS > > * Visit your group > "<http://groups.yahoo.com/group/flexcoders>flexcoders" on the web. > * > * To unsubscribe from this group, send an email to: > * > <mailto:[EMAIL PROTECTED]>flexc [EMAIL PROTECTED] > > * > * Your use of Yahoo! Groups is subject to the > <http://docs.yahoo.com/info/terms/>Yahoo! Terms of Service. > > >---------- -- 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 --------------------~--> Fair play? Video games influencing politics. Click and talk back! http://us.click.yahoo.com/T8sf5C/tzNLAA/TtwFAA/nhFolB/TM --------------------------------------------------------------------~-> -- 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/

