importing animation controller
Hello friends! I unfortunately need help once again :(...
Ok so, the project is to display, and animate a sprite using imbeds instead of importing them into a .fla library.
here is my test sprite sheet:
http://s7.postimage.org/asdnfbnvv/my_Image.png
I use an assets.as to import the sprite sheets this file is located in /assetsTest folder:
Actionscript Code:
package assetsTest {
import flash.display.*;
public class assets {
[Embed(source='myImage.png')]
public static var myImage:Class;
}
}
now that we have the image cached, i send it over to my animation.as script (located in same folder as above):
Actionscript Code:
package assetsTest
{
import flash.events.*;
import flash.geom.*;
import flash.display.*;
import assetsTest.assets;
public class animation extends MovieClip
{
var bowserTilesHeight:int;
var bowserTilesWidth:int;
var bowserTilesLength:int;
var animationIndex:int;
var animationCount:int;
var animationDelay:int;
var bowserX:int;
var bowserY:int;
var bowserRect:Rectangle;
var bowserPoint:Point;
var canvasBD:BitmapData;
var canvasBitmap:Bitmap;
var tileSheet:Bitmap;
var tileSheetData:BitmapData;
var backGroundBitmapData:BitmapData;
public function animation()
{
bowserTilesHeight = 91;
bowserTilesWidth = 66;
bowserTilesLength = 16;
animationIndex = 0;
animationCount = 0;
animationDelay = 1;
bowserX = (stage.stageWidth / 2)-(bowserTilesWidth / 2);
bowserY = (stage.stageHeight / 2)-(bowserTilesHeight / 2);
canvasBD = new BitmapData(bowserTilesWidth,bowserTilesHeight,true,0);
canvasBitmap = new Bitmap(canvasBD);
backGroundBitmapData = new BitmapData(bowserTilesWidth,bowserTilesHeight,true,0);
tileSheet = new assets.myImage();
if (tileSheet == null) {
// catch error
trace("Bowser Sprite Sheet Missing... code: Ani_49");
return;
}
tileSheetData = tileSheet.bitmapData.clone();
bowserRect = new Rectangle(0,0,bowserTilesWidth,bowserTilesHeight);
bowserPoint = new Point(0,0);
addChild(canvasBitmap);
canvasBitmap.x = bowserX;
canvasBitmap.y = bowserY;
addEventListener(Event.ENTER_FRAME,aniLoop);
}
private function aniLoop(e:Event)
{
clearFrame();
}
private function clearFrame():void
{
canvasBD.lock();
canvasBD.copyPixels(backGroundBitmapData, backGroundBitmapData.rect, bowserPoint);
drawBowser();
}
private function drawBowser():void
{
if (animationCount == animationDelay)
{
animationIndex++;
animationCount = 0;
if (animationIndex == bowserTilesLength)
{
animationIndex = 0;
}
}
else
{
animationCount++;
}
bowserRect.x = int((animationIndex % bowserTilesLength)) * bowserTilesWidth;
bowserRect.y = int((animationIndex / bowserTilesLength)) * bowserTilesHeight;
canvasBD.copyPixels(tileSheetData,bowserRect, bowserPoint);
canvasBD.unlock();
}
}
}
now to my question, how can i make it so i can use a Main.as to run this animation.as file?
every time i try it says undefined method animation through a reference with static type class.