haXe Forum > Invalid commandline class???

  • I get this error:
    Invalid commandline class : Main should be sg.hxf.tut.chap01.Main

    I tried making the Main function like this:
    sg.hxf.tut.chap01.Main() and
    sg.hxf.tut.chap01.main()

    but I get an error that says unexpected "." after the sg

    I am trying to learn haXe but its kinda hard. Hey I'm getting there!

    package sg.hxf.tut.chap01;
    
    import flash.display.MovieClip;
    import flash.display.Graphics;
    import flash.display.Shape;
    
    import sg.hxf.Graph;
    
    class Demo01 {
      static var mc : MovieClip;
    
      static function main() {
        mc = flash.Lib.current;
        var figures:Shape = new Shape();
        // draw a rectangle
        var g : Graphics = figures.graphics;
        g.lineStyle(2,0xFF0000);
        g.drawRect(5,5,45,35);
        // draw a circle
        g.lineStyle(2,0x0000FF);
        g.drawCircle(70,20,15);
        // draw a rounded rect
        g.lineStyle(2,0x00FF00);
        g.drawRoundRect(90,5,30,30,10,10);
        mc.addChild(figures);
      }
    }
  • Matt
    My by example may help with learning haXe flash. If you want me to add to byexamples let me know, and I will try to add something on a topic you request.
    Cheers ;j

  • Filename and classname are not the same, thats why you example does not work.

  • Main.hx

    package com.example;
    class Main
    {
        public static function main()
        {
        }
    }
    You need to use com.example.Main in the hxml , not Main. (and also what Philippe says)

    build.hxml:

    com.example.Main
    -main com.example.Main
    -swf9 test.swf

    Jan

< Prev | Page 1 / 1 | Next >