Hello, about get bitmapdata from a bitmap, did you try get it through bitmapData property? In your case, maybe roadcolor.bitmapData.
Best, F On Mon, Apr 6, 2009 at 12:26 PM, Florent <[email protected]> wrote: > > Hi, > > I didn't want to create a new topic as I encounter the same > problem... > The only thing is I have some errors. > I am trying to compile the sample code given in the tutorial, but > my > compiler (either Flash CS4 IDE or FlashDevelop with Flex SDK) keep > telling me that the "elevation" variable is undefined or (with > Hamak's > above code) "Error: Can't cast to bitmap: roadcolor"... > > Here is a part of "my" code.. I think the problem is in the Embed > part, and I'm quite noob at Bitmap(Data) in ActionScript... > > [Embed(source = '../elevate2.jpg')] private var > RoadColor:Class; > private var roadcolor:Bitmap = new RoadColor(); > [Embed(source = '../elevate3.jpg')] private var > EleVation:Class; > private var elevation:Bitmap = new EleVation(); > > // ------------------ MAIN FUNCTION > -------------------- > public function Main():void { > init3D(); > build(); > //build2(); > //init(); > } > > // ---------- ELEVATION & MOUNTAIN GENERATION > ----------- > > private function imageFromLib > (source_ID:String):BitmapData { > var classRef:Class = > getDefinitionByName(source_ID) as Class; > return new classRef(classRef.width, > classRef.height); > } > > private function build():void { > var source_elevation:BitmapData = > imageFromLib("elevation"); > var mat:IMaterial = new > BitmapMaterial(imageFromLib("roadcolor") , > {smooth:true}); > var elevate:Elevation = new > Elevation(); > extrude = new SkinExtrude > (elevate.generate(source_elevation, "r", > 5, 5, 50, 50, 4), {material:mat, recenter:true, closepath:false, > coverall:true, subdivision:1, bothsides:false, flip:true}); > extrude.rotationX = 90; > this.scene.addChild(extrude); > } > > private function build2():void { > var mat:BitmapMaterial = new BitmapMaterial > (Cast.bitmap("roadcolor") , {smooth:true}); > var elevate:Elevation = new Elevation(); > extrude = new SkinExtrude(elevate.generate > (Cast.bitmap("elevation"), "r", 5, 5, 50,50, 4), {material:mat, > recenter:true, closepath:false, coverall:true,subdivision:1, > bothsides:false, flip:true}); > view.scene.addChild(extrude); > //extrude.rotationX = 90; > plane = new Cube( { depth:10, width:600, > height:1000, y:50, x:10, > z:10 } ); > //view.scene.addChild(plane); > var m:BitmapMaterial = new BitmapMaterial > (Cast.bitmap("elevation"), > { smooth:true, precision:1 } ); > plane.material = m; > } > > > Thanks for helping > > ------------------------------------------------- > > EDIT : I now know that the problem is that elevation is not a > BitmapData... I'm sorry but I really don't know how to correct that > problem, I can't just change Bitmap into BitmapData... Can anyone > explain/correct/give me a good tutorial on that ? I tried reading > documentations on various classes but I appear to be lost... -- Fábio Pinatti :: web.developer :::: www.pinatti.com.br :::::: 19. 9184.3745 / 3342.1130
