Вы используете тот же экземпляр Sprite, поэтому при вызове метода shapeCreate()
он переопределяет его.
Вы должны определить столько спрайтов, сколько вам нужно, и применить создание фигур к ним отдельно, чтобы не было переопределения.
var c:UIComponent = new UIComponent();
//Creating the Sprite instances for the shapes
var s1:Sprite = new Sprite();
s1.name = "s1_sp";
var s2:Sprite = new Sprite();
s2.name = "s2_sp";
var s3:Sprite = new Sprite();
s3.name = "s3_sp";
private function shapeCreate(s:Sprite)
{
s.graphics.beginFill(0x333333);
s.graphics.drawEllipse(7,35,18,12);
s.graphics.endFill();
s.addEventListener(MouseEvent.MOUSE_DOWN,chgColorBlue);
s.addEventListener(MouseEvent.MOUSE_UP,chgColorReset);
c.addChild(s);
addElement(c);
}
private function chgColorBlue(e:MouseEvent):void {
//Just added this line to clear the old graphics
e.currentTarget.graphics.clear();
e.currentTarget.graphics.beginFill(0x000099);
e.currentTarget.graphics.drawEllipse(7,35,18,12);
e.currentTarget.graphics.endFill();
}
//Creating the shapes
shapeCreate(s1);
shapeCreate(s2);
shapeCreate(s3);
Я надеюсь, что это поможет, и это то, что вы хотели сделать.
Удачи,
Rob