Tips for flash loading external files

Source: Internet
Author: User
Flash can invoke external files through frames, buttons, and movie clips. External files that are invoked include external text files, external program files, external *.swf files, external picture files, external music files, and external script files.


. Invoke an external text file: (The beginning of the text file begins with the variable name of the dynamic text box in Flash, such as


msg= "..." in this form, to be placed in the same directory as the edited Flash file


1. Use the Text tool in the Toolbox, select dynamic text, give dynamic text a variable name, such as MSG, and drag a text box in the edit area


2. Make two press buttons (one call, one purge) and drop them into the scene. (3lian material net)


3. Call on the button to add as:


on (Released) {//release the mouse to execute the following code;


loadvariables ("Msg.txt", msg)//Call the Msg.txt text file in the same directory as the one you edited, in the dynamic text msg;


system.usecodepage=true;//enables the Chinese characters in the external file to be displayed correctly;


  }


4. Clear the As:
on the button

on (release) {//loosen the mouse to clear the contents of the dynamic text box;


msg= "";


  }


5.ctrl+enter test.


Of course the code can also be written on the frame: (call the instance name of the button is BT1, clear the instance name of the button is BT2)


Add the following code on the first frame:


Stop ();


_root.bt1.onrelease=function () {


loadvariables ("Msg.txt", msg);


system.usecodepage=true;


}


_root.bt2.onrelease=function () {


_root.msg= "";


  }


ctrl+enter test.

The external text file that
calls can scroll:


1. Use the Text tool in the Toolbox, select dynamic text, give dynamic text a variable name, such as MSG, and drag a text box in the edit area


2. Create a new layer, make two presses (a call, a purge) drag and drop into this layer


3. Create a new layer and draw a vertical bar with a rectangular tool on the right side of the dynamic text box. The height is the same as the dynamic text; then make an upward direction "arrow" press F8 to press the torsion element; Copy an arrow to press the twist, the vertical mirror image, so that the two buttons and the ends of the vertical bar are aligned.


4. Call the AS:
on the button

on (Released) {//release the mouse to execute the following code;


loadvariables ("Msg1.txt", msg);//Call Msg1.txt text file to msg in dynamic text box;


system.usecodepage=true;//enables the Chinese characters in the external file to be displayed correctly;


  }


clear the As:
on the button

on (release) {


_root.msg= ""; Clear the contents of the dynamic text box;


  }


up button on the as:


on (Press) {//The following code is executed every time the mouse is pressed on the sensor area of the torsion;


_root.msg.scroll=_root.msg.scroll-1;//text scroll down one line;


  }


down button on as:


on (Press) {//The following code is executed every time the mouse is pressed on the sensor area of the torsion;


_root.msg.scroll=_root.msg.scroll+1;//text scroll up one line;


  }


ctrl+enter test.


Of course the code can also be written on the frame: (call the instance name of the button is BT1, clear the instance name of the button is BT2, the instance name of the button up is: Up, the instance name on the button down is down)


Add the following code on the first frame:


_root.bt1.onrelease=function () {//release the mouse to execute the following code;


loadvariables ("Msg1.txt", msg);//Call Msg1.txt text file to msg in dynamic text box;


system.usecodepage=true;//enables the Chinese characters in the external file to be displayed correctly;


  }


_root.bt2.onrelease=function () {//After releasing the mouse to perform


_root.msg= ""; Clear the contents of the dynamic text box;


  }


_root.up.onpress=function () {//press the button up button to execute the following code every time;


_root.msg.scroll=_root.msg.scroll-1;//text scroll down one line;


  }


_root.down.onpress=function () {//On press down button to execute the following code every time the mouse is pressed;


_root.msg.scroll=_root.msg.scroll+1;//text scroll up one line;


  }


ctrl+enter 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.