0 Replies Latest reply on Oct 18, 2011 7:46 PM by xtempore

    Problems drawing directly on Spark components


      I've just started experimenting with Flash Builder, and had a simple example up and running well.  All it did was draw shapes when I clicked onto the canvas.


      But then I noticed that Flash Builder was telling me that I shouldn't be using mx:Canvas, but rather the Spark equivalent, BorderContainer.


      So I changed it.  Everything still compiled okay, but the drawn items no longer appeared on the screen.  No errors were given, and if I debug I can see that the code is still being executed, but nothing shows.


      I simplified it down as much as I could, but still nothing...


      var g: Graphics = area.graphics;
      g.beginFill(255, 1);
      g.drawRect(10, 10, 210, 210);


      I tried finding answers in various places, and found some documentation that suggested the best thing to draw on (for my needs) was a Shape.  So I created a Shape object, and tried adding that to the BorderContainer.  All that did was result in an run-time error...

      Error: addChild() is not available in this class. Instead, use addElement() or modify the skin, if you have one.


      Okay, so I tried addElement, which gave me a compile-time error...

      1067: Implicit coercion of a value of type flash.display:Shape to an unrelated type mx.core:IVisualElement.


      This can't be that hard.  All I want to do is create an application which can respond to mouse events and create visual elements.


      Any help greatly appreciated!