Stop ();
// Declare the variable
Var my_sound: Sound = new Sound ();
My_sound.attachSound ("dazi.mp3 ")
My_sound.start ()
Var id: Number = setInterval (dazi, 100 );
Var I: Number = 0;
Var my_fmt: TextFormat = new TextFormat ();
Var my_str: String = "Goodbye to Kangqiao -- Xu Zhimo" + newline + "I walked gently," + newline + "as I gently came; "+ newline +" I waved gently. "+ newline +" let's see the clouds of the West. ";
// Create dynamic text
This. createTextField ("my_txt", 1,100, 40,120, 20 );
// Control the automatic size adjustment and left alignment of text fields
My_txt.autoSize = true;
// Set text line spacing
My_fmt.leading = 6;
// Set the text color
My_fmt.color = 0x000000;
// Apply the new text format to dynamic text
My_txt.setNewTextFormat (my_fmt );
// User-defined functions
Function dazi (){
// If the variable I is not greater than the number of my_str characters
If (I <= length (my_str )){
I ++;
// Display the characters of my_str in dynamic text (starting from the first character with the length of I)
My_txt.text = my_str.substr (0, i-1 );
// Variable increments by 1
}
// If the variable I is greater than the number of my_str characters
If (I> length (my_str )){
My_sound.stop ()
// Stop setInterval () call
ClearInterval (id );
SetTimeout (function (){
I = 0;
My_txt.text = "";
My_sound.start ()
Id = setInterval (dazi, 100 );
},5000 );
}
}