~EDIT~ Now sets to null as operator used was “==” instead of “=”;
Movement is still an issue ~END EDIT~
~EDIT~ PlayerText is declared at the beginning of the as and if statement now tests its text not the object. Only the movement issue now
~END EDIT~
I’ve got two (possibly three) logic errors going on… Well, I say logic errors as the compiler and output windows are clear from any error reports. Can anyone lend some insight?
Error 1: Dynamic Text Field
if (PlayerText == null && !this.contains(PlayerText)) {
PlayerFormat.font = PlayerFont.fontName;
PlayerFormat.size = 21;
PlayerFormat.color = 0xFFFFFF;
PlayerFormat.align = "center";
PlayerText = new TextField();
PlayerText.type = TextFieldType.DYNAMIC;
PlayerText.autoSize = TextFieldAutoSize.CENTER;
PlayerText.defaultTextFormat = PlayerFormat;
PlayerText.embedFonts = true;
PlayerText.wordWrap = true;
PlayerText.width = 250;
this.addChild(PlayerText);
}
PlayerText.x = x;
PlayerText.y = y - 20;
trace(getQualifiedClassName(getChildAt(0)));
//PlayerText display options
if (isKeyDown(Keyboard.UP)) {
if (!textTime.running) {
textTime.start();
}
PlayerText.text = "Interact";
}
if (!textTime.running) {
PlayerText.text = "";
}
So first off I create the PlayerText dynamic text field using the first bit of code and edit the text using the scond. The textfield never displays on the screen. I know the second piece of code works becuase when I trace the PlayerText.text, it outputs the correct values. When I run the trace in the first line of vode (gets class name of child) it returns:
flash.display::Shape
Any ideas why? Shouldn’t it return TextField? And would this be what’s interfering with displaying the text field?
Error 2: Not setting to null
if (over.currentFrameLabel == "lastFrame"){
if (stage.contains(over)) {
stage.removeChild(over);
over == null;
trace("over removed");
}
trace(over);
controlAllow = true;
}
This traces the first statement but then when I trace its value, it still returns that the variable “over” is still to the object and not null. Can’t figure out why…
The other problem may be occurring because of this but when the game runs. All of the player movements script is within an if statement that only executes if controlAllow = true. When the over is added to the stage it sets controlAllow to false, but after the over is added it still moves. I tried to clear the kayArray but it threw me errors, so i tried to cycle the keyArray in a for loop and set all values to false but it wasn’t having any of that either.
Any help with any of this would be largely appreciated