Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assets.getBitmapData not working? #12

Closed
madrazoman opened this issue May 30, 2013 · 8 comments
Closed

Assets.getBitmapData not working? #12

madrazoman opened this issue May 30, 2013 · 8 comments

Comments

@madrazoman
Copy link

In https://github.com/openfl/openfl/wiki/Transition-to-OpenFL
says "you can use the "openfl.Assets" like you would in NME".

However, if you change "DisplayingABitmap" sample as:
-Adding "import openfl.Assets"
-Replacing
"var bitmap = new Bitmap (new Image (0, 0));"
for
var bitmap = new Bitmap (Assets.getBitmapData ("assets/nme.png"));
(or
"var bitmap = new Bitmap (Assets.getBitmapData ("nme.png"));"
)

the bitmap is not displayed, and no error or warning is shown.

@madrazoman
Copy link
Author

Targeting flash an error occurs:
Assets.hx: 180[openfl.Assets] There is no BitmapData asset with ID of "assets/nme.png"

I tried to add an "assets" tag in the xml but still no luck.

@madrazoman
Copy link
Author

Sorry.
I got it working by adding

< assets path="Assets" rename="assets" exclude="nme.svg" />

as in the old NME example (I was missing the "rename").

It may be worth mentioning, in the "Transition-to-OpenFL" page, that you need an "assets" tag?
Cheers :D

@jgranick
Copy link
Member

When someone embedded an asset using NME, they would use an tag and they would use nme.Assets

Now with embedded @:bitmap tag (and others) you can directly embed assets, avoiding the openfl.Assets class and accompanying tag ... its up to your preference :)

@Beeblerox
Copy link
Contributor

@jgranick Will openfl.Assets class stay in openfl or it will be removed after some time?

@madrazoman
Copy link
Author

Joshua, thank you very much for your patience. This leads me to my next question: http://www.nme.io/index.php?cID=11557
Cheers

@accidentalrebel
Copy link

Hi there,

So I was having a problem where Assets.getBitmapData ("assets/nme.png"); is returning null.

Turns out that I need to import and use "nme.Assets" instead of "openfl.Assets". After I did that, getBitmapData started working.

Shouldn't openfl be independent from NME?

Thanks, guys!

@prettymuchbryce
Copy link

I found this thread when trying to figure this out, and thought I would post what I did incase it could help anyone.

in my project.xml:
<assets path="assets/include" include="*" />

then in your Main.hx: import openfl.Assets;

then

new Bitmap(openfl.Assets.getBitmapData('assets/include/myGreatAsset.png'));

@dagnelies
Copy link

I fell in the same trap. Perhaps the error message could be more noob friendly by stating "... Please check your project.xml"

LeiChenIntel pushed a commit to LeiChenIntel/openfl that referenced this issue Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants