Two ways to invoke an external text file in Flash

Source: Internet
Author: User
Tags insert

Method One: Use the up and down scroll button

1. Open the text file and copy the text to the program "Notepad" that is brought in by Windows 2000. and enter "t=" ("T" as a variable defined for us) before the text content, then save as "M.txt" file, save the location as "My Documents", encode "UTF-8" or " Unicode ".

2. Run Flash MX, in the name "Call external text file in Flash", Save in My Documents (note: The Flash MX file must be in the same folder as the external text file that will be invoked).

3. Create a dynamic text box on the stage and name the dynamic text instance "MyText" in the Properties panel, set the various properties of the text, set the text box to multiple lines, and enter "T" in the Variable text box.

4. Click the (Insert Layer) button in the lower-left corner of the timeline window to insert a new layer and the system is automatically named Layer 2. Right-click the first frame of the layer, select "Action" from the pop-up shortcut menu, open the Action-frame window, and enter "Loadvariablesnum (" M.txt ", 0) in expert mode;".

5. Click the (Insert Layer) button in the lower-left corner of the timeline window to insert a new layer and the system is automatically named Layer 3.

6. Click Windows/Common Library/button to open the Library-button window. Double-click the Circle Buttons folder in the window and drag the Circle with arrow button onto the stage, using the zoom, rotate tool to adjust it to an arrow up and the appropriate size. Finally drag it to the right position on the right-hand side of the dynamic text box. Repeat the above action, and then create an arrow down button. Right-click the arrow up button, select the action from the pop-up shortcut menu, open the Action-button window, and enter the following statement in Expert mode:

On (Press) {
Mytext.scroll =mytext.scroll+1;
}

Similarly, add the following statement for the arrow down button:

On (Press) {
Mytext.scroll =mytext.scroll-1;
}

7. Press the "Ctrl+enter" key to test, click the up arrow button, text scroll up one line, click the down arrow button, text scroll down one line.

Method Two: Using the scroll bar component

1. Step 1 of the same method.

2. Step 2 of the same method.

3. Create a dynamic text box (or an Input text box) on the stage and, in the Properties panel, still name the dynamic text instance as "MyText," set various properties for the text, and set the text box to multiple lines.

4. Click the (Insert Layer) button in the lower left corner of the timeline window to insert Layer 2.

5. From the Flash MX palette, drag the scroll bar component to the right edge of the dynamic text box instance, where the component is automatically combined with the text box.

6. Click the (Insert Layer) button in the lower left corner of the timeline window to insert Layer 3.

7. Right-click the first frame of Layer 3, click Actions on the pop-up shortcut menu, open the Actions-frames window, and enter the following in expert mode:

MT = new Loadvars ();//Create an instance of a Loadvars object with an instance named MT
Mt.load ("M.txt");//The object to be loaded for the MT instance created is the M.txt text file
Mt.onload = function (s) {//Start loading external file. The parameter s indicates whether the load operation completed successfully. If it is done, then the value of S is true (true) and False (false).
if (s) {
Mytext.text = mt.t;
}//If the load succeeds, the content in the MyText text box equals the contents of T in the Mt instance (t is the variable that we previously defined in the external text file)
};

8. Press "Ctrl+enter" key to test.



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.