2014-01-13 17 views
0

我是使用AS3和as3isolib的初学者。我正在试图将fla库中的一些MC添加到isoGrid对象中。我尝试使用IsoGrid类的addChild()方法,但它给了我一个错误:1067:将类型[MovieClip Name]的值隐式强制为不相关的类型as3isolib.data:INode。我认为我想要使用节点类。如何将moiveClip附加到as3isolib网格中?

任何想法如何做这样的事情?

预先感谢您。

回答

1

as3isolib使用它自己的display list就像渲染树一样,添加树中的所有节点必须实现as3isolib.data:INode。有两种可能性闪光灯本地显示对象添加到IsoScene

看看这个小教程:

//create IsoView, IsoScene and IsoGrid - default from as3isolib 
    var view:IsoView = new IsoView(); 
    view.setSize(stage.stageWidth, stage.stageHeight); 
    addChild(view); 

    var scene:IsoScene = new IsoScene(); 
    view.addScene(scene); 

    var grid:IsoGrid = new IsoGrid({cellSize:32}); 
    grid.setGridSize(800, 600); 
    grid.stroke = new Stroke(0, 0x576F33); 
    grid.render(); 

    //create iso box, just for demo 
    var obj:IsoBox = new IsoBox(); 
    obj.setSize(32, 32, 64); 
    obj.moveTo(5*32, 5*32, 1); 

    //first possiblity to add flash.display.Shape to the iso scene - using IsoSprite.sprites 
    var isoSprite:IsoSprite = new IsoSprite(); 
    isoSprite.moveTo(5*32, 7*32, 1); 

    var shape1:Shape = new Shape(); 
    shape1.graphics.beginFill(0xFF0000, 1); 
    shape1.graphics.drawRect(0, 0, 32, 32); 
    isoSprite.sprites = [shape1]; 

    //second possiblity to add flash.display.Shape to the iso scene - using IsoDisplayObject.container 
    var isoObj:IsoDisplayObject = new IsoDisplayObject(); 
    isoObj.moveTo(7*32, 7*32, 1); 

    var shape2:Shape = new Shape(); 
    shape2.graphics.beginFill(0x0000FF, 1); 
    shape2.graphics.drawRect(0, 0, 32, 32); 
    isoObj.container.addChild(shape2); 

    //add all objects to the scene and render all 
    scene.addChild(grid); 
    scene.addChild(obj); 
    scene.addChild(isoSprite); 
    scene.addChild(isoObj); 
    scene.render(); 
+0

这是我在寻找的答案。非常感谢我的朋友^^。 –