From the book “AdvancED Actionscript 3.0 Animation”
I fixed a problem in the code they give you that is using [Embed…] instead of using library objects with linkage names.
I still have the error:
TypeError: Error #1034: Type Coercion failed: cannot convert Tile_01@1bf93a61 to Class.
at GraphicTest$iinit()
With the following code…
public class GraphicTest extends Sprite
{
private var world:IsoWorld;
//[Embed(source="tile_01.png")]
//private var Tile01:Class;
private var Tile01 = new Tile_01();
public function GraphicTest()
{
world = new IsoWorld();
world.x = stage.stageWidth / 2;
world.y = 100;
addChild(world);
for(var i:int = 0; i < 20; i++)
{
for(var j:int = 0; j < 20; j++)
{
var tile:GraphicTile = new GraphicTile(20, Tile01, 20, 10);
tile.position = new Point3D(i * 20, 0, j * 20);
world.addChildToFloor(tile);
}
}
}
The GraphicTile Class is the following code…
package com.friendsofed.isometric
{
import flash.display.DisplayObject;
public class GraphicTile extends IsoObject
{
public function GraphicTile(size:Number, classRef:Class, xoffset:Number, yoffset:Number):void
{
super(size);
var gfx:DisplayObject = new classRef() as DisplayObject;
gfx.x = -xoffset;
gfx.y = -yoffset;
addChild(gfx);
}
}
}