Lingo10-D script

Source: Internet
Author: User

I also reviewed various concepts about script in lingo.

Behavior: "Behavior is a set of handler ".

Handler: "Is the method/function for processing the event ".

Event: "Specific situations defined by the system or user. "Well, yes, the event here is indeed divided into two types: system and user-defined. In terms of system, there are two categories: one is automatic, and the other is manually triggered (mouseup ..). This distinction is not very interesting. It is only for the following "execution sequence of automatic system events ".

 

Sequence of Automatic System Events

 

Movie start frame:PreparemovieÀBeginsprite (OpenStartFrame)ÀPrepareframeÀStartmovie

Note: In the script dictionary document of director11.5, the order of beginsprite and prepareframe is reversed.

Within the intermediate Frame:Beginsprite (BenFrame)ÀStepframeÀPrepareframe ÀEnterframeÀExitframeÀEndsprite (LocalFrame)

Note: stepframe is the system event of parent script. It is useless to write on stepframe in frame behavior.

Movie end frame:Endsprite (EndBundleFrame)ÀStopmovie

It is alsoError (or obsolete). Events within a frame, such as xxxframe, are located between beginsprite and endsprite.

 

How does handler know the event?

 

If Handler has a mobile phone, director can call it when event occurs. But it does not, so ctor sends a message to handler.

Message: Director notifies handler of the communication mode when an event occurs.

The problem is, what if handler is too many? For example, for a button, its cast script has a flip effect, and the background color of mouseup changes; its sprite mouse clicks will stop playing; at the same time, when an event is clicked on the frame, a number indicating the number of frames is refreshed at a certain position on the screen. At the same time, the entire movie records the number of mouse clicks in the entire video. The scripts corresponding to the above four features are:

Cast member script: Button flip Effect

Sprite Behavior: Stop Function

Frame Behavior: Return framenum

Movie Script: Refresh clicknum

(This example must be awkward to get the four types of scripts .)

When this button is clicked, the handler of the mouseup event in the above four scripts receives the mouseup message in the following order: (return immediately after the advertisement ..)

 

The order in which Director sends messages to handler in different scripts

 

Sprite BehaviorÀCast member scriptÀFrame BehaviorÀMovie Script

Well, I should have noticed immediately that a Sprite, like Sprite behavior, has many behavior. What is the order of them?

The answer is logical, that is, in the order of addition. That is, the order of behavior in Sprite (Num). scriptinstancelist.

WhyMovie ScriptOfMouseupIs it not responding?

In the preceding 4 Class Handler There was a similar default Handler Such On mouseupscript . Handler It will continue to forward messages in turn after the execution of its own, of course, you can also disable ,Dontpassevent . And the above 4 Class Event Handler , You must manually add Pass () . For example Sprite Of On mouseup Otherwise Pass () Statement. Event That's even the end.

ThereforeHandlerEspeciallySystem Event Handler, Especially to confirm whether or notPass ().

 

Look back at handler.

 

Handler responds to the event.CodeEvent Handler is a function.

Of course, this function is written in a script, but the Script Type and _________ are a bit interesting.

The blank space will be added later. (Objects attached to the script)

 

Review script types

 

There are two types of scripts in ctor: lingo and JavaScript. -- Not that!

In ctor, there are three types of scripts: behavior, movie, and parent. -- That's what it means.

These three types are the three optional types seen in the Property inspector window when a script is created.

(Shortcut: script window Ctrl + 0, Property inspector CTRL + ALT + S ;)

(Then send the shortcut Ctrl + Shift + D for the current movie attribute. This shortcut is actually to open the Property inspector, but to locate the movie label immediately .)

The obvious difference between the three types is that behavior can be attached (dragged to score) to frame/Sprite, while movie and parent cannot.

In addition, behavior and parent have the me concept, that is, they exist in the form of 1. Behavior attachment; 2. Child-based parent.

Movie scripts are equivalent to the regions that can be accessed globally in the current project. In addition to the global system event handler, you can also write some global access functions here. Although it is also a separate script member form, its existence is more like the abstract with only the static method in C ++.

Then handler puts the function inDifferent TypesAndAttach to different locations.

I still want to explain how to create and use a script of a certain type, both of which you and those of the last n days are purely mentally retarded. It is like this (coming back immediately after the advertisement ...)

 

How to Create a script

 

There are many ways to create a script. You can:

Right-click Sprite and select script

In this case, the script window will topset and automatically create a behavior that has been attach to Sprite.

Click here to create a script member with the behavior type. 2 The behavior has been attach to Sprite, that is, you can find it in Sprite scriptinstancelist.

Double-click a frame of the script channel.

This is automatically created in the script window and is still a behavior, but it attach to a frame, which is a frame behavior.

In behavior script, both have me. This must exist.

+ In script window

The type of the newly created script seems to be the type of the script used once.

If you want to create a movie, you can directly type the script after ensuring that the type is correct in the Property Window.

If you want to create a behavior, in addition to the above operations, after you have knocked on the keyboard, You have to attach it to the frame or prite. There are also many attach methods. Gui methods include: 1. Drag script member to score; 2. Drag script member to stage; 3, select sprite or frame and click + Add in behavior inspector. (Behavior Inspector shortcut: CTRL + ALT + ;)

The parent to be created is the same as that of movie. Only a new child is required for use.

Right-click cast member and choose cast member script

This is strange. You can't even see the type in the Property inspector. This script does not add a new script member to cast.

These two points are logically consistent, but the difference is that cast member script is obviously a script, but it is not included in script member.

Other aspects, such as how the internal handler processes the event, have been mentioned earlier. Director manages the event with other scripts.

Note that a cast member script does not necessarily execute the sprite. You need to manually add it in behavior inspector and still press that +. (Behavior Inspector shortcut: CTRL + ALT + ;)

In addition, do not forget to forward the event message command pass ().

 

 

 


 

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.