Обновление: не уверен, что этот код будет работать, но не может получить имя спрайта, где c.getChildByName(spName)
- ноль, spName
- строковое имя спрайта.
private var s:Sprite;
private var s2:Sprite;
private var c:UIComponent;
private var c2:UIComponent;
private function drawQuarterNotes(xx:int,ty:String):void {
if(ty=="up") {
s = new Sprite();
s2 = new Sprite();
c = new UIComponent();
c2 = new UIComponent();
s2.graphics.lineStyle(3,0x333333);
s2.graphics.moveTo(20,0);
s2.graphics.lineTo(20,50);
c2.addChild(s2);
c2.x = xx+16;
c2.y = xx-18;
s.graphics.beginFill(0x333333);
s.graphics.drawEllipse(7,35,18,12);
s.graphics.endFill();
s.name = "asd2";
s.addEventListener(MouseEvent.MOUSE_DOWN,chgColor);
s.addEventListener(MouseEvent.MOUSE_UP,chgColorReset);
c.addChild(s);
c.rotation = -20;
c.x = xx;
c.y = xx;
}
if(ty=="down") {
s2.graphics.lineStyle(3,0x333333);
s2.graphics.moveTo(20,0);
s2.graphics.lineTo(20,50);
c2.addChild(s2);
c2.x = xx+1;
c2.y = xx+35;
s.graphics.beginFill(0x333333);
s.graphics.drawEllipse(7,35,18,12);
s.graphics.endFill();
c.addChild(s);
c.rotation = -20;
c.x = xx;
c.y = xx;
}
addElement(c);
addElement(c2);
}
private function drawQuarterNotes2(xx:int,ty:String):void {
if(ty=="up") {
s = new Sprite();
s2 = new Sprite();
c = new UIComponent();
c2 = new UIComponent();
s2.graphics.lineStyle(3,0x333333);
s2.graphics.moveTo(20,0);
s2.graphics.lineTo(20,50);
c2.addChild(s2);
c2.x = xx+16;
c2.y = xx-18;
s.graphics.beginFill(0x333333);
s.graphics.drawEllipse(7,35,18,12);
s.graphics.endFill();
s.name = "asd1";
s.addEventListener(MouseEvent.MOUSE_DOWN,chgColor);
s.addEventListener(MouseEvent.MOUSE_UP,chgColorReset);
c.addChild(s);
c.rotation = -20;
c.x = xx;
c.y = xx;
}
if(ty=="down") {
s2.graphics.lineStyle(3,0x333333);
s2.graphics.moveTo(20,0);
s2.graphics.lineTo(20,50);
c2.addChild(s2);
c2.x = xx+1;
c2.y = xx+35;
s.graphics.beginFill(0x333333);
s.graphics.drawEllipse(7,35,18,12);
s.graphics.endFill();
c.addChild(s);
c.rotation = -20;
c.x = xx;
c.y = xx;
}
addElement(c);
addElement(c2);
}