mardi 7 mars 2017

ActionScript 3.0 function for modify TextField

I started one week ago to study ActionScript 3.0. I would like to do a simple game. It will start with a window displaying a welcome message( "press the button to start"), and a arrow that start from the text and point to the button. I want to create everything from code. I'm using a TextField for the welcome message but I have some trouble. I created a file .fla AIR for Destkop. Then I associated to that file a class called mainFunzioneModidificaTest.as . In this class I wrote a function to set the text of the first window. I use the TextFormat but when I run the .fla file I see the text but without any formatting.The color, the dimension and the font dosen't change Here is the code. Can someone help me? Thank you!

package {
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFormat;

public class mainFunzioneModificaTest extends MovieClip {

    public function mainFunzioneModificaTest() {
        setText();
    }
    function setText(): void {
        var text: TextField = new TextField();
        var myFormat: TextFormat = new TextFormat("Arial", 39, 0xFF0000);
        text.setTextFormat(myFormat);
        text.text = "Hello";
        addChild(text);
    }

}

}

Aucun commentaire:

Enregistrer un commentaire