2 Replies Latest reply on Dec 11, 2010 5:54 PM by pauland

    What's wrong with my class?

    SiHoop Level 1

      I have the following in a component that's a Canvas and it works perfectly:


                  ungradedMark(100, 100);

                  public function ungradedMark(_x:Number, _y:Number):void{
                      var image:Image=new Image();
                      image.source="images/geoOnOff.jpg";
                      image.x=_x
                      image.y=_y
                      this.addChild(image)
                  }

       

      However, if I put the function into its own class file, the image won't show. I assume that I'm missing something very basic. What's my error? Is there a different way that I should be writing the class?

       

      Thank you.

       

            var _addGradingMark:GradingMarks_;

            _addGradingMark.ungradedMark(100, 100);

       

      package {
          import mx.containers.Canvas;   
          import mx.controls.Image;
          public class GradingMarks_ extends Canvas{

       

              public function GradingMarks_(){
              }
              public function ungradedMark(_x:Number, _y:Number):void{
                  var image:Image=new Image();
                  image.source="images/geoOnOff.jpg";
                  image.x=_x
                  image.y=_y
                  this.addChild(image)
              }
          }
      }