2

我有一张由里面的 MovieClip 城市组成的地图,我在地图 MovieClip 的顶层有一个点击功能。如果我单击一个城市,我会尝试这样做,将绘制一个矩形。这是代码:

function rpress(a)
{
trace( "trying" );

    var b:MovieClip = new MovieClip();
    b.graphics.beginFill(0xFF0000);
    b.graphics.drawRect(0,0,100,80);
    b.graphics.endFill();
    b.x = 150;
    b.y = 150;
    addChild( b );
trace("done")
}

执行跟踪命令但不绘制矩形。我试过MovieClip( root ).addChild..., stage.addChild..., MovieClip( parent ).addChild...了,其他人...

你有什么主意吗?谢谢!

完整代码:

双击地图MovieClip->84层欢迎我们->选择名为“Action Layer”的层ACTIONS-FRAME:

function rbtxt(a)
{
    var _loc2 = a;
    var _loc3 = this;
    balon._visible = true;
    arbtxt = ilad.split(",");
    balon.txt.text = arbtxt[_loc2];
    _loc3["x" + _loc2].play();
    balon._x = _loc3["x" + _loc2]._x;
    balon._y = _loc3["x" + _loc2]._y - _loc3["x" + _loc2]._height / 2 + 5;
}
//End of the function
function rbalon(a)
{
    balon._visible = false;
    this["x" + a].gotoAndStop(1);
}
//End of the function
function rpress(a)
{
trace( "trying" );

    var b:MovieClip = new MovieClip();
    b.graphics.beginFill(0xFF0000);
    b.graphics.drawRect(0,0,100,80);
    b.graphics.endFill();
    b.x = 150;
    b.y = 150;
    addChild(b );
trace("done")
}

ilad = "CITY NAMES....."
ilurl = "CITY URLS....."
4

3 回答 3

1

您没有显示足够的代码,所以我们只能猜测。通过查看您提供的信息,您可以尝试:

this["x" + a].addChild( b );

或者

balon.addChild( b );

但这只是猜测...

于 2012-08-03T22:26:51.170 回答
1

嗨尝试将影片剪辑添加到舞台,然后像这样执行绘图camamnd

 var b:MovieClip = new MovieClip();
    addChild(b );
    b.graphics.beginFill(0xFF0000);
    b.graphics.drawRect(0,0,100,80);
    b.graphics.endFill();
    b.x = 150;
    b.y = 150;
于 2012-08-04T11:58:27.067 回答
0

Sprite 可以访问图形,尝试仅将 Movieclip 用于复杂对象,例如加载的 SWF 和具有基于时间轴的动画和变量等的 Flash 库资源

function drawRect()
{
    trace( "trying" );

    //var b:MovieClip = new MovieClip();
    var b:Sprite = new Sprite();
    b.graphics.beginFill(0xFF0000);
    b.graphics.drawRect(0,0,100,80);
    b.graphics.endFill();
    b.x = 150;
    b.y = 150;
    addChild( b );
    trace("done")
}
于 2012-08-03T22:34:26.447 回答