如何调整Swf内部的Swf大小?

时间:2011-11-07 07:54:39

标签: flash actionscript-3 resize

  我尝试在swf(video.swf)中加载一个swf(text.swf)。在我的(text.swf)中,我传递了一些文本。而我调整了(text.swf),文本里面的文本( text.swf)是Changed.Without更改内容如何调整(text.swf)?实际上我的text.swf大小是400 * 44px。如果我单独运行text.swf大小很小但是当我添加到(video.swf)text.chat的大小非常大。所以我只调整了text.swf的大小,但是?(text.swf)里面的内容也发生了变化。我怎么能解决这个问题?有人帮帮我

提前致谢 在这里我的编码

     _loader.load(new URLRequest("text.swf"));
     _loader.x=(((_stage.stageHeight)/100)*0.1);
     _loader.y=(((_stage.stageWidth)/100)*49);
     _loader.height=((_stage.stageWidth)/25);
     _loader.width=(((_stage.stageWidth)));

     mainContainer.addChild(_loader);

1 个答案:

答案 0 :(得分:1)

下次尝试格式化您的问题文本(添加一些换行符,在。之后使用空格,并在提交之前检查它在预览中的外观)。

以下代码可能对您有所帮助:

/**
 * Reset text to original scale
 */
function resetTextScaling(aContainer: DisplayObjectContainer): void
{
  for(var index: int = aContainer.numChildren; index--; )
  {
    var child: DisplayObject = aContainer.getChildAt(index);
    if (child is TextField)
    {
      var parentMatrix: Matrix = child.parent.transform.concatenatedMatrix;
      // calc area of child as visible
      var childWidth: Number = child.width * parentMatrix.a / child.scaleX;
      var childHeight: Number = child.height * parentMatrix.d / child.scaleY;
      // restore original font size
      child.scaleX /= parentMatrix.a;
      child.scaleY /= parentMatrix.d;
      // resize child so it still uses the same area 
      child.width = childWidth;
      child.height = childHeight;
    }
    else if (child is DisplayObjectContainer)
    {
      // process children
      resetTextScaling(child as DisplayObjectContainer);
    }
  }
}

// make this call after _loader has been added to the stage 
// and has completed loading
resetTextScaling(_loader);
相关问题