PDA

View Full Version : Sprite class cranks out warning every time



WhiteRau
June 7th, 2008, 12:06 AM
hey crew:

sticking my toes into the AS 3.0 pool here. i imported a .PNG to the library and tried to set the base class (in the Linkage window) to 'flash.display.Sprite'. when i click 'okay', it tells me it can't find the base definition and one will be created automatically on export. WTF?! isn't the Sprite a new part of CS3?

also, when i go back to the Properties, the base class has reverted to 'flash.display.BitMap'. i can change it, but i never takes... this is stupid.

can anyone tell me WTF is going on? i'm tired, cranky and if this **** is broken right out of the box, i'll go back to AS 2.0 and be done with it.

thanks

WR!

sasxa
June 7th, 2008, 12:15 AM
you can't set base class for images as Sprite, it's Bitmap/BitmapData... If you want that, make new symbol, put your image inside, and make it's (symbol's) base class Sprite...

WhiteRau
June 7th, 2008, 12:19 AM
ah. okay. so i have to wrap it in something first, THEN change the wrapper's base class. gotcha. thanks!

WR!

PS: apologies for cranky tone. new baby = desire to stab self in the eyes...

Alex Lexcuk
June 7th, 2008, 04:24 PM
http://kind-armadillo.pochta.ru/FlaAC3/Bmp_copy.swf
http://kind-armadillo.pochta.ru/FlaAC3/BMP_copy.rar

http://kind-armadillo.pochta.ru/FlaAC3/Mov_copy.swf
http://kind-armadillo.pochta.ru/FlaAC3/Mov_copy.rar

dthought
June 7th, 2008, 08:56 PM
Let's say you imported a PNG called "myImage.png".

When you set up linkage, Flash will try to call the new class by its library name, inheriting from flash.display.BitmapData . As the PNG is a raw bitmap image, you cannot convert it to a Sprite - it must be encapsulated in some way, usually by another class that inherits from Bitmap.

Things aren't as lax in AS3.0 compared to 2.0 - there are very specific ways to organise things, and whilst this forces you to write "cleaner" code overall, it does take a little more time to do it properly. In the end though, it's worth it for the speed boost alone :)