Domanda

I am a beginner with using AS3 and as3isolib. I am trying to add some MC from the fla library into an isoGrid object. I tried to use addChild() method of the IsoGrid class but it gave me an error saying: 1067: Implicit coercion of a value of type [MovieClip Name] to an unrelated type as3isolib.data:INode. Which I think wants me to use the node class.

Any idea how to do such a thing?

Thank you in advance.

È stato utile?

Soluzione

as3isolib use it's own display list like rendering tree, add all nodes in this tree must implements as3isolib.data:INode. There are two possibility to add flash native display objects to the IsoScene:

Take a look on this small tutorial:

    //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();
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top