使用actionscript3绘制一系列矩形

时间:2014-09-16 09:03:17

标签: xml actionscript-3 drawing flash

我正在尝试使用actionscript3绘制一系列矩形。我使用XML

检索我的信息。
<onlineTrain>
  <sensor>

    <xlocation>13</xlocation>
    <ylocation>307</ylocation>

  </sensor>
  <sensor>

    <xlocation>121</xlocation>
    <ylocation>301/ylocation>

  </sensor>
</onlineTrain>

所以我将这些值放在foreach

for each(var element:XML in xml.sensor)
{
    var sp:Sprite = new Sprite();
   addChild(sp);
  sp.x =element.xlocation;
  sp.y = element.ylocation;
  var g:Graphics = sp.graphics;
  g.lineStyle(1, 0x0000FF);
  g.drawRoundRect(0, 0, 100, 60, 15);

}

但它没有用。任何想法都会受到赞赏。我是AS3中的新人

1 个答案:

答案 0 :(得分:0)

试试这个

sp.x = int(element.location[0]);
sp.y = int(element.location[1]);

或者您可以看到此示例xml example

相关问题