Write a simple Flash pull-down menu, all only blame my art too bad, do not too good-looking! But as a novice to learn the example is very good! You novice friends, can not miss!!
Production process:
1, the production of four buttons, respectively, written on Photo_1, Photo_2, Photo_3, Photo_4.
2, import four picture.
3, new four movie clips, the previous prepared button and picture one by one dragged into the clip, and the instance name is set to BT, and finally four clips are dragged into the four layers of the scene, respectively, and named Ph1,ph2,ph3,ph4.
Here's the code, adding the following code in the first frame:
_global.pre = "PH1";//To assign the diagram being displayed to the pre variable
For (I=1 i<5; i++) {//event with loop Write button
this["ph" +i].bt.onrelease = function () {
_global.speed = 0;//to make initial speed 0
_global.cur = this._parent._name;//assigns the clicked graph to the cur variable
Trace ("Pre:" +_global.pre);
Trace ("cur:" +_global.cur);
Id_up = SetInterval (this._parent._parent, "action_up", _global.pre);//action_up function once every 10ms!
};
}
var action_down = function (cur) {//The functions implement the clicked picture Down!
_global.speed + + 1;//to implement buffering effect
This[cur]._y + = _global.speed;//Move picture
if (this[cur]._y>=17.4) {//stop moving when a predetermined position is reached
this[cur]._y = 17.4;//prevents alignment
Clearinterval (Id_down);//Clear clock
_global.pre = cur;//to record the diagram being displayed to the pre variable
}
};
var action_up = function (pre) {//The functions implement the clicked image up-Move!
_global.speed + + 1;//to implement buffering effect
This[pre]._y-= _global.speed;//move picture
if (this[pre]._y<=-300) {//stop moving when a predetermined position is reached
this[pre]._y = -300;//prevents alignment
Clearinterval (ID_UP);//Clear clock
Id_down = SetInterval (This, "Action_down", "_global.cur"); Action_down function is called once every 10ms! Parameters passed by _global.cur
_global.speed = 0;//to make initial speed 0
}
};