Announcement

Collapse
No announcement yet.

Problem displaying an image with AS3

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Problem displaying an image with AS3

    Hi. I'm trying to display a single image using pure AS3 code in flashDevelop. My code is this simple thing:

    Code:
    package 
    {
    	import flash.display.*;
    	
    	public class Main extends Sprite
    	{		
    		[Embed(source = "../assets/logoAGDG.png", mimeType = "image/png")]
    		private var logoAGDG:Class;
    
    		public function Main() 
    		{
    			super();
    			trace("loading image");
    			var sp  = new logoAGDG();
    			addChild(sp);
    		}
            }
    }
    It displays the image using Flash Player. However, it isn't shown in GFx Player or in game.
    In the GFX Player this error is thrown in bold red letters:

    Code:
    Error: TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at Bitmap Asset instance constructor()[E:\dev\4.y\frameworks\project\framework\src;mx\core;BitmapAsset.as:136]
    at Main_logoAGDG instance constructor()
    at Main instance constructor()


    So, what would be the best way to show embedded images? TIA

    #2
    for starters I would make sure your image is valid.
    - It must be in the proper directory or it wont show up, (UDKGame\Flash\GameUI\GameUI\logoAGDG.png) even in the scale-form editor.
    - base2 dimensions (64x32, 512x512 etc)
    - make sure you have removed the ".png" from the suffix of the symbol.

    Comment

    Working...
    X