• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Invalid BitmapData Error #2015

New Here ,
May 04, 2010 May 04, 2010

Copy link to clipboard

Copied

I'm getting an Invalid BitmapData Error #2015 at 
flash.display::BitmapData$iinit() that points to the line
of code below where a BitmapData object is created.
I am using this function to create only a few hundred
Item objects, each of which is only 166 px by 96 px in
size so I don't believe that the problem has to do with
running out of memory. I also used system.totalMemory
to trace memory consumption but it showed that only
a few tens of megabytes were used when the error occurred.
I have tried setting the BitmapData and Bitmap
objects to null because that was a solution I found on another
site. That didn't work. I tried dispose(). The error
occurs intermittently, sometimes after running my app a few
times and sometimes when I first load it. I am not
refreshing my browser over and over in order to run the app.
I cannot figure out the exact sequence of events that
leads to this error. In earlier versions of my app, I was able to
successfully use the exact same function (minus
the lines where the BitmapData and Bitmap objects are set to
null). I am not an expert at Actionscript, so perhaps
I'm doing something wrong. Please help me out. Thanks.
          public function cloneItem(item:Item):Item {                var itemClone:Item = new Item(item.ID, item.name, item.bpCost, item.bcCost, item.quantity);                var tempBitmap:Bitmap;                var tempBitmapData:BitmapData;                var tempSprite:Sprite;                if (item.card != null) {                     itemClone.card = new mcCard();                     itemClone.card.txbCardName.text = item.card.txbCardName.text;                     itemClone.card.setCost(item.card.cost);                     itemClone.card.txbSet.text = item.card.txbSet.text;                     itemClone.card.txbRarity.text = item.card.txbRarity.text;                     itemClone.card.txbLevel.text = item.card.txbLevel.text;                     itemClone.card.txbType.text = item.card.txbType.text;                          if (itemClone.card.txbType.text.indexOf('Unit') == -1 && itemClone.card.txbType.text.indexOf('Hero') == -1 && itemClone.card.txbType.text.indexOf('Leader') == -1) {                          itemClone.card.hideUnitAttributes();                     } else {                          itemClone.card.txbAttack.text = item.card.txbAttack.text;                          itemClone.card.txbHP.text = item.card.txbHP.text;                                                   if (itemClone.card.txbType.text.indexOf('Leader') == -1) {                               itemClone.card.lblMP.visible = false;                               itemClone.card.txbMP.visible = false;                          } else {                               itemClone.card.lblAttack.visible = false;                               itemClone.card.txbAttack.visible = false;                               itemClone.card.mcSword.visible = false;                                                             itemClone.card.lblHP.x = itemClone.card.lblAttack.x;                               itemClone.card.txbHP.x = itemClone.card.txbAttack.x;                               itemClone.card.mcHeart.x = 0;                               itemClone.card.txbMP.text = item.card.txbMP.text;                          }                     }                                         itemClone.card.txbRules.text = item.card.txbRules.text;                                         tempBitmapData = new BitmapData(166, 96);                     tempBitmapData.draw(item.card.mcImage);                     tempBitmap = new Bitmap(tempBitmapData);                     //tempBitmap.cacheAsBitmap = false;                     //tempBitmap.smoothing = true;                     tempSprite = new Sprite();                     tempSprite.addChild(tempBitmap);                     itemClone.card.mcImage.addChild(tempSprite);                     //tempBitmapData.dispose();                                         tempBitmapData = null;                     tempBitmap = null;                                         itemClone.card.buttonMode = true;                     itemClone.card.mouseChildren = false;                     itemClone.card.tabEnabled = false;                }                return itemClone;           }
TOPICS
ActionScript

Views

8.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 06, 2010 May 06, 2010

Copy link to clipboard

Copied

Can someone help me out?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 06, 2010 May 06, 2010

Copy link to clipboard

Copied

I'm sorry, but your code is largely unreadable.  It's too busy and not broken up into invidual functions, nor commented very well.  I'm sure it makes perfect sense to you, but for me, not being familiar at all with what properties or functions "item" has, it's hard to say.

But just as a shot in the dark, I'd say that item.card.mcImage is the culprit.  I assume this is a MovieClip.  Can you add this to the stage and see if there's any data there?  Or trace it to make sure it returns non-null?

addChild(item.card.mcImage);

trace (item.card.mcImage);

Also, if you comment out that whole part with the Bitmap, does the rest of the code work?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 06, 2010 May 06, 2010

Copy link to clipboard

Copied

Thanks for the suggestion. I've already tried tracing item.card.mcImage to see if it's null but that's not what's causing the error. I need the Bitmap part in order for it to work. Is there anything else that I should look into?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 06, 2010 May 06, 2010

Copy link to clipboard

Copied

More shots in the dark...

Check the following:

1) The height and width may be invalid.  Change it to:

new BitmapData (item.card.mcImage.width, item.card.mcImage.height);

2) If that doesn't work, try it with just a single pixel

new BitmapData(1,1);

3) Check to see if the movieClip has been resized or transformed.

4) Make sure the MovieClip is at 0,0 registration

5) Try setting the alpha value to false and see if it captures a black rectangle

new BitmapData(166,96,false);

If it doesn't throw an error, and returns a black rectangle, it means there were no pixels for it to capture.

6) Substitute the item.card.mcImage with a different MovieClip.

7) And lastly, try to comment out code that comes before to see if it's something else that's causing the error.  Sometimes the error is being thrown for entirely different reasons than it says, but AS gets confused.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 07, 2010 May 07, 2010

Copy link to clipboard

Copied

You test for the card being null - so it must be able to be null, right.

if (item.card != null) {

But you still try and and take an image from it... what if it is null? Seems your imaging code should be inside the if so you guarantee it's not null. The draw isn't going to work if item.card is null.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 07, 2010 May 07, 2010

Copy link to clipboard

Copied

Thanks for the suggestions. I've tried just about all of them but still can't get it working. I'm going to try something else entirely.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 27, 2010 Dec 27, 2010

Copy link to clipboard

Copied

Is there any possibilities to create a Bitmapdata of more than 2880 pixel width and height? I know in flash there is a limitation of Bitmapdata dimension and that is 2880 pixel. But what is the solution to overcome this problem?

Actually I am creating a photo album application. There user can choose the album dimension and as it is related to the Print section so I have to keep the resolution in 300 DPI. there fore 3.5 inch means 3.5*300 pixel similarly 11 / 8 inchs is generating more that the 2880 pixels. and whenever I am trying to convert the album into jpeg format by bitmap data handler, I am getting error.

What is the solution????

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 27, 2010 Dec 27, 2010

Copy link to clipboard

Copied

Here are limitations as describled in documentation:

"In  AIR 1.5 and Flash Player 10, the maximum size for a BitmapData object is 8,191 pixels in width or height,  and the total number of pixels cannot exceed 16,777,215 pixels. (So, if a BitmapData object is 8,191 pixels  wide, it can only be 2,048 pixels high.) In Flash Player 9 and earlier and AIR 1.1 and earlier, the limitation is 2,880 pixels in height and 2,880 in width."

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/BitmapData.html?filter_coldfusion=9&filter_flex=3&filter_flashplayer=10&filter_air=1.5

There is no way to overcome this limitations.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 27, 2010 Dec 27, 2010

Copy link to clipboard

Copied

That means if I use Flash player 10 then I can increase the dimension the of Bitmap? What is the limitation of the dimension on the latest version, 8191 pixels ?????

Getting confuse on this section :

"In  AIR 1.5 and Flash Player 10, the maximum size for a BitmapData object is 8,191 pixels in width or height,  and the total number of pixels cannot exceed 16,777,215 pixels. (So, if a BitmapData object is 8,191 pixels  wide, it can only be 2,048 pixels high.)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 28, 2010 Dec 28, 2010

Copy link to clipboard

Copied

LATEST

Max width OR height can be up to 8191. It CANNOT be 8191 by 8191 because these dimensions will encompass 67,092,481 pixels which is more than 16,777,215 the max of all-in-all pixels BitmapData can take. So, if it is 8191 wide - it can be NOT MORE than 2048. The same goes for height vs width.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 27, 2010 Dec 27, 2010

Copy link to clipboard

Copied

there's no reason your printer would be related to bitmapdata size.   what are you trying to do?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 27, 2010 Dec 27, 2010

Copy link to clipboard

Copied

Actually I am making an online photo album maker, where user can upload their personal photo and can decorate it through different ornaments, like Photo frame, ring, floral design, some background and so on . User also can choose the dimension of the album, whether  it will be Landscape or portrait. The maximum width and height can be A4 size. As it is print related so after all the decoration user can save this file or send this file to the admin for print purpose.

If you see the www.mixbook.com you can easily understand what kind of application I am going to create.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines