Multimedia interaction application BASICS (1)

Source: Internet
Author: User

As 3.0 provides a good way to interact with each other. If you are used to as2.0, the conversion to as3.0 may fail sometimes. In fact, you should think carefully about the procedures evolved from the original foundation, the idea remains unchanged.

Flash has a good use. Many people like to use it to make multimedia. Flash has obvious advantages. As long as you know some of its applications, you may become a master.

 

Okay. Let's try some simple interaction effects. For the first time, we tried some simple operations and clicked a button with the mouse.

 

Question 1: click the button with the mouse and output "you clicked me" on the output panel"

 

Step: 1. Create a button in the scenario and rename it in the property panel: BTN

2. Create a new class name, example.

  1. Package
  2. {
  3. Import flash. display. movieclip;
  4. Import flash. Events .*;
  5. Import flash. display. simplebutton;
  6. Public class example extends movieclip
  7. {
  8. Public Function example ()
  9. {
  10. BTN. addeventlistener (mouseevent. Click, onclick );
  11. }
  12. Private function onclick (E: mouseevent): void
  13. {
  14. Trace ("You clicked on me ");
  15. }
  16. }
  17. }

We have completed the interaction of the first mouse. Looking at the program with less than 20 lines of code, we can find that when we click the button with the mouse, then output the desired result in the output panel. Now that we know that this effect can happen after clicking the mouse, we just need to change some actions to achieve more and better interaction effects.

 

Question 2: When we click the mouse, the position of an object changes.

Step 1: Add a video clip for MC in the original scenario. Write MC in the attribute panel

 

  1. Package
  2. {
  3. Import flash. display. movieclip;
  4. Import flash. Events .*;
  5. Import flash. display. simplebutton;
  6. Public class example extends movieclip
  7. {
  8. Public Function example ()
  9. {
  10. BTN. addeventlistener (mouseevent. Click, onclick );
  11. }
  12. Private function onclick (E: mouseevent): void
  13. {
  14. MC. x = 50;
  15. }
  16. }
  17. }

When you see the above, the content in onclick is changed. When you click with the mouse, the X coordinate of MC is moved,

Assume that it is 100 at the beginning. When you click it, the attribute of x changes. Here we know one thing. How to change the attributes of an object to produce more interaction results.

Continue with the other questions below.

 

Question 3: When we click the mouse, the size of an object is scaled.

Step: directly change the content in the video clip without changing anything.ScalexAttributeScaley attributes

 

  1. Package
  2. {
  3. Import flash. display. movieclip;
  4. Import flash. Events .*;
  5. Import flash. display. simplebutton;
  6. Public class example extends movieclip
  7. {
  8. Public Function example ()
  9. {
  10. BTN. addeventlistener (mouseevent. Click, onclick );
  11. }
  12. Private function onclick (E: mouseevent): void
  13. {
  14. MC. scalex = 0.5;
  15. MC. Scaling = 0.5;
  16. }
  17. }
  18. }

Here we can understand some simple interaction effects, and use the mouse to change some attributes of other objects or make some effects on other objects. These are the first steps to try to make a multimedia interaction effect. In addition to the mouse clicking effect, we also have the mouse clicking, when the mouse is moving, when the mouse is rolling, these are the basis for some simple Interactive effects through the mouse.

 

 

 

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.