[Papervision3D] upcasting DisplayObject3D
Ralph Hauwert
r.hauwert at gmail.com
Mon Apr 2 05:37:43 EDT 2007
Ron,
I'm not sure I'm totally following, but your code shows that you want
to cast the Cube class to a Block class. (the oScene.addChild(oCube)
would return the add cube object).
Regards,
Ralph.
On 4/2/07, Ron Valstar <ron at sjeiti.com> wrote:
> I have a class containing numerous cubes. Now I want to store the
> gridposition (=position*size) in the cubes.
> I tried to make a class Block that extends the DisplayObject3D but I
> can't seem to cast the DisplayObject3D to Block.
>
> The Block class looks like this:
>
> package com.sjeiti.cubejunky {
> import org.papervision3d.objects.DisplayObject3D;
> import org.papervision3d.core.proto.GeometryObject3D;
> public class Block extends DisplayObject3D {
> public var iX:int;
> public var iY:int;
> public var iZ:int;
> public function Block( name:String=null,
> geometry:GeometryObject3D=null, initObject:Object=null ):void {
> super(name,geometry,initObject);
> }
> }
> }
>
> I tried to cast it like this:
>
> var oCube:Mesh3D = new
> Cube(aMat[iType],iBlockSize,iBlockSize,iBlockSize,1,1,1);
> //var mCube:DisplayObject3D = oScene.addChild( oCube );
> var mBlock:Block = (Block)( oScene.addChild(oCube) );
>
> And I get this error:
>
> TypeError: Error #1034: Type Coercion failed: cannot convert
> org.papervision3d.objects::Cube at ab200d1 to com.sjeiti.cubejunky.Block.
>
> I could of course easily make a container class where the
> DisplayObject3D is a public variable, but I just thought extending would
> look much nicer.
>
> anybody have a solution?
>
>
> thanks...
>
> Ron
>
>
> _______________________________________________
> Papervision3D mailing list
> Papervision3D at osflash.org
> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>
--
Ralph Hauwert
FlashCoder
More information about the Papervision3D
mailing list