Archive for November, 2009

Place the exact same movie clip script on all 10 number keys. Do not place it on the asterisk or pound keys.

Test the movie. You should be able to click on any number key and see it light up. Click on it again and see it turn off. Test all 10 number keys. If it does not work, go back and double-check your work. Make sure that the right scripts are in the right places. You can use the example movie 08keypad.fla to see how this should work.

Place this script on the asterisk key:

onClipEvent (mouseUp) {
if (this.hitTest(_root._xmouse, _root._ymouse)) {
_parent.clearAll();
}
}

Instead of sending the movie clip to frame 1 or 2, this script calls a function named clearAll that is one level up from this movie clip. One level up is the root level; we will have to make a function at the root level named clearAll. We’ll get to that in a minute.

Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours

Comments No Comments »

Each movie clip instance must have a name. Name the 10 numbers one, two, three, and so on. Name the other two movie clips asterisk and pound.

Start with the movie clip at the upper-left corner. In Figure 8.1. It has the number 7 on top of it. It should be named seven. Place the following script on it:

onClipEvent (mouseUp) {
if (this.hitTest(_root._xmouse, _root._ymouse)) {
if (this._currentFrame == 1) {
this.gotoAndStop(2);
} else {
this.gotoAndStop(1);
}
}
}

This is exactly the same script that we used in the previous example. It determines whether a mouse click took place with the mouse over this movie clip and sends it either to frame 2 or frame 1, depending on where it is now.

Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours

Comments No Comments »

In the example movie 08keypad-noscripts.fla, you’ll find all the movie clip instances in place but no scripts there yet. You will also see a layer that contains the 10 digits and the * and # characters. I placed these on top of the movie clips so that I didn’t have to build 12 different but similar movie clips. Instead, I could reuse the same movie clip and make it appear different by placing a different number on top of it.

Start with the movie 08keypad-noscripts.fla. Or, you can create your own movie with 12 instances of the same movie clip.

These movie clips should all have two frames. The first frame is the off state of the key. It looks like all the keys in Figure 8.1. The second frame is similar, but you can tell that the key is lit up, or somehow highlighted.

Place a stop(); command on frame 1 of the movie clip. This prevents it from animating when the movie starts. We want it to stay at frame 1 and wait.

Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours

Comments No Comments »

To change this into a selection script, we have to allow the user to click the movie clip multiple times and change the state of the movie clip from off to on and back to off again.

The script has to determine which state the movie clip is currently in and then send the clip to the other frame. The script can determine the current state by looking at the current frame of the movie clip. This can be done with the aptly named _currentFrame property. This property reads 1 when the movie clip is on the first frame and 2 when it is on the second.

Here is the new script. You can see it in 08twomcs3.fla. This is a complex script because it first tests the location of the mouse and then tests the current frame of the movie clip.

onClipEvent (mouseUp) {
if (this.hitTest(_root._xmouse, _root._ymouse)) {
if (this._currentFrame == 1) {
this.gotoAndStop(2);
} else {
this.gotoAndStop(1);
}
}
}

Now you have seen two completely different ways of making selectable movie clips. I like the second way better because you don’t end up with the extra library symbols of the buttons. The advantage of using buttons, however, is that they can easily contain up, down, and over states, which are sometimes nice for user feedback as users make their choices.

Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours

Comments No Comments »

Overweight can be a serious problem for women. But, there’s solution to get out from this problem. You need to swimming. Yes, swimming is the best activity that will give you both, exercise and relaxation.

But, you also need best womens swimwear that will look good on your oversize body. Therefore, Swimsuitsforall.com is here to help you. Yes, you can get best big size swimwear here. All of them are designed so you will look beautiful when you wear it.

You also can get plus size bathing suits here too. So, visit now and get the best product that you want. If you need more information, there’s a number here that you can call.

Comments No Comments »

This is because all movie clips get the mouseUp event sent to them. It is not exclusive to just the movie clip under the cursor.

Determining Which Movie Clip Was Clicked
There is a way to determine which movie clip has been clicked. The hitTest function tests a mouse location with a movie clip to see whether the location is inside the movie clip. So, by modifying the script, we can only send the correct movie clip to its second frame. You can see this one in example 08twomcs2.fla.

onClipEvent (mouseUp) {
if (this.hitTest(_root._xmouse, _root._ymouse)) {
this.gotoAndStop(2);
}
}

The hitTest function can work a variety of different ways. In this case, it is fed the x and y values of the mouse location. It is prefaced with this so that it refers to the current movie clip. When the user clicks anywhere, the onClipEvent (mouseUp) handlers in all the movie clips get triggered. Then, both of the movie clips perform the hitTest test; only one that is under the mouse will test positive and jump to frame 2.

Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours

Comments No Comments »

You can detect a mouse click in a movie clip without a button. However, this method is a little trickier. After you learn it, though, it is a much cleaner solution.

To detect a mouse click on a movie clip without a button, use the onClipEvent(mouseDown) or onClipEvent(mouseUp) movie clip handlers. For instance, you can place the following script on a movie clip:

onClipEvent (mouseUp) {
this.gotoAndStop(2);
}

The example movie 08twomcs1.fla contains two instances of the same movie clip with this same script applied to both. Two frames are in the movie clip, each with a different colored circle. A stop(); command is on the first frame of the movie clip.

When you try this movie, you will see right away why the onClipEvent(mouseUp) handler is different from the on(release) handler used on buttons. If you click on one movie clip, they both react.

Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours

Comments No Comments »

By referring to this, the button is referencing the movie clip that it is in. Frame 2 of the movie clip contains a similar button named On Button. The difference is that the On Button is a little brighter, indicating that the movie clip has been selected. The script on this movie clip is similar:

on (release) {
this.gotoAndStop(1);
}

As you might guess, by clicking the button on frame 2, the movie clip goes to frame 1, where the original Off Button is located. By clicking the buttons in the movie clip over and over again, the movie clip goes back and forth between frames 1 and 2.

The only thing left is to place a stop(); command on the first frame of the movie clip. You can go to the example movie 07buttoninmc.fla to try this out.

Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours

Comments No Comments »

A movie clip cannot simply react to a mouse click. Unlike a button, it cannot use an on (release) or on (press) handler.

So you have to be tricky. You put a button inside a movie clip. The button can handle the mouse clicks as long as it is big enough to cover the entire movie clip.

The example 08buttoninmc.fla illustrates this. When you look at the movie, you will see that it has a single movie clip on the screen. Inside that movie clip is a single button.

To turn this into a selectable movie clip, we’ll have to make this into a multiframe movie clip. The first frame contains the button named Off Button. This button has the following script:

on (release) {
this.gotoAndStop(2);
}

Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours

Comments No Comments »

You have already learned how to make buttons that allow the user to click and make an action occur. A different type of user interface element, however, allows the user to select an item on the screen.

The difference is that a user clicks to make a selection, and that movie clip changes its appearance. But nothing else happens. This way, the user can make or change her selections. After that, the user can click another button or perform another action.

We’ll use selections as the first step toward learning how to drag and drop movie clips, the goal of this hour.

Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours

Comments No Comments »

  • Partner links