symbol with text in action script 3
Hello, I have a problem with displaying a text symbol in ActionScript 3.
I am making a project to test the operation of dialog boxes and for this I need to display symbols on which there will be pictures of a speaking character, a dialog background and text - but it is the only thing that is not displayed.
I hid the symbol at the beginning of the code and make it visible when interacting with the object, I also checked through debugging whether the symbol is visible - it says yes, although there is nothing on the screen.
The text symbol is made as dynamic text in the Arial font, the font has the desired language built in, the size is 20 pt and opaque. I tried to move the symbol to the hud but nothing changed.
The code itself is written below, and the photo shows that the dialog has started, but the text is not highlighted.
there is a lot of code here that is not related to the dialogue, because of which you need to ignore a lot, but just in case I left even such nonsense.
the function that makes the symbols visible starts on the 65th line, and on the 70th line specifically the text symbol.
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import flash.display.MovieClip;
import flash.events.Event;
import flash.display.Stage;
lilyEc.gotoAndStop("lily stand front frame");
textBoxEc.visible = false; // Initially hide the dialogue box
lilyphrase1Ec.visible = false; // Initially hide the dialogue text
var rightPressed: Boolean = false;
var leftPressed: Boolean = false;
var upPressed: Boolean = false;
var downPressed: Boolean = false;
var spacePressed: Boolean = false;
var linkSpeed: Number = 6;
var dialogActive: Boolean = false;
var lastDirection: String = "front";
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
stage.addEventListener(Event.ENTER_FRAME, gameLoop);
function keyDownHandler(keyEvent: KeyboardEvent):void {
if (!dialogActive) {
if (keyEvent.keyCode == Keyboard.RIGHT) rightPressed = true;
else if (keyEvent.keyCode == Keyboard.LEFT) leftPressed = true;
else if (keyEvent.keyCode == Keyboard.DOWN) downPressed = true;
else if (keyEvent.keyCode == Keyboard.UP) upPressed = true;
}
if (keyEvent.keyCode == Keyboard.SPACE && !spacePressed) {
spacePressed = true;
if (checkInteraction()) {
startDialogue();
}
}
}
function keyUpHandler(keyEvent: KeyboardEvent):void {
if (keyEvent.keyCode == Keyboard.RIGHT) rightPressed = false;
else if (keyEvent.keyCode == Keyboard.LEFT) leftPressed = false;
else if (keyEvent.keyCode == Keyboard.DOWN) downPressed = false;
else if (keyEvent.keyCode == Keyboard.UP) upPressed = false;
else if (keyEvent.keyCode == Keyboard.SPACE) spacePressed = false;
}
function checkInteraction():Boolean {
return lilyEc.hitTestObject(dialogSirEc);
}
function checkCollision(nextX:Number, nextY:Number):Boolean {
lilyEc.x = nextX;
lilyEc.y = nextY;
var isColliding:Boolean = lilyEc.hitTestObject(catEc) || lilyEc.hitTestObject(sirEc) ||
lilyEc.hitTestObject(stairEc) || lilyEc.hitTestObject(wallEc);
lilyEc.x -= (nextX - lilyEc.x); // Reset position
lilyEc.y -= (nextY - lilyEc.y);
return isColliding;
}
function startDialogue():void {
dialogActive = true;
rightPressed = leftPressed = upPressed = downPressed = false;
lilyEc.gotoAndStop("lily stand " + lastDirection + " frame");
textBoxEc.visible = true; // show dialogue box
lilyphrase1Ec.visible = true; // text
trace("Dialogue started with sirEc.");
// additional dialogue
}
function gameLoop(loopEvent: Event):void {
if (dialogActive) {
lilyEc.gotoAndStop("lily stand " + lastDirection + " frame");
return;
}
var nextX:Number = lilyEc.x;
var nextY:Number = lilyEc.y;
var moving:Boolean = false;
if (rightPressed && lilyEc.x + linkSpeed <= 500 && !checkCollision(lilyEc.x + linkSpeed, lilyEc.y)) {
nextX += linkSpeed;
lastDirection = "right";
moving = true;
}
if (leftPressed && lilyEc.x - linkSpeed >= 180 && !checkCollision(lilyEc.x - linkSpeed, lilyEc.y)) {
nextX -= linkSpeed;
lastDirection = "left";
moving = true;
}
if (downPressed && lilyEc.y + linkSpeed <= 410 && !checkCollision(lilyEc.x, lilyEc.y + linkSpeed)) {
nextY += linkSpeed;
lastDirection = "front";
moving = true;
}
if (upPressed && lilyEc.y - linkSpeed >= -70 && !checkCollision(lilyEc.x, lilyEc.y - linkSpeed)) {
nextY -= linkSpeed;
lastDirection = "back";
moving = true;
}
lilyEc.x = nextX;
lilyEc.y = nextY;
// Play correct walking animation
if (moving) {
lilyEc.gotoAndStop("lily walk " + lastDirection + " frame");
} else {
lilyEc.gotoAndStop("lily stand " + lastDirection + " frame");
}
// Camera follows Lily by moving the parent container
this.x = stage.stageWidth / 2 - lilyEc.x;
this.y = stage.stageHeight / 2 - lilyEc.y;
}

