Use the slider to control text movement

Source: Internet
Author: User

We recommend that you first download the original file and open it so that you can refer to the following descriptions.
1. we need to use a button to drag the text, so we need to have a text mc (mc refers to video editing), write a text in the scene, select a text, press F8 to convert it into mc, mc is named as a publicity slogan and its instance name is set to wby.
2. Create a new mc named mc in the main scenario and set its instance name to "any. So what do we mainly put in this mc ???
Don't worry. Let's put an empty mc and a button (empty mc ??? Have you heard of it ?? Haha, you will know what it means .) Press Ctrl + F8 to create a new mc named: empty mc. You do not need to enter the instance name for it.
Since it is an empty mc, it does not have any graphics or text, but note that it still has content. What else should we do with it ?? Its content is ------ code. Don't be afraid. I will explain it clearly to you, but let's talk about how to do it first, OK ??
In this empty mc, we put two blank key keywords (that is, the first and second phases of the blank key keywords). On the first release, we add the following code:

TellTarget (_ root. any ){
SetProperty (wbh, _ y, wbyy-(_ y-ans)/anh * (getProperty (wbh, _ height)/1.300000 ));
}

Tell the "mc of the main scenario" (the instance name is set to any) in the scenario to set the properties of the ordinate of an object called wbh, the following wbyy-(_ y-ans)/anh * (getProperty (wbh, _ height)/1.300000) is the ordinate value of the wbh object. (For details, refer to the Golden Flash Forum.Http://goldflash.lpscn.comSee the home page> webpage technical area> Technical Exchange area [help] code does not understand)

We add the following code on the second release:

GotoAndPlay (1 );

Okay, this empty mc is done.

Return to video editing-mc of the main scenario (note that it is not back to the main scenario)
We don't care about this empty mc. Next we will create a new name: The new button, so you don't need to set the instance name for it. Add the following code to the button:

On (press)
{
StartDrag ("", false, _ x, ans, _ x, anw );
}

On (release, releaseOutside)
{
StopDrag ();
}

The format of the drag command can be written
StartDrag (target, [lock, left, top, right, bottom])
Or target. startDrag ([lock, left, top, right, bottom])
Parameters
Target refers to the target path of the drag video clip.
Lock is a logical value that specifies whether the drag clip is locked to the center of the mouse position (true) or to the position where the user clicks the clip for the first time (false ). This parameter is optional.
The value of left, top, right, and bottom relative to the parent coordinate of the video clip. These values specify the constrained rectangle of the video clip. These parameters are also optional.

When you press the mouse, start to drag this ("" refers to this stuff, both button) false indicates that you can drag a video clip to the position where the user clicks the video clip for the first time. Oh, it's a bit hard to understand, right ?? I understand it as follows: the location of the button is the same every time you open the file. It won't be because you dragged it this time. The next time you open the file, you will go to the location after the drag.
The drag button has a range limit. If there are two _ x, it indicates that its x coordinate is limited to death. It can only be the current x coordinate of the button. That is to say, this button can only be moved up and down.
When you move the mouse down, stop dragging.

Below we find some strange values, such as ans, anw, wbh, and wbyy, as if we haven't defined them yet, right?

Then let's define these values. Where do we define these values? In the mc of the video clip-main scenario, we create a new layer, put the code to define these values on the blank key pair at this layer. The code is as follows:

Anh = 313; // used to specify the length of the button for dragging the cursor up or down (the length value is set by yourself)
Ans = _ y; // you can pay the ordinate value of the mouse position to the variable ans, that is, the ordinate value before the button is dragged.
Anw = Number (ans) + Number (anh);
Wbh = _ root. wby;
Wbyy = getProperty (wbh, _ y );

The last two sentences
Wbh = _ root. wby; is to define the wby in the home scene, that is, the text mc to the variable wbh
Because our text is movable, you can think of it as putting the text mc in the scene and the immovable text mc into the mc of the video editing-main scenario, by the way, we gave it a variable name: wbh.
Now you know

SetProperty (wbh, _ y, wbyy-(_ y-ans)/anh * (getProperty (wbh, _ height)/1.300000 ));

Who is wbh in ??

Then wbyy = getProperty (wbh, _ y); it means to pay the value of the wbh ordinate value obtained at any time to the variable wbyy;
Now, do you know why the text is moving ??

Finally, drag this video clip-the mc of the main scenario to the scenario!

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.