Actionscript 3 Actionscript 3.0在不影响孩子的情况下调整家长的大小

Actionscript 3 Actionscript 3.0在不影响孩子的情况下调整家长的大小,actionscript-3,Actionscript 3,我有一个包含多个孩子的家长电影剪辑。 如何调整父对象的大小而不影响子对象的movieClip 备注:孩子们必须和父母住在一起 import flash.display.MovieClip; import flash.events.MouseEvent; /*The parents*/ var motherFather:MovieClip = new MovieClip(); motherFather.graphics.beginFill(0xAA0022); motherFather.grap

我有一个包含多个孩子的家长电影剪辑。
如何调整父对象的大小而不影响子对象的movieClip

备注:孩子们必须和父母住在一起

import flash.display.MovieClip;
import flash.events.MouseEvent;

/*The parents*/
var motherFather:MovieClip = new MovieClip();
motherFather.graphics.beginFill(0xAA0022);
motherFather.graphics.drawCircle(40, 40, 40);
motherFather.width=100
motherFather.height=100
motherFather.x=10
motherFather.y=60

addChild(motherFather);
  for (var i:Number=1; i<=6;i++){
   var children:MovieClip = new MovieClip();
   children.graphics.beginFill(0xFF0260);
   children.graphics.drawCircle(40, 40, 40);
   children.width=30
   children.height=30
   children.x=10 +(i*30)
   children.y=50
   motherFather.addChild(children);


  }
//CLICK ON STAGE TO RESIZE THE PARENT.
motherFather.addEventListener(MouseEvent.CLICK, ResizeParent);
function ResizeParent(e:MouseEvent){
 motherFather.width+=150;

}
导入flash.display.MovieClip;
导入flash.events.MouseEvent;
/*父母*/
var motherFather:MovieClip=新MovieClip();
motherFather.graphics.beginll(0xAA0022);
爸爸妈妈。图形。画圈(40,40,40);
爸爸妈妈。宽度=100
爸爸妈妈。身高=100
爸爸妈妈。x=10
爸爸妈妈。y=60
addChild(母亲父亲);
对于(变量i:Number=1;i给你:

import flash.display.MovieClip;
import flash.events.MouseEvent;

/*The parents*/
var motherFather:MovieClip = new MovieClip();
addChild(motherFather);

var fill:MovieClip = new MovieClip();
fill.graphics.beginFill(0xAA0022);
fill.graphics.drawCircle(40, 40, 40);
fill.width=100
fill.height=100
fill.x=10
fill.y=60

motherFather.addChild(fill);

  for (var i:Number=1; i<=6;i++){
   var children:MovieClip = new MovieClip();
   children.graphics.beginFill(0xFF0260);
   children.graphics.drawCircle(40, 40, 40);
   children.width=30
   children.height=30
   children.x=10 +(i*30)
   children.y=50
   motherFather.addChild(children);

   addChild(new MovieClip());
  }
//CLICK ON STAGE TO RESIZE THE PARENT.
motherFather.addEventListener(MouseEvent.CLICK, ResizeFill);
function ResizeFill(e:MouseEvent){
 fill.width+=150;
}
导入flash.display.MovieClip;
导入flash.events.MouseEvent;
/*父母*/
var motherFather:MovieClip=新MovieClip();
addChild(母亲父亲);
变量填充:MovieClip=新的MovieClip();
fill.graphics.beginll(0xAA0022);
填充。图形。画圈(40,40,40);
填充宽度=100
填充高度=100
填充。x=10
填充y=60
母亲父亲。添加孩子(填充);

对于(VarI:Number=1;i而言,除了透明度之外,与Richards的答案或多或少相似

您只需将透明背景添加到您的motherFather MovieClip并调整其大小,而不是调整motherFather MovieClip本身的大小

var background:Shape = new Shape();
background.name = "background";

background.graphics.beginFill( 0 , 0 );
//add the rest of the graphics functions

motherFather.addChild(background );

function resize(event:MouseEvent):void
{
    motherFather.getChildByName("background").with += 150;
}

此外,如果您只想创建形状,则无需使用MovieClips,为孩子使用形状实例,为容器使用精灵。

也可以作为motherFather的孩子填充。你是什么意思?我已经有了motherFather.addChild(children);子项现在不可见您是否将代码复制到结尾?请检查代码结尾是否有“}”。因为它对我非常有效!为什么要使用
addChild(new MovieClip())添加一堆空MovieClip
?这真的有用吗?非常感谢你的建议。我仍然喜欢使用movieClip,因为它提供了更多的选项,性能也不错。透明度的想法很好。谢谢