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";>
> 
> 
> <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; 
>        }
> }
> ------------------------------------------------------------





------------------------ 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/
 



Reply via email to