Problem: Solution to disappear after dynamic text box rotation?
There is a button on the stage named btn. The first key frame in the code layer has the following statement:
_ Root. createTextFiled ("dy_txt", 999,100,100, 90,50 );
With (dy_txt ){
Border = true;
BorderColor = 0xff3388;
Background = true;
BackgroundColor = 0x111111;
Type = "dynamic"
Text = "I want to rotate"
}
Btn. onRelease = function (){
Dy_txt. _ rotation + = 10;
}
I want to rotate the dynamic text box by clicking the button. However, when the button is clicked, the dynamic text box disappears. Why? Please give me some advice. The source file is as follows:
Ywxgood answer:There are two ways to solve the problem of rotating text disappears:
1. Use the embedded font, that is, set the embedFonts attribute to true. For more information, see the help provided by flash.
2. Convert the text box to a bitmap.
The code is as follows:
//////////////////////////////////////// /////////////////////////////////
Import flash. display. BitmapData;
Import flash. geom. Matrix;
Import flash. geom. ColorTransform;
Import flash. geom. Rectangle;
_ Root. createTextField ("dy_txt", 1,100,200,100, 22 );
With (dy_txt ){
Border = true;
BorderColor = 0xff3388;
Background = true;
BackgroundColor = 0xff0000;
Type = "dynamic ";
Text = "Hello ";
TextColor = 0x000000;
}
Btn. onRelease = function (){
_ Mc. _ rotation + = 10;
};
// Create BitmapData with the same width and height as the text box
Var bp: BitmapData = new BitmapData (dy_txt. _ width, dy_txt. _ height, false );
// Display bitmap. The draw method of BitmapData is described in detail in this document.
This. createEmptyMovieClip ("_ mc", 2 );
Bp. draw (dy_txt, new Matrix (), new ColorTransform (), normal, new Rectangle (0, 0, dy_txt. _ width, dy_txt. _ height), true );
// If the rotation is not processed, you can directly use the following sentence to save the imported ColorTransform, Matrix, and Rectangle classes.
// Bp. draw (dy_txt );
_ Mc. attachBitmap (bp, 1 );
// Hide the original text box and set the location of bitmap editing
_ Mc. _ x = dy_txt. _ x;
_ Mc. _ y = dy_txt. _ y;
Dy_txt. _ visible = false;