# How to call BitmapData from another function?

**URL:** <https://forum.kirupa.com/t/how-to-call-bitmapdata-from-another-function/291194>\
**Category:** flash\
**Created:** [June 26, 2009, 12:33am UTC](https://forum.kirupa.com/t/how-to-call-bitmapdata-from-another-function/291194 "2009-06-26T00:33:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![four4swords](https://avatars.discourse-cdn.com/v4/letter/f/87869e/32.png) [@four4swords](https://forum.kirupa.com/u/four4swords)\
**Post date:** [June 26, 2009, 12:33am UTC](https://forum.kirupa.com/t/how-to-call-bitmapdata-from-another-function/291194/1 "2009-06-26T00:33:42Z")

</div>

Hi,

I can’t seem to call my bitmapData from another function, if the bitmapdata was made in a function in the first place. Anyone know why?

Here’s my code… If you chuck it into flash, it’ll run the function dd() and it’ll make a bitmapdata, however, if you try to trace it or call to it… You can’t… you get “undefined” back…

But if i were to take it out of a function and put the bitmapdata on the frame without a function enclosing it, it works fine…

```auto
import flash.display.BitmapData;
import flash.geom.Rectangle;
import flash.geom.Point;
import com.*;
function dd () {
    var super_map_bit = new BitmapData (50, 50, true, 0x00CCCCCC);
    meg ();
}
function meg () {
    trace (super_map_bit);
}
dd ();

```

Anyway know how I could call my bitmapdata when it’s generated by a function?

Thanks.
