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