2013-02-20 124 views
0

我有一个主要的swf文件。它有一个简单的空白影片剪辑,实例名称为mc_external_swf。加载外部swf - 尺寸不正确

现在我使用文档类来加载外部swf文件。外部文件加载并且可见,但其尺寸不适合在movieclip容器内部,外部swf中的某些内容与movieclip容器外部重叠。看下面的图片。

这是用于加载外部swf文件的代码。

var _swfLoader:Loader; 
    var _swfContent:MovieClip; 

    function goToPlay(e:MouseEvent=null):void 
    { 
     loadSWF("agameFLA.swf"); 
    }  


    public function loadSWF(path:String):void 
    { 
     var _req:URLRequest = new URLRequest(); 
     _req.url = path; 

     _swfLoader = new Loader(); 
     setupListeners(_swfLoader.contentLoaderInfo); 

     _swfLoader.load(_req); 
    } 

    function setupListeners(dispatcher:IEventDispatcher):void 
    { 
     dispatcher.addEventListener(Event.COMPLETE, addSWF); 
    } 

    function addSWF(event:Event):void 
    { 
     event.target.removeEventListener(Event.COMPLETE, addSWF); 
     event.target.removeEventListener(ProgressEvent.PROGRESS, preloadSWF); 
     _swfContent = event.target.content; 
     mc_external_swf.addChild(_swfContent); 
    } 

这里是外部文件本身的代码 - (其文档类)

package 
{ 
import away3d.cameras.Camera3D; 
import away3d.cameras.lenses.PerspectiveLens; 
import away3d.containers.ObjectContainer3D; 
import away3d.containers.Scene3D; 
import away3d.containers.View3D; 
import away3d.controllers.HoverController; 
import away3d.entities.Mesh; 
import away3d.materials.ColorMaterial; 
import away3d.primitives.CubeGeometry; 

import flash.display.MovieClip; 

public class Main extends MovieClip 
{ 
    public var _view : View3D; 
    private var _scene:Scene3D; 
    private var _camera : Camera3D; 
    private var _hoverController:HoverController; 

    private var _container:ObjectContainer3D; 
    private var _cube:CubeGeometry; 
    private var _cubeMaterial:ColorMaterial; 
    private var _cubeMesh:Mesh; 

    public function Main() 
    { 
     addEventListener(Event.ADDED_TO_STAGE,init); 
    } 

    private function init(e:Event):void 
    { 
     removeEventListener(Event.ADDED_TO_STAGE,init); 
     iniScene(); 
     iniObjects(); 
    } 

    private function iniScene():void 
    {   
     _scene = new Scene3D(); 

     _view = new View3D(); 
     _view.backgroundColor = 0x666666; 
     _view.antiAlias = 4; 

     _camera= new Camera3D(); 
     _camera.lens = new PerspectiveLens(60); 
     _hoverController = new HoverController(_camera, null, 180, 0); 
     _hoverController.distance = 400; 
     _hoverController.steps = 16; 
     _view.camera = _camera; 

     this.addChild(_view); 
    } 

    private function iniObjects():void 
    { 
     _container = new ObjectContainer3D(); 
     _cube = new CubeGeometry(100, 100, 100, 20, 20, 20); 

     _cubeMaterial = new ColorMaterial(0x0000FF); 

     _cubeMesh = new Mesh(_cube, _cubeMaterial); 
     _cubeMesh.mouseEnabled = true; 
     _container.addChild(_cubeMesh); 
     _view.scene.addChild(_container); 
     this.addEventListener(Event.ENTER_FRAME, _onEnterFrame); 
     _onResize(); 
    } 

    private function _onResize(e:Event=null):void 
    { 
     _view.width = stage.stageWidth; 
     _view.height = stage.stageHeight; 
    } 

    private function _onEnterFrame(e:Event):void 
    { 
     _view.render(); 
    } 
} 

}

screenshot

它可能会发生在Away3D中图书馆。我试图加载其他的swfs,但它们都很好。但是这个swf尤其不适合在动画片段容器中。我认为这与away3中的view3d有关,但我不确定。

回答

0

,我已经看到已经包括在主类下面的代码上的Stage3D所有教程(或库如Away3D中):

public function Main() 
{ 
    //wait until stage object is ready 
    addEventListener(Event.ADDED_TO_STAGE, addedHandler); 
} 

private function addedHandler(event:Event):void 
{ 
    removeEventListener(Event.ADDED_TO_STAGE, addedHandler); 
    stage.align = "TL"; //or use StageAlign.TOP_LEFT; 
    stage.scaleMode = "noScale"; //or use StageScaleMode.NO_SCALE; 
} 

它将从缩放停止瑞士法郎。

+0

已经试过了。他们似乎都没有工作。另外,当我使用object.x或object.y定位一个对象时,它将自己定位在主要的swf坐标系上,而不是本地的。 (如果你明白的话) – 2013-02-22 21:55:37