miahmiah
54 posts
|
I want to make a bitmap utility class, but I need the features that I normally use by writing “import flash.display.BitmapData;”. You can’t do this anywhere inside a Class file AFAIK, so how do you go about accomplishing this feat? Do I need to inherit or extend?
|
|
|
arcaneCoder
2354 posts
|
The simplest way is usually to extend the BitmapData class and add the needed functionality to the child class, but that is largely dependent upon what you specifically want to do.
|
|
|
miahmiah
54 posts
|
How about if I wanted to use also the geometry api – if I extend the bitmapdata class then I don’t have access to the other stuff I would normally import – Guess I forgot to mention that in the first post, I would like to get the effect of importing more than once class… does that make any sense?
|
|
|
arcaneCoder
2354 posts
|
If you extend the Bitmapdata class you still have access to importing all the other classes just the same as you do in your previous classes. Thats the point of extending a class, so you can add functionality to an already existing base.
|
|
|
FliplineStudios
244 posts
|
You can also write your import statements before the Class definition in the .as file at the top. You can also do multiple import statements there too — so you can import bitmap, geom, and point if you need them all in that class.
|
|
|
miahmiah
54 posts
|
Oh ok I’ll try that, doing it above the class statement inside the same .as file – sounds contrary to the error message I recieved but hope it works!
|
|
|
arcaneCoder
2354 posts
|
Yes, thats how you always use the import statement. As I was saying, its the same in your subclasses as it is in your other classes.
|
|
|
IndieFlashAr...
433 posts
|
I’m assuming that there’s no inheritance of the imported classes, or is there? In other words, if you have a class and a class which extends it, if you import geom, point, and bitmap (for instance) will you need to use the import statements again in the class which extends the class where the import statements were made.
|
|
|
arcaneCoder
2354 posts
|
Yes, you have to import again.
|
|
|
miahmiah
54 posts
|
I suppose you have to Import again because the classes can be seperate from eachother?
|
|
|
arcaneCoder
2354 posts
|
You have to import on every individual frame and class file you want to use that code in. Such is just how it is as importing scopes the code to just the current script. Read here for more.
|