Flash to make beautiful music beat rhythm Tutorial

Source: Internet
Author: User
Tutorials | bounce

First look at the effect of adding random colors:

One: Build a MC named: Beat the Pillar, and then draw a small rectangle here.

Second: To build a MC named: The next part of the jump pillar, the beating of the pillars dragged into the scene: and then 5,10,15,20,30. Frame Insert KeyFrames (F6) to animate these frames.

Third: To build a film called: the top block of the movie, draw a small rectangle.

Four: To build a single jumping column of the film elements, will be the next part of the Jump column and the top block into the top block placed above. The lower part of the pillar is below.

Five: To build a MC named: Seven Jumping pillars, drag eight single jumping pillars, respectively, the instance name: Bar1-bar8.

Then write the code in the first frame:

This._parent.mysound.setvolume (100);
Set the volume of music
var Num = 8;
The number of bouncing columns
var space = 2;
Space between the top block and bar
var Soundon = true;
Identifies the music switch's identifier and is set to
var i = 1;
while (I<=num) {
MyColor = new Color (this["Bar" +I].BARMC);
Mycolor.setrgb (Random (0XFFFFFF));
this["Bar" +i].barmc.gotoandplay (Random (this["bar" +i].barmc._totalframes));
Sets the music bounce column to start playing in the random frame of the total frame number of the BARMC
/////////////////////////////////////////////
this["Bar" +i].onenterframe = function () {
Always detect the position of the top bar. Let it follow the BARMC.
var bar = this;
Trace (Bar.barmc._yscale)
if (Soundon = = True) {
If the music is playing state
if (-bar.barmc._height-space<bar.topmc._y) {
Set the position of the top jump block
bar.topmc._y = -1*bar.barmc._height-space;
Set the position of the top block to the height of the runout block (this height is randomly changed)
}
bar.topmc._y = bar.topmc._y+7.000000e-001;
Return
}
};
//////////////////////////////////////////////////
++i;
}
Stop ();

VI: Add the Music play code to the scene:

var mysound:sound=new Sound ()
Mysound.attachsound ("S1")
Mysound.start (5,1) dragged seven bouncing pillars into the scene.

Flash source file Download:music.rar



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.