Actionscript 3: Create dictionary inside class? - actionscript-3

I'm trying to transform my actionscript 3 code from the timeline, which I previously used, to packages.
I need to define some dictionaries in the beginning of the code.
But when running the following code inside my class, actionscript returns an error.
public var S_USA:Dictionary = new Dictionary();
S_USA["x"] = -299;
S_USA["y"] = -114;
S_USA["bynavn"] = "New York";
This is the error: "1120: Access of undefined property S_USA.
EDIT: Posting the entire code:
package
{
import fl.motion.MatrixTransformer;
import flash.display.MovieClip;
import flash.utils.Dictionary;
import flash.display.Shape;
import fl.transitions.Fly;
import fl.motion.MatrixTransformer;
import flash.events.MouseEvent;
import flash.display.Sprite;
import flash.events.KeyboardEvent;
import flash.geom.Matrix;
import flash.geom.Point;
import flash.ui.Mouse;
import flash.text.TextField;
import flash.display.SimpleButton;
import fl.controls.List;
public class Main extends MovieClip
{
public static var bg_width = 980;
public static var bg_height = 541;
public var spImage:Sprite;
public var mat:Matrix;
public var mcIn:MovieClip;
public var mcOut:MovieClip;
public var externalCenter:Point;
public var internalCenter:Point;
public var scaleFactor:Number = 0.8;
public var minScale:Number = 0.25;
public var maxScale:Number = 10.0;
/*public static var startList:List;
public static var sluttList:List;*/
public var bynavntxt:TextField;
public var intervall:TextField;
public var create_route:SimpleButton;
public var confirm_button:SimpleButton;
public var beregn_tid:SimpleButton;
public static var S_Norway:Dictionary = new Dictionary();
S_Norway["x"] = -60;
S_Norway["y"] = -183;
S_Norway["bynavn"] = "Oslo";
public static var S_Australia:Dictionary = new Dictionary();
S_Australia["x"] = 307;
S_Australia["y"] = 153;
S_Australia["bynavn"] = "Sydney";
public static var S_China:Dictionary = new Dictionary();
S_China["x"] = 239;
S_China["y"] = -98;
S_China["bynavn"] = "Beijing";
public static var S_South_Africa:Dictionary = new Dictionary();
S_South_Africa["x"] = -26;
S_South_Africa["y"] = 146;
S_South_Africa["bynavn"] = "Cape Town";
public static var S_Brazil:Dictionary = new Dictionary();
S_Brazil["x"] = -210;
S_Brazil["y"] = 73;
S_Brazil["bynavn"] = "Rio de Janeiro";
public static var S_USA:Dictionary = new Dictionary();
S_USA["x"] = -299;
S_USA["y"] = -114;
S_USA["bynavn"] = "New York";
public static var S_France:Dictionary = new Dictionary();
S_France["x"] = -79;
S_France["y"] = -135;
S_France["bynavn"] = "Paris";
// ------------------------------------------------------
public static var Flyplasser:Dictionary = new Dictionary();
Flyplasser["USA"] = S_USA;
Flyplasser["Norway"] = S_Norway;
Flyplasser["South Africa"] = S_South_Africa;
Flyplasser["Brazil"] = S_Brazil;
Flyplasser["France"] = S_France;
Flyplasser["China"] = S_China;
Flyplasser["Australia"] = S_Australia;
public function Main()
{
// ------------------------------------
startList:List = new List();
sluttList:List = new List();
bynavntxt:TextField = new TextField() ;
intervall:TextField = new TextField() ;
create_route:SimpleButton = new SimpleButton() ;
confirm_button:SimpleButton = new SimpleButton() ;
beregn_tid:SimpleButton = new SimpleButton() ;
this.addChild(startList);
this.addChild(sluttList);
this.addChild(bynavntxt);
this.addChild(intervall);
this.addChild(create_route);
this.addChild(confirm_button);
this.addChild(beregn_tid);
// -----------------------------------------
// We use the ctrl and shift keys to display the two different cursors that were created on the stage.
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyHandler);
stage.addEventListener(KeyboardEvent.KEY_UP, keyHandler);
this.addEventListener(MouseEvent.CLICK, mouseCoordinates);
trace("Main spawned");
// --------------------
this.width = bg_width;
this.height = bg_height;
// --------------------
for (var k:Object in Flyplasser)
{
var value = Flyplasser[k];
var key = k;
trace(key);
startList.addItem({label:key, data:key});
sluttList.addItem({label:key, data:key});
var airport:flyplass = new flyplass(key,Flyplasser[key]["bynavn"]);
airport.koordinater(Flyplasser[key]["x"], Flyplasser[key]["y"]);
this.addChild(airport);
}
var mcOut = new OutCursorClip();
this.addChild(mcOut);
var mcIn = new InCursorClip();
this.addChild(mcIn);
startList = new List();
this.addChild(startList)
sluttList = new List();
this.addChild(sluttList)
bynavntxt = new TextField;
this.addChild(bynavntxt)
intervall = new TextField;
this.addChild(intervall)
create_route = new SimpleButton;
this.addChild(create_route)
confirm_button = new SimpleButton;
this.addChild(confirm_button)
beregn_tid = new SimpleButton;
this.addChild(beregn_tid)

Are you setting this data inside Constructor or function?
EDIT:
Hm, where to start...
1) You know that the trick with static is not gonna work if you'll create more than 1 instance of class? In this case if you have only 1 Main class it's gonna work, but omg... Imho it's not nice to store data in static vars...
2) If you already declared:
public var bynavntxt:TextField;
public var intervall:TextField;
later just do
bynavntxt = new TextField() ;
intervall = new TextField() ;
no need for type in there.
3) Later in Main you have something like:
var mcOut = new OutCursorClip();
this.addChild(mcOut);
var mcIn = new InCursorClip();
this.addChild(mcIn);
Why are you declaring new variables with same name but without Type?
Waaaaaay up you have:
public var mcIn:MovieClip;
public var mcOut:MovieClip;
so those variables are already declared. By declaring them once again you are creating local ones. Beware!! The ones from the top would be null after that.

