|
metadata
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?
|
|
|
metadata
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.
|
|
|
metadata
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?
|
|
|
metadata
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.
|
|
|
metadata
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.
|
|
|
metadata
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!
|
|
|
metadata
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.
|
|
|
metadata
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.
|
|
|
metadata
Yes, you have to import again.
|
|
|
metadata
I suppose you have to Import again because the classes can be seperate from eachother?
|
|
|
metadata
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](http://livedocs.adobe.com/flash/9.0/main/00001328.html) for more.
|