如何指定外部swf的高度和宽度? AS3

时间:2011-05-05 19:45:07

标签: flash height width external loading

我想将外部swf文件加载到我的项目中。我的项目比我加载的项目小得多,我需要使外部swf文件更小以适应。每当我添加myLoader.width和myLoader.height时,都无法看到项目。如果我将myLoader.width和myLoader取消,该项目将加载正常,但它太大了。

这是我的代码,

stop();
home_btn.addEventListener(MouseEvent.CLICK, ClickButton2);
calm_btn.addEventListener(MouseEvent.CLICK, ClickButton2);
linden_btn.addEventListener(MouseEvent.CLICK, ClickButton2);
moving_btn.addEventListener(MouseEvent.CLICK, ClickButton2);

var myLoader:Loader=new Loader();

var xPos:Number = 45;

var yPos:Number = 85;

function ClickButton2(Event:MouseEvent):void

{

if(Event.target==home_btn)

{
    gotoAndStop("home");
}

else if(Event.target==calm_btn)
{
    gotoAndStop("calm");
    var myURL:URLRequest=new URLRequest("Project 2 Scott Parker FINAL.swf");
    myLoader.load(myURL);
    myLoader.x = xPos;
    myLoader.y = yPos;
    myLoader.width = 100;
    myLoader.height = 100;
    addChild(myLoader);
}

谢谢

1 个答案:

答案 0 :(得分:0)

我想你想要myLoader.content.width = 100;

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/Loader.html

*修改

function ClickButton2(event:MouseEvent):void

{

if(event.target==home_btn)

{
    gotoAndStop("home");
}

else if(event.target==calm_btn)
{
    gotoAndStop("calm");
    var myURL:URLRequest=new URLRequest("Project 2 Scott Parker FINAL.swf");
    myLoader.load(myURL);
    myLoader.x = xPos;
    myLoader.y = yPos;

    myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, function(){
        myLoader.content.width = 100;
        myLoader.content.height= 100;
    });

    addChild(myLoader);
}