Waiting for an image to load – BitmapFileMaterial

Friday, November 21st, 2008 | snippets
package
{
	import org.papervision3d.events.FileLoadEvent;
	import org.papervision3d.materials.BitmapFileMaterial;
	import org.papervision3d.objects.primitives.Plane;
	import org.papervision3d.view.BasicView;
 
	[SWF(width="640", height="480", backgroundColor="#000000", frameRate="60")]
	public class WaitForAnImageToLoad extends BasicView
	{
 
		public function WaitForAnImageToLoad()
		{
			var url:String = "http://content.screencast.com/media/1676f247-e7f0-4035-a826-06e2d7885731_089125cc-8776-47ed-92d7-280330071c15_static_0_0_00000149.png";
			var bitmapFileMaterial:BitmapFileMaterial = new BitmapFileMaterial(url);
			bitmapFileMaterial.addEventListener(FileLoadEvent.LOAD_COMPLETE, loadCompleteHandler);
		}
 
		private function loadCompleteHandler(event:FileLoadEvent):void
		{
			var plane:Plane = new Plane(BitmapFileMaterial(event.target));
			scene.addChild(plane);
			singleRender();
		}
	}
}

Tags: ,

  • Hi John, I haven't been able to combine a Phong shader (or any shader for that matter) to a loaded material in a shadedMaterial. Is that simply because I wasn't waiting for the load? Can it be done? More or less the same as you've done here where I created my ShadedMaterial in the loadComplete handler? Thanks for this example btw.

    a.
blog comments powered by Disqus

Search

Recommended Books

Speaking at FITC Toronto

 

November 2008
M T W T F S S
    Dec »
 12
3456789
10111213141516
17181920212223
24252627282930

Preferred Video Tutorial Resolution

  • 1024x768 (53%, 85 Votes)
  • 1280x1024 (15%, 24 Votes)
  • 1920x1080 (15%, 24 Votes)
  • 800x600 (13%, 20 Votes)
  • 480x320 (4%, 6 Votes)
  • 640x480 (0%, 2 Votes)

Total Voters: 160

Loading ... Loading ...