Some basic AS

xiaoxiao2021-03-06  14

Flash can call external files through frames, pressing, movie clips. Calling external files include: external text files, external program files, external * .swf files, external image files, external music files, external script files. 1. Call external text file: (The text file begins with the variable name of the dynamic text box in Flash, such as MSG = "........", to put the Flash file to edit Under the same directory) 1. Use the text tool in the toolbox, select dynamic text, give dynamic text a variable name, such as: MSG, drag a text box in the editing area 2. Make two press (a call, one Clear) Drag and drop into the scene. 3. Call Press to Torked Add as: On (Release) {// Loosen the following code after the mouse; loadvariables ("msg.txt", msg); // call and your edited Flash under the same directory MSG .txt text file into dynamic text MSG; system.usecode = true; // enables the Chinese characters of the external file to display correctly;} 4. Clear the as: on (Release) {// Loosen the mouse after clearing the mouse Dynamic text boxes; msg = "";} 5.ctrl enter test.

Of course, the code can also be written on the frame: (Call the transformation of the transformation is BT1, clear the transformation instance name 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 called: 1. Use the text tool in the toolbox, select dynamic text, give dynamic text, one variable name, such as: MSG, dragging a text box in the editing area 2. Newly built two, create two Transfer (a call, one clearance) Drag and drop to this layer 3. Create a new layer, draw a vertical bar in the right side of the dynamic text box, the high and dynamic text is the same; then make an upward direction "arrow "Press F8 to turn to call the component; copy a" arrow "button, vertical mirror icon, align the two directed and vertical bars. 4. Call and press the AS: On (Release) {/ / Loosen the following code after the mouse; loadvariables ("msg1.txt", msg); // calls msg1.txt text file into dynamic text box MSG; system.usecodepage = true; // makes the Chinese characters for external files Correctly displayed;} Clear as: on (transase) {_root.msg = ""; // clear the contents of the dynamic text box;} AS: on (PRESS) {////// Perform the following code per click on the induction area; _root.msg.scroll = _root.msg.scroll-1; // Text scroll down;} Press the twisting on: ON Press) {// Perform the following code per mouse on the keying induction zone; _root.msg.scroll = _root.msg.scroll 1; // Text scroll down;} Ctrl Enter Test.

Of course, the code can also be written on the frame: (call the transformation of the transformation is BT1, clear the transformation instance name is BT2, the instance name of the forward button is: Up, press down to press the instance name is DOWN) The first frame is added as follows: _root.bt1.onrelease = function () {// Loosen the following code after the mouse; loadvariables ("msg1.txt", msg); // call msg1.txt text files to dynamics Text box MSG; system.usecode = true; // Make the Chinese characters of the external file to display correctly;} _ root.bt2.onrelease = function () {// Loosen the mouse after _Root.msg = ""; // Clear the content in the dynamic text box;} _ root.up.onpress = function () {// In the up, press the code to perform the following code per click; _root.msg.scroll = _root.msg.scroll-1; / / Text scroll down;} _ root.down.onpress = function () {// Down to press down to do the following code per click; _root.msg.scroll = _root.msg.scroll 1; / / Text roll up;} Ctrl Enter test. 2. Call the external * .swf file (loaded into the movie clip): External * .swf file should be placed in the same directory with the edited flash file 1. newly established an empty The movie editing MYMC, put it in the scene, the instance name is: mymc.2. New layer, make two press (a call, one clearance) drag and drop to this layer 3. Call and press the twisting : On (Release) {// Mouse leaves the following code after being twisted; loadMovie ("Flash8.SWF", "MyMC"); / / Load the external "flash8.swf" file to "MyMC" empty movie clip MMC._X = 70; // Load the X-axis coordinate of the film; mymc._y = 20; // load the Y-axis coordinate of the movie; mymc._xscale = 70; // load the width of the movie; mymc._yscale = 70; // Load the height of the movie;} Clear the as: on (Release) {// mouse button on: on (Release) {// Mouse to execute the following code unloadMovie (MyMC); // Delete the * .swf file loaded with LoadMovie;} Ctrl ENTER test

3. Call the external * .swf file (loaded to the timeline): External * .swf file to be in the same directory and edited Flash files 1. Make two twists (a call, one clearance) drag and drop to the scene 2.2. Call the AS: on (Release) {// mouse to leave the code to perform the following code LoadMovie ("Flash8.swf", 1); // load the external "flash8.swf" file to the scene In the middle, the layer depth is 1;} Clear the as: on (Release) {// mouse to leave the twist, execute the following code unloadMovie (1); // Delete the layer depth is 1 LoadMovie loaded with LoadMovie " Flash8.swf "file} Ctrl ENTER test. Of course, the second and third code can be written on the frame.

IV. Call the external picture (loaded into the movie clip) External picture must be in the same directory with the Flash file being edited 1. Make two press (a call, a clearance) Drag and drop in the scene 2. Make an empty The movie clip is dragged into the scene, the instance name is: mymc; 3. AS: i = 0 on the first frame on the timeline; // Define a variable I, and the beginning value is 0; call to press twisting As: on (release) {// mouse leaves the following code after the twist; i ; if (i> 9) {// Because there is 9 pictures outside, when the variable is greater than 9, the variable is 1, This will make the loaded picture is continuous, that is, each point is twisting, change a picture, etc., come to the ninth map, then call the twisting, loop to the first picture (J1.jpg to J9 .jpg, because there is no j0.jpg, if i = 0, it will be prompted to find j0.jpg); i = 1;} loadmovie (("J" i) "jgp", mymc); // J1.jpg began to load pictures in the movie editing MYMC; mymc._x = 110; // The following settings loaded the image of the image with MYMC._Y = 35; mymc._yscale = 130; mymc._yscale = 130;} Clear button As: on (release) {unloadMovie (MyMC); // Delete Picture of loaded with loadmovie to the movie clip;} Ctrl Enter test. Of course, the AS can be written on the frame. 5. Calling an external sound file (loaded into the scene) External sound file must be in the same directory with the Flash file being edited 1. Make two press (a call, one clearance) drag and drop in the scene 2. call The as: on (Release) {// mouse exits the following code after the twist; mysound = new sound (); // build a new sound object mysound; mysound.loadsound ("zaihuni.mp3", TRUE ); // load the external * .mp3 sound file into the mysound object, and play in the flow (when the parameter is false, it is played after loading);} Clear the twisting on (Release) { MySound.stop (); // When you press the clear button, stop the playback of the sound} Ctrl Enter test.

转载请注明原文地址:https://www.9cbs.com/read-48293.html

New Post(0)