Flash typing effect

Source: Internet
Author: User
Tags setinterval

The flash typing effect is also used in many animations, such as the AE typing effect. For example, the typewriter effect, flash typewriter effect, and premiere typing effect are easy to implement. There is also a kind of such effect: webpage typing effect. The animation typing effect can be achieved by using js on the webpage, but the flash typing effect can be more beautiful.

Step 1: import a typing sound to the first frame in the home scene, and set the sound to "event" and "loop" in the attribute panel ". (If the sound in the library is loaded, the loading time is not good)
Step 2: write the following code on the frame ----
// Declare the variable
Var my_sound: Sound = new Sound (_ root );
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, just as I gently came;" + newline + "I waved gently, the clouds of the West sky. "+ Newline +" The Willow on the banks of that river is the bride in the sunset; "+ newline +" The Shadows in the light are Ripple in my mind. "+ Newline +" soft mud on the green, the oil shake under the bottom; "+ newline +" in the conghe soft wave, I am willing to make a water plant! "+ Newline +" a pool under the shadow, not a spring, "+ newline +" is a rainbow broken in the floating algae, precipitation of a Rainbow Dream. "+ Newline +" dream searching? Let's hold on a long journey and roll back to the green grass. "+ newline +" is loaded with a ship of stars, singing in the stars. "+ Newline +", but I can't play songs. Quietly, it's a separation. "+ newline +" Xiadong is also silence for me. Silence is Kang Qiao tonight. "+ Newline +" I walked quietly, just as I quietly came; "+ newline +" I waved my sleeves without a cloud color. ";
// Create dynamic text
This. createTextField ("my_txt", 1, 30, 10,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 = 0 xFFFFFF;
// 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 )){
// 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 );
// Variable increments by 1
I ++;
}
// If the variable I is greater than the number of my_str characters
If (I> length (my_str )){
// Sound stops
My_sound.stop ();
// Stop setInterval () call
ClearInterval (id );
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.