1) Fill the dictionary inside the Constructor (I seen by comments you have done this already).
2) you have already assigned type to bynavntxt with public var bynavntxt:TextField; you should not be doing it again with bynavntxt:TextField = new TextField(); just bynavntxt= new TextField(); will do.
This is the same with all other variables on similar type.
3) Make sure this class is going to be your "Document Class"/"Compiled Class" otherwise you will not have access to the 'stage' variable yet. To make sure you will have access to the stage variable you can always do:
/* Inside Constructor */
addEventListener(Event.ADDED_TO_STAGE, _onAddedToStage);
/* Outside Constructor */
private function _onAddedToStage(e:Event):void
{
removeEventListener(Event.ADDED_TO_STAGE, _onAddedToStage);
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyHandler);
stage.addEventListener(KeyboardEvent.KEY_UP, keyHandler);
}
Again, if this is going to be the compiled class, this can be skipped.

Related

How to read information from an XML file in AS3

I need to build an XML file that is read by this code.
I can't figure out how to do it.
public function formDoneLoading(param1:ServerConfig) : void
{
this.serverConfig = param1;
this.loadAvatars("boy");
this.loadAvatars("girl");
this.hairXMLLoader = new URLLoader(new
URLRequest(this.avatarPath + "defaultHair.xml"));
this.hairXMLLoader.addEventListener(Event.COMPLETE,this.hairXMLLoaded);
//this.hairXMLLoader.load(); //# this part is missing in original code
}
private function hairXMLLoaded(param1:Event) : void
{
var _loc2_:XML = XML(this.hairXMLLoader.data);
this.BOY_INIT_HAIR = _loc2_.defaultHair.#boy;
this.GIRL_INIT_HAIR = _loc2_.defaultHair.#girl;
}
Is what I'm doing right? This is how you write the XML document
import flash.filesystem.File;
import flash.filesystem.FileMode;
import flash.filesystem.FileStream;
XML.ignoreComments = false;
XML.ignoreWhitespace = true;
public const FNAME:File = new File(File.applicationDirectory.nativePath + "/myfile.xml");
public const FSTREAM:FileStream = new FileStream();
FSTREAM.open(FNAME, FileMode.READ);
var myxml:XML = new XML(<myxmlroot/>);
myxml = new XML(FSTREAM.readUTFBytes(FSTREAM.bytesAvailable));
FSTREAM.close();

