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

发布于 2024-11-05 19:26:14 字数 934 浏览 5 评论 0原文

我想将外部 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);
}

谢谢

I want to load an external swf file into my project. My project is much smaller than the project I am loading in and I need to make the external swf file smaller to fit. Whenever I added the myLoader.width and myLoader.height the project cannot be seen. If I take it away the myLoader.width and myLoader, the project will load fine but it is too big.

here is my code,

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);
}

thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

番薯 2024-11-12 19:26:14

我想你想要 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);
}

I think you want myLoader.content.width = 100;

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

*edit

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);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文