Wednesday, July 21, 2010

AS quickly teach you to draw simple and practical to use the menu


Preview the final result:

Source and Analysis:

/ / Direct draw with AS menu, features small color blocks will move and move with the mouse.
/ / The following is the main program.
var menuText = new Array ("My collection of pictures," "My music collection", "My personal work,"
"I want the diary," "now wrote to me", "into my book");
/ / Menu label.
var menuURL = new Array ("http:// #", "http:// #", "http:// #", "http:// #",
"Qxiao_xi@tom.com", "http://ningning.dns0755.net");
/ / Menu label point to the URL.
var theItem;
/ / Create MC to spend time on this variable.
var i;
/ / Loop variable.
var step;
/ / Blocks of color moving steps.
var running;
/ / Determine whether the moving variable.
/ / Create a new function. May be cited directly this.DrawRect (x, y, w, h);
/ / X, y -> coordinates, w, h -> width and height.
MovieClip.prototype.DrawRect = function (x, y, w, h) (
this.moveTo (x, y);
this.lineTo (x + w, y);
this.lineTo (x + w, y + h);
this.lineTo (x, y + h)
this.lineTo (x, y);
);
/ / Create menu items function.
/ / Mc -> movie clip x, y -> coordinate w, h -> width and height. Text -> string.
function CreateItem (mc, x, y, w, h, text) (
mc.createTextField ("text", 2, x +10, y, 85, 20);
/ / Create an empty dynamic text paragraph
mc.text.text = text;
/ / Dynamic text segment for the new assignment, color,
mc.text.textColor = 0x000000
/ / Text size with or without borders, can choose.
mc.text.size = 14;
mc.text.border = false;
mc.text.selectable = false;
)
/ / Start building the menu functions.
function CreateMenu (mc) (
/ / Create a movie clip, and a color block of the above. Name bg -> BackGround.
mc.createEmptyMovieClip ("bg", 1);
/ / Create an empty MC
mc.bg.beginFill (0x33ccff, 100);
/ / Start filling
mc.bg.DrawRect (0, 0, 90, 20);
/ / Call the function
mc.bg.endFill ();
/ / End fill
mc.bg._alpha = 50;
/ / Transparency
mc.bg._visible = false;
/ / Visibility
/ / End of the painting.
/ / Start the following cycle.
for (i = 0; i
mc.createEmptyMovieClip ("item" + i, 2 + i);
theItem = mc ["item" + i];
theItem.index = i;
CreateItem (theItem, i * 90, 0, 90, 20, menuText [i]);
/ / Frame start of the action.
theItem.onEnterFrame = function () (
/ / If statement to determine the default condition is "true"
/ / Time when the running == true.
if (running) (
if (mc.bg._x <= step * 90) (
mc.bg._x + = 5;
) Else if (mc.bg._x> = step * 90 +10) (
mc.bg._x -= 5;
)
)
);
/ / Passing motion.
theItem.onRollOver = function () (
mc.bg._visible = true;
running = true;
step = this.index;
);
/ / Left movement.
theItem.onRollOut = function () (
mc.bg._visible = false;
running = false;
);
/ / Action when clicked.
theItem.onPress = function () (
getURL (menuURL [this.index]);
);
)
/ / Loop end.
)
createEmptyMovieClip ("menu", 10);
/ / Create "menu" movie clip.
menu._y = 0;
/ / Coordinate values.
menu._x = 0;
CreateMenu (menu);
/ / Create the menu.
/ / Put this program on the scene of the first frame, and then run.
/ / I spent a morning writing. Also Minato and.






Recommended links:



Vob file converter



Lohan DVD to MOV



Computer Education Infomation



Video Formats



.mkv files



Merry CD APE MP3 ID3 Tag to VQF Copy



Nevo DVD RIPPER Platinum



flv mp4



DVD Clone - DVD XCopy Deluxe



Simple Trace And Ping Tools



FutureDecks Pro



B2C mall to promote the six-pulse Sword



Apolo IPOD Backup



No comments:

Post a Comment