Flash-Adding Symbol to Stage in AS3

I am trying to add a symbol from my library to the stage. For some reason, when I run the code, no objects are appearing on the stage but I am not getting any errors either. I can't provide all of the code because its VERY long, but I'll provide enough for anyone reading to get a good idea of what I'm trying to do.
Basically, the main as3 file starts like this:
package {
import flash.display.*;
import flash.events.*;
import flash.ui.*;
import flash.media.*;
import flash.net.*;
public class NewFrogMod extends MovieClip
{
var oneHit:Boolean;
var twoHit:Boolean;
var threeHit:Boolean;
var fourHit:Boolean;
var fiveHit:Boolean;
var sixHit:Boolean;
var sevenHit:Boolean;
var eightHit:Boolean;
var nineHit:Boolean;
var tenHit:Boolean;
var elevenHit:Boolean;
var twelveHit:Boolean;
var thirteenHit:Boolean;
var fourteenHit:Boolean;
var score:uint;
var frog1:Frog;
var truck1:Truck;
var truck2:Truck;
var truck3:Truck;
var car1:Car;
var car2:Car;
var log1:Logs;
var log2:Logs;
var log3:Logs;
var log4:Logs;
var turtle1:Turtles;
var turtle2:Turtles;
var z1:Zfrog;
var z2:Zfrog;
var z3:Zfrog;
var z4:Zfrog;
var z5:Zfrog;
public function NewFrogMod()
{
var score = 0;
frog1 = new Frog();
truck1 = new Truck();
truck2= new Truck();
truck3 = new Truck();
car1 = new Car();
car2 = new Car();
log1 = new Logs();
log2 = new Logs();
log3 = new Logs();
log4 = new Logs();
turtle1 = new Turtles();
turtle2 = new Turtles();
z1 = new Zfrog();
z2 = new Zfrog();
z3 = new Zfrog();
z4 = new Zfrog();
z5 = new Zfrog();
addChild(frog1);
addChild(truck1);
addChild(truck2);
addChild(car1);
addChild(car2);
addChild(log1);
addChild(log2);
addChild(log3);
addChild(turtle1);
addChild(turtle2);
addChild(z1);
addChild(z2);
addChild(z3);
addChild(z4);
addChild(z5);
frog1.x = 238;
frog1.y = 373;
truck1.x = 0;
truck1.y = 252;
truck2.x = 205;
truck2.y = 252;
car1.x = 82;
car1.y = 175;
car2.x = 363;
car2.y = 175;
log1.x = 22;
log1.y = 51;
log2.x = 355;
log2.y = 51;
log3.x = 43;
log3.y = 102;
log4.x = 292;
log4.y = 102;
turtle1.x = 241;
turtle1.y = 81;
turtle2.x = 508;
turtle2.y = 125;
z1.x = 200;
z1.y = 250;
z2.x = 300;
z2.y = 350;
z3.x = 100;
z3.y = 150;
z4.x = 100;
z4.y = 250;
z5.x = 200;
z5.y = 150;
Then there's a bunch more after that....
Now, to give you an idea of how I'm setting up the objects, here is the code for some of them:
package {
import flash.display.MovieClip;
import flash.events.Event;
public class Car extends NewFrogMod{
public function Car()
{
addEventListener(Event.ENTER_FRAME, Enter4);
}
function Enter4(event:Event):void
{
this.x += 3;
}
}
}
package {
import flash.display.MovieClip;
import flash.events.Event;
public class Truck extends NewFrogMod{
public function Truck()
{
addEventListener(Event.ENTER_FRAME, Enter5);
}
function Enter5(event:Event):void {
if(this.hitTestObject(frog1))
{
health1.width -= 5;
}
}
}
}
I've tried extending MovieClip with these files as well and that doesn't work either. Any hep is GREATLY aqppreciated. Thank you!
Ensure that the parent class NewFrogMod which adds the movieclip, has itself been added to the stage.
Also ensure that each library symbol, eg. Truck, has been linked to its class:
Right-click the symbol in the library and choose Properties from the menu.
Check the box 'Export for ActionScript'.
In the Class field, enter the full class path of your Truck class (simply 'Truck' in your case). The base field class can be ignored as your Truck class already extends MovieClip.
Alternatively, specify NewFrogMod as the document class of the main timeline:
Left-click an empty part of the stage, go to the Properties inspector and enter NewFrogMod into the Class field.
i think it may be that you added the objects before you specified the location. try moving the addChild functions below the x and y coordinates.

Actionscript 3: Adding buttons/textfields to an instance of a class

This absolutely does not work. The for loop simply spam tracing of one of the objects in the dictionary. After like 10 seconds i get this error message:
Error: Error #1502: A script has executed for longer than the default timeout period of 15 seconds.
Does anyone know why?
package
{
import flash.display.MovieClip;
import flash.utils.Dictionary;
import flash.display.Sprite;
public class Main extends MovieClip
{
public static var bg_width = 980;
public static var bg_height = 541;
public var S_Norway:Dictionary = new Dictionary();
public var S_Australia:Dictionary = new Dictionary();
public var S_China:Dictionary = new Dictionary();
public var S_South_Africa:Dictionary = new Dictionary();
public var S_Brazil:Dictionary = new Dictionary();
public var S_USA:Dictionary = new Dictionary();
public var S_France:Dictionary = new Dictionary();
// ------------------------------------------------------
public static var airportDict:Dictionary = new Dictionary();
public function Main()
{
S_USA["x"] = -299;
S_USA["y"] = -114;
S_USA["city"] = "New York";
S_Norway["x"] = -60;
S_Norway["y"] = -183;
S_Norway["city"] = "Oslo";
S_South_Africa["x"] = -26;
S_South_Africa["y"] = 146;
S_South_Africa["city"] = "Cape Town";
S_Brazil["x"] = -210;
S_Brazil["y"] = 73;
S_Brazil["city"] = "Rio de Janeiro";
S_France["x"] = -79;
S_France["y"] = -135;
S_France["city"] = "Paris";
S_China["x"] = 239;
S_China["y"] = -98;
S_China["city"] = "Beijing";
S_Australia["x"] = 307;
S_Australia["y"] = 153;
S_Australia["city"] = "Sydney";
airportDict["USA"] = S_USA;
airportDict["Norway"] = S_Norway;
airportDict["South Africa"] = S_South_Africa;
airportDict["Brazil"] = S_Brazil;
airportDict["France"] = S_France;
airportDict["China"] = S_China;
airportDict["Australia"] = S_Australia;
for (var k:Object in airportDict)
{
var value = airportDict[k];
var key = k;
trace(key);
var airport:flyplass = new flyplass(key,airportDict[key]["bynavn"]);
airport.coordinates(airportDict[key]["x"], airportDict[key]["y"]);
this.addChild(airport);
}
Running script in debug mode (CTRL - SHIFT - Enter) produced the following output.
Attempting to launch and connect to Player using URL C:\Users\eivmey\Documents\practice\3.0.swf
[SWF] C:\Users\eivmey\Documents\It 2\fly\3.0.swf - 475976 bytes after decompression
USA
Australia
* Infinite spam of Australia follows
____________________________--
EDIT: Solved it
Ok, the problem was in the flyplass class.
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.display.SimpleButton;
import flash.display.Stage;
import flash.text.TextField;
import flash.text.TextFormat;
public class flyplass extends Main()
{
// variables
public function flyplass(input1, input2)
{
// code
}
When changing extends Main() to extends MovieClip it suddenly worked. Do you know why?

Can't access public properties of my Class

I'm still learning about object oriented programming...
I made my own simple button class to do horizontal buttons lists. I works fine, but...
package as3Classes {
import flash.display.Graphics;
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.events.Event;
import flash.text.TextField;
import flash.events.MouseEvent;
import fl.motion.MotionEvent;
import flash.text.TextFormat;
public class simpleButton extends MovieClip {
//var nome:String = new String();
var sub:Sprite = new Sprite();
public var realce:Sprite = new Sprite();
public var titulo:String;
public function simpleButton(nomeId:String, texto:String) {
this.name = nomeId;
this.titulo = texto;
this.useHandCursor = true;
this.buttonMode = true;
this.mouseChildren = false;
var txtf:TextFormat = new TextFormat();
txtf.font = "Arial";
var txt:TextField = new TextField();
txt.wordWrap = false;
txt.multiline = false;
txt.text = texto;
txt.setTextFormat(txtf);
txt.width = txt.textWidth+4;
txt.height = 22;
txt.x = 4;
txt.y = 2;
txt.cacheAsBitmap = true;
var fundo:Sprite = new Sprite();
fundo.graphics.beginFill(0xCCCCCC);
fundo.graphics.drawRect(0, 0, txt.width+8, 22);
fundo.graphics.endFill();
//var realce:Sprite = new Sprite();
this.realce.graphics.beginFill(0x00CC00);
this.realce.graphics.drawRect(0, 0, txt.width+8, 22);
this.realce.graphics.endFill();
this.sub.graphics.beginFill(0xFF0000);
this.sub.graphics.drawRect(0, 0, txt.width+8, 2);
this.sub.graphics.endFill();
this.addChild(fundo);
this.addChild(this.realce);
this.addChild(this.sub);
this.addChild(txt);
this.sub.alpha = 0;
this.sub.y = 22;
this.addEventListener(MouseEvent.MOUSE_OVER, mouseover);
this.addEventListener(MouseEvent.MOUSE_OUT, mouseout);
}
private function mouseover(e:MouseEvent){
sub.alpha = 1;
}
private function mouseout(e:MouseEvent){
sub.alpha = 0;
}
}
}
... when I try to access the "titulo" or set "realce" as alpha=1 (to display it as clicked) it returns undefined. I can only set or read proprieties inherited, as the name, alpha, etc. What is my conceptual mistake?
Yes! I found a way to avoid this issue: Since (as it seams) I can't access the internal public objects of "simpleButton" by display objects list, I create a private object (btns:Object) in the root of the main class (can be seen everywhere) and add the simpleButtons simultaneously as adding at display. The name is the same, so I can change the realce.alpha by btns and it will reflect in the display.
This is bizarre, because the e.target leads to the child instead of the object itself!
If somebody knows a better way, please let me know.

tweenlite not working with bitmaps?

I have the following problem when I try to use TweenLite with a Bitmap:
I get strange error messages when applying TweenLite to a Bitmap (tempScore.bitmap). GetBounds works. The bitmap has transparency. Does anyone have an idea why it doesn't work? Any help appreciated. Thanks.:)
When using a getBounds-Method I get this:
tempScore.bitmap.getBounds(this)(x=2.35, y=-0.45, w=25, h=18)
This is the error message:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.greensock.plugins::TransformAroundPointPlugin/onInitTween()
at com.greensock.plugins::TransformAroundCenterPlugin/onInitTween()
at com.greensock::TweenLite/init()
at com.greensock::TweenLite/renderTime()
at com.greensock.core::SimpleTimeline/renderTime()
at com.greensock::TweenLite$/updateAll()
My imported and activated libraries look like this:
import com.greensock.*;
import com.greensock.TweenLite;
import com.greensock.plugins.TweenPlugin;
import com.greensock.plugins.TransformAroundCenterPlugin;
import com.greensock.plugins.TransformAroundPointPlugin;
import com.greensock.easing.*;
import com.greensock.plugins.AutoAlphaPlugin;
import com.greensock.plugins.ColorTransformPlugin;
import com.greensock.plugins.ColorMatrixFilterPlugin;
TweenPlugin.activate([TransformAroundCenterPlugin, TransformAroundPointPlugin, ColorTransformPlugin,
ColorMatrixFilterPlugin]);
This is the part where I try to use TweenLite on my tempScore:
var scoreTextLength:int = scoreManager.scores.length - 1;
for (var counter:int = scoreTextLength; counter >= 0; counter--)
{
tempScore = scoreManager.scores[counter];
tempScore.startDelay = true;
TweenLite.to(tempScore.bitmap, 2, {transformAroundCenter: {scale:2}});
trace("tempScore.bitmap.getBounds(this)" + tempScore.bitmap.getBounds(this));
if (tempScore.update())
{
disposeScore(counter);
}
}
So far as I can see the getBounds-values are ok. My game is based on a gameframework. There's a renderer inside of it.
Call me an idiot if I'm wrong but is it possible that the renderer of the framework and tweenlite are getting in each other's way??
TweenLite has problems with other similar objects like tempAsteroid. A lot of objects are drawn onto a canvas with copyPixels (blitting-method).
tempScore is a Score-object. The Score object is based on a BasicBlitArrayObject. Otherwise this object extends an EventDispatcher. I hope this little info helps.
This is the scoreManager which manages the look and properties of tempScore:
package com.cosmicward.src.classes
{
import flash.display.*;
import flash.text.*;
import flash.geom.*;
import com.framework_mod.src.BlitArrayAsset;
public class ScoreManager
{
public var scoreBitmapData:BitmapData;
public var scoreBitmap:Bitmap;
public var scoreAnimationFrames:Array = [];
public var scores:Array;
public var tempScore:Score;
private var textfield:TextField = new TextField();
private var textFormat:TextFormat = new TextFormat();
private var $textWidth:int;
private var $textHeight:int;
private var rec:Rectangle;
public var scoreCount:int;
public var scoreCountTwo:int;
public var scoreCountThree:int;
private var drawingCanvas:Shape = new Shape();
private var point0:Point = new Point(0, 0);
public function ScoreManager()
{
}
public function createScoreLook(textWidth:int, textHeight:int, text:String, textFormat:TextFormat):void {
var tempBlitArrayAsset:BlitArrayAsset = new BlitArrayAsset();
scoreBitmapData = new BitmapData(textWidth, textHeight, true, 0x00000000);
var font:ArialBold = new ArialBold();
textFormat.font = "ArialBold";
textFormat.font = font.fontName;
Font.registerFont(ArialBold);
textfield.embedFonts = true;
textfield.blendMode = BlendMode.LAYER;
//textfield.autoSize = TextFieldAutoSize.LEFT;
textfield.defaultTextFormat = textFormat;
textfield.setTextFormat(textFormat);
textfield.selectable = false;
textfield.text = text;
trace("drawingCanvas.height =" + drawingCanvas.height);
trace("drawingCanvas.width =" + drawingCanvas.width);
scoreBitmapData.draw(textfield);/
$textWidth = textWidth;
$textHeight = textHeight;
//*** end look
}
public function createScores(xPos:Number, yPos:Number, stopAnimation:int = 5,
scoreDelay:int = 10, scoreLife:int = 40):void {
var tempScore:Score = new Score(5, 1315, 5, 995);
tempScore.bitmapData = scoreBitmapData;
scoreBitmap = new Bitmap(tempScore.bitmapData);
tempScore.bitmap = scoreBitmap;
tempScore.x = xPos;
tempScore.y = yPos;
tempScore.life = scoreLife;
tempScore.lifeCount = 0;
tempScore.widthObject = $textWidth;
tempScore.heightObject = $textHeight;
tempScore._delay = scoreDelay;
tempScore.delayCount = 0;
tempScore.nextX = tempScore.x;
tempScore.nextY = tempScore.y;
scores.push(tempScore);
}
}
}
Here is some code of the BasicBlitArrayObject (tempScore rests upon that (i.e. Score-object):
package com.framework_mod.src
{
import flash.display.BitmapData;
import flash.geom.Point;
import flash.events.EventDispatcher;
import flash.geom.Rectangle;
import flash.display.Bitmap;
public class BasicBlitArrayObject extends EventDispatcher{
public var x:Number = 0;
public var y:Number = 0;
public var nextX:Number = 0;
public var nextY:Number = 0;
public var dx:Number = 0;
public var dy:Number = 0;
public var frame:int = 0;
public var bitmapData:BitmapData;
public var bitmap:Bitmap;
public var animationList:Array = [];
public var testList:Array = [];
public var point:Point = new Point(0, 0);
public var speed:Number = 0;
public var xMax:int = 0;
public var yMax:int = 0;
public var xMin:int = 0;
public var yMin:int = 0;
public var aniType:int = 1;
public var health:int = 0;
public var _size:int = 0;
public var score:int = 0;
public var _damage:int = 0;
public var count:int = 0;
public var bitmapSize:int = 0;
public var life:int = 0;
public var lifeCount:int = 0;
public var startCount:Boolean;
public var _delay:int = 0;
public var delayCount:int = 0;
public var startDelay:Boolean;
public var _stop:int;
public var stopAni:Boolean;
public var stopAniCount:int = 0;
public var _type:int = 0;
public var shield:int = 0;
public var healthPoints:int = 0;
public var widthObject:int;
public var heightObject:int;
public var boost:Number;
public var boostLfe:int;
public var weaponLfe:int;
public var _projXAdjust:Number;
public var _projYAdjust:Number;
public var number:int;
public var _offset:int;
public var marked:Boolean;
public var objMove:Boolean;
public var removeObj:Boolean;
public var finished:Boolean;
public function BasicBlitArrayObject(xMin:int, xMax:int, yMin:int, yMax:int)
{
this.xMin = xMin;
this.xMax = xMax;
this.yMin = yMin;
this.yMax = yMax;
//trace("basicblittarrayobject");
}
public function updateFrame(inc:int, aniType:int = 1):void
{
frame += inc;
switch (aniType) {
case 1:
if (frame > animationList.length - 1){
frame = 0;
}
bitmapData = animationList[frame];
break;
case 2:
if (frame > animationList.length - 1){
frame = 0;
}
bitmapData = animationList[1][frame];
break;
}
}
public function render(canvasBitmapData:BitmapData):void {
x = nextX;
y = nextY;
point.x = x;
point.y = y;
canvasBitmapData.copyPixels(bitmapData, bitmapData.rect, point);
}
public function dispose():void {
bitmapData.dispose();
bitmapData = null;
bitmap = null;
animationList = null;
point = null;
}
}
}
I think the problem is simple, but the resolution is not. The objects you are trying to transform are blitted. So they are not added to the stage. So the object's stage property is null.
I suspect that the TransformAroundPoint plugin is trying to use the object's stage property, and that is throwing a null object error your are seeing.
To see a simple example of this, make a very simple file.
Create two bitmaps, add one to the stage, and don't add the other.
Apply the tween to the stage instance, it will work.
Then apply the tween to the off-stage instance, and you should get the same error you get in the game.
What you will need to do instead is handle the transform yourself. Instead of using TweenLite to rotate around a point, do it yourself.
Fortunately Stack Overflow already has a great thread on that topic!
Rotate around a point that is not (0,0)