I would rename the function from contentLoaderInfo since thats a reserved name. Also add an error event if that doesn't work, so you can see what the error may be (possibly sandbox etc).
-Pete On Wed, Jul 1, 2009 at 4:41 PM, away3dfan <[email protected]> wrote: > > I'm doing something wrong, but I'm not sure what it is. Here is my > code, from what I understand of as3, this should replace the texture > almost instantly, but the contentLoaderInfo() never gets called. The > code should be well-commented. Any idea why the function isn't > getting called or what else might be going wrong? > > Thanks again. > > ================================= > > package > { > import away3d.containers.View3D; > import away3d.lights.DirectionalLight3D; > import away3d.materials.BitmapFileMaterial; > import away3d.materials.PhongBitmapMaterial; > import away3d.primitives.Cube; > import away3d.primitives.Sphere; > import away3d.core.utils.Cast; > import away3d.core.base.Mesh; > import away3d.core.base.Face; > import away3d.core.base.Vertex; > import flash.events.Event; > > import flash.display.Bitmap; > import flash.display.Sprite; > > import flash.display.BitmapData; > import away3d.materials.BitmapMaterial; > > import away3d.materials.ColorMaterial; > > import flash.net.URLRequest; > import flash.display.Loader; > > [SWF(width="500", height="200", frameRate="60", > backgroundColor="#FFFFFF")] > public class Main extends Sprite > { > private var mycube:Cube; > private var my_loader:Loader; > private var my_url:URLRequest; > > public function Main() > { > // camera > var view:View3D = new View3D({x:250,y:100}); > addChild(view); > > // create cube > mycube = new Cube(); > mycube.width = 300; > mycube.height = 300; > mycube.depth = 300; > mycube.x = mycube.y = mycube.z = 0; > mycube.material = new BitmapMaterial(new > BitmapData(128, 128, > false, 0xFF0000)); > view.scene.addChild( mycube ); > > // begin load of new texture > my_loader = new Loader(); > my_url = new URLRequest("C:/pic.jpg"); > my_loader.load( my_url ); > // complete load, apply texture > > my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, > contentLoaderInfo); > > // lights > var light:DirectionalLight3D = new > DirectionalLight3D(); > view.scene.addChild(light); > light.y = 500; > light.x = -300; > light.z = -200; > > // render > view.render(); > } > > private function contentLoaderInfo():void > { > // I would replace this argument with my_url but I > get implicit > coercion errors: > mycube.material = new BitmapFileMaterial( > "C:/pic.jpg" ); > > // this line never changes the cube to green, which > means this > function is not getting called at all: > mycube.material = new BitmapMaterial(new > BitmapData(128, 128, > false, 0x00FF00)); > } > } > } > > On Jul 1, 4:25 pm, Fabrice3D <[email protected]> wrote: > > or cube.material = new BitmapFileMaterial(url); > > > > for an swf its indeed a flash basic loader, once loaded, pass the > > loader data to MovieMaterial as MovieClip > > > > Fabrice > > > > On Jul 1, 2009, at 10:01 PM, Peter Kapelyan wrote: > > > > > Let me know if this helps or is too vague: > > > > > 1. Make cube with some default Bitmapmaterial like this: > > > > > mycube.material=new BitmapMaterial(new BitmapData(128, 128, false, > > > 0xFF0000)); > > > > > 2. Load your jpg with URLRequest add contentLoaderInfo listener. > > > > > 3. On listener COMPLETE replace the bitmap something like this: > > > > > mycube.material.bitmap=event.target.content.bitmapData; > > > > > Let me know if it makes sense. There may be a shorter way, but this > > > is how I am used to doing it. > > > > > -Pete > > > > > On Wed, Jul 1, 2009 at 3:43 PM, away3dfan <[email protected]> > > > wrote: > > > > > Absolutely. I want to create a cube in actionscript similar to the > > > following (not tested for errors): > > > > > var c = new Cube({ width:300, height:300, depth:20} ); > > > > > Then I want to assign an image to one of the faces, the image should > > > rest in a URL, say, this one: > http://img.timeinc.net/time/photoessays/2008/world_water/water_01.jpg > > > > > Additionally, as I mentioned before, I would like to be able to apply > > > SWF files in the same way, but that's not as important, and I don't > > > know if it's even possible under away3d. > > > > > On Jul 1, 2:55 pm, Peter Kapelyan <[email protected]> wrote: > > > > Can you tell us exactly what you are trying to do, also I can try > > > to help. > > > > > > For instance > > > > > > > Make cube, > > > > Apply Bitmap Material > > > > Change Bitmap Material > > > > > > etc? > > > > > > Not quite sure what you mean by native as3 object jpgs (the ones > > > in the > > > > library?) > > > > > > -Pete > > > > > > On Wed, Jul 1, 2009 at 2:48 PM, away3dfan <[email protected]> > > > wrote: > > > > > > > Thanks for your time. > > > > > > > I've been on the api pages including > > > > >http://www.away3d.com/livedocs/away3d/loaders/data/ > > > MaterialData.html > > > > > trying half a dozen different loaders, flash.display.Loader, > > > > > away3d.loaders.data.MaterialData, etc., and looking at over 9000 > > > > > tutorials trying to intuit how it's done, but I didn't come up > > > with > > > > > anything specific to native as3 object jpgs (or other formats) > > > applied > > > > > directly to polygons, and for the life of me I can't figure out > > > how to > > > > > load one of these materials (or swfs) into away3d in this way. > > > > > > > Ideally, I would like to do both external images and reflected > > > data > > > > > streams (such as youtube) which may or may not be possible. > > > > > > > But for now, I'd be happy with simple jpg importing. > > > > > > > Appreciate any help. > > > > > > -- > > > > ___________________ > > > > > > Actionscript 3.0 Flash 3D Graphics Engine > > > > > > HTTP://AWAY3D.COM > > > > > -- > > > ___________________ > > > > > Actionscript 3.0 Flash 3D Graphics Engine > > > > > HTTP://AWAY3D.COM > -- ___________________ Actionscript 3.0 Flash 3D Graphics Engine HTTP://AWAY3D.COM
