Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any way to use an external image/sprite file for the graphic of a FlxSprite instance?

Say I declare my player FlxSprite as follows:

player = new FlxSprite(FlxG.width/2 - 5);

How could I instead instantiate the FlxSprite using my own spritesheet or image? I have seen others do it in the Flixel demos , and in the featured games.

share|improve this question
up vote 0 down vote accepted

You want to use the loadGraphic method of FlxSprite, here's an example :

// in your class declarations 
[Embed(source="your.png")] private var yourGraphic:Class;

// in your class code wherever, after you have created an instance
// use true for second parameter if image is a row of sprite frames
player.loadGraphic(yourGraphic, false); 
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.