bitmapData - stupid question probably

0 views
Skip to first unread message

juan kennaugh

unread,
Jul 28, 2011, 10:20:03 AM7/28/11
to flash user group
Hi all

I'm trying to create a bitmapData - with the dimensions taken from an
MovieClip like this:

var myBitmapData:BitmapData = new
BitmapData(mc.width,mc.height,true,0x000000);

the MC has been added to the stage and I can trace the dimensions - but
this errors...

"ArgumentError: Error #2015: Invalid BitmapData"

it works if I just set the dimensions manually.

Any ideas what's going on - I'm sure it's a stupid thing I'm doing

Cheers

Juan


Richard Davey

unread,
Jul 28, 2011, 10:30:13 AM7/28/11
to bristol-flas...@googlegroups.com
How large are width / height? And are they round numbers? Maybe cast them to an int in the constructor.

Cheers,

Rich




--
You received this message because you are subscribed to the Google Groups "Bristol Flash User Group" group.
To post to this group, send email to bristol-flash-user-group@googlegroups.com.
To unsubscribe from this group, send email to bristol-flash-user-group+unsub...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/bristol-flash-user-group?hl=en.




--
http://www.photonstorm.com
We've got some wild things floating about.

juan kennaugh

unread,
Jul 28, 2011, 10:36:53 AM7/28/11
to bristol-flas...@googlegroups.com
Hi

no - I've rounded them like this:

    var w:int = Math.round(mc.width) as int;
    var h:int = Math.round(mc.height) as int;

    var myBitmapData:BitmapData = new BitmapData(w,h,true,0x000000);

and no joy???

wierd

Juan



On 28/07/2011 15:30, Richard Davey wrote:
How large are width / height? And are they round numbers? Maybe cast them to an int in the constructor.

Cheers,

Rich
On 28 July 2011 15:20, juan kennaugh <con...@jkennaugh.co.uk> wrote:
Hi all

I'm trying to create a bitmapData - with the dimensions taken from an MovieClip like this:

var myBitmapData:BitmapData = new BitmapData(mc.width,mc.height,true,0x000000);

the MC has been added to the stage and I can trace the dimensions - but this errors...

"ArgumentError: Error #2015: Invalid BitmapData"

it works if I just set the dimensions manually.

Any ideas what's going on - I'm sure it's a stupid thing I'm doing

Cheers

Juan


--
You received this message because you are subscribed to the Google Groups "Bristol Flash User Group" group.
To post to this group, send email to bristol-flas...@googlegroups.com.
To unsubscribe from this group, send email to bristol-flash-user...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/bristol-flash-user-group?hl=en.




--
http://www.photonstorm.com
We've got some wild things floating about.

--
You received this message because you are subscribed to the Google Groups "Bristol Flash User Group" group.
To post to this group, send email to bristol-flas...@googlegroups.com.
To unsubscribe from this group, send email to bristol-flash-user...@googlegroups.com.

s'unya

unread,
Jul 28, 2011, 12:00:13 PM7/28/11
to bristol-flas...@googlegroups.com
On 28 July 2011 15:36, juan kennaugh <con...@jkennaugh.co.uk> wrote:
Hi

no - I've rounded them like this:

    var w:int = Math.round(mc.width) as int;
    var h:int = Math.round(mc.height) as int;

    var myBitmapData:BitmapData = new BitmapData(w,h,true,0x000000);

and no joy???

wierd

Juan

Seems rather overdoing it, but if you trace out the w and h, what do you get?
--
                      o
            o                 o
                O   O   O
      o  o   O s´unya O   o  o

Richard Davey

unread,
Jul 28, 2011, 12:58:53 PM7/28/11
to bristol-flas...@googlegroups.com
Yeah that was my previous question too - what are the actual width / height of the clip? Because there's nothing wrong with the line below that creates the BitmapData assuming w and h are within a valid range for it.



--
You received this message because you are subscribed to the Google Groups "Bristol Flash User Group" group.
To post to this group, send email to bristol-flas...@googlegroups.com.
To unsubscribe from this group, send email to bristol-flash-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/bristol-flash-user-group?hl=en.

juan kennaugh

unread,
Jul 28, 2011, 1:11:28 PM7/28/11
to bristol-flas...@googlegroups.com
I've worked it out...

the width and height trace out fine.

It's actually due to the maximum allowed size of a bitmapdata in flash. My movieClip is created dynamically from hundreds of text fields - and obviously, my movieclip's width is greater than the maximum width of a bitmap.

Doh!

Cheers for trying to help though

Juan

Richard Davey

unread,
Jul 28, 2011, 2:05:56 PM7/28/11
to bristol-flas...@googlegroups.com
Thought as much :)

You'll be pleased to know that Flash Player 11 removes this limitation (there's no max size on bitmapData any more)

Cheers,

Rich

juan kennaugh

unread,
Jul 28, 2011, 2:38:08 PM7/28/11
to bristol-flas...@googlegroups.com
Good!

Cheers

Juan

tailless

unread,
Jul 28, 2011, 5:24:41 PM7/28/11
to bristol-flas...@googlegroups.com

Until then -  or if you need to support flash player 10, this is a good guide to bitmap size : 


/ Liv
Reply all
Reply to author
Forward
0 new messages