关闭顶部展开顶部

Flash:80行AS代码打造奇幻光影_Flash教程

编辑Tag赚U币
教程Tag:暂无Tag,欢迎添加,赚取U币!

推荐:用Flash的beginBitmapFill平铺背景
之前写过在flashmx2004中平铺背景的方法,虽然它也是有效果的,但相对使用flash8时还是显得有些复杂.这次介绍的是flash8中的MovieClip的新方法MovieClip.beginBit

/////////////////////////////////////////////
///// author: chenlangeer //////
///// msn: [email=chenlangeer@hotmail.com]chenlangeer@hotmail.com[/email] //////
///// blog: cgs.flash8.net //////
/////////////////////////////////////////////
import flash.display.BitmapData;
import flash.filters.*;
import flash.geom.*;
_quality = "LOW";
_root.createTextField("logo", 10, 10, 10, 220, 18);
logo.html = true;
logo.htmlText = "<FONT FACE=’Arial’ SIZE=’14’ COLOR=’#FF9900’><A HREF=’http://cgs.flash8.net’ TARGET=’_blank’>Core Graph Studio</A> </FONT><FONT FACE=’Arial’ SIZE=’12’ COLOR=’#999999’>click to redraw</FONT>";
_root.createTextField("para", 9, Stage.width-150, Stage.height-30, 150, 18);
para.html = true;
var bmp:BitmapData = new BitmapData(Stage.width, Stage.height, false, 0x0);
_root.attachBitmap(bmp, 0);
_root.createEmptyMovieClip("world", 2);
world.createEmptyMovieClip("_mc", 0);
world._mc._x = Stage.width/2;
world._mc._y = Stage.height/2;
var rad_speed:Number = 2;
var blurFilter:BlurFilter = new BlurFilter(2, 2, 1);
var f:Number = -.01;
var colorFilter:ColorMatrixFilter = new ColorMatrixFilter([.9, -.1, 0, 0, f, 0, .8, -.2, 0, f, .1, 0, .9, 0, f, 1, 0, 0, 1, 0]);
var total_nums:Number = 10;
onMouseDown = function () {
for (var i in world._mc) {
world._mc[i].removeMovieClip();
}
var a = Math.random()*.2;
t = (Math.random()-.5)*a;
z = (Math.random()-.5)*a;
para.htmlText = "<FONT SIZE=’12’ COLOR=’#999999’>z=" Math.round(z*10000)/10000 " t=" Math.round(t*10000)/10000 "</FONT>";
rad_speed = (Math.random()-.5)*3.8;
line_bool = random(5);
swirl_bool = random(3);
rnd_xy_bool = random(4);
var i = 0;
for (k=0; k<total_nums; k ) {
for (m=0; m<360; m = 5) {
var line:MovieClip = world._mc.createEmptyMovieClip("line" i, i);
if (rnd_xy_bool) {
line.ox = line.__x=line._x=k*Math.sin(m/180*Math.PI)*8 Math.random()*20;
line.oy = line.__y=line._y=k*Math.cos(m/180*Math.PI)*6 Math.random()*20;
} else {
line.ox = line.__x=line._x=k*Math.sin(m/180*Math.PI)*8;
line.oy = line.__y=line._y=k*Math.cos(m/180*Math.PI)*6;
}
line.lx = line._x*.3;
line.ly = line._y*.3;
if (random(3)) {
(new Color(line)).setTransform({rb:i*512/k/m-256, gb:i*255/k/m, bb:random(512)-256});
} else {
(new Color(line)).setTransform({rb:255, gb:255, bb:255});
}
line.onEnterFrame = function() {
if (swirl_bool) {
var x = this.__x;
this.__x = 10*Math.cos(this.__y*z)*Math.sin(this.__y*t);
this.__y = 10*Math.sin(x*z)*Math.cos(x*t);
} else {
this.__x = 10*Math.cos(this.__y*z)*Math.sin(this.__y*t);
this.__y = 10*Math.sin(this.__x*z)*Math.cos(this.__x*t);
}
this.clear();
this.lineStyle(1, 0x66EE66);
if (line_bool>1) {
this.moveTo(this.ox-this._x, this.oy-this._y);
this.lineTo(this.__x-this._x, this.__y-this._y);
} else if (line_bool == 1) {
this.moveTo(this.ox, this.oy);
this.lineTo(this.__x this.lx, this.__y this.ly);
} else {
this.moveTo(this.ox-this.lx, this.oy-this.ly);
this.lineTo(this.__x-this.lx, this.__y-this.ly);
}
this.ox = this.__x;
this.oy = this.__y;
};
i ;
}
}
clearInterval(val);
val = setInterval(onMouseDown, 20000);
};
onEnterFrame = function () {
world._mc._rotation = rad_speed;
bmp.draw(world);
bmp.applyFilter(bmp, bmp.rectangle, new Point(0, 0), blurFilter);
bmp.applyFilter(bmp, bmp.rectangle, new Point(0, 0), colorFilter);
};
world._visible = false;
world._y = 100000;
onMouseDown();

分享:Flash AS曲线的绘制
曲线的绘制原理有两种:一种是由无数多或有限多的,即:lineTo绘制的曲线。另一种是由函数计算并由曲线函数curveTo计算而成的。重点之重是讲第二点,最

/所属分类:Flash教程/更新时间:2008-03-05
loading.. 评论加载中....
相关Flash教程
闂佹眹鍩勯崹閬嶆偤閺囶澁缍栭柛鈩冪⊕閳锋帗銇勯弴妤€浜惧銈忕秶閹凤拷
濠电偛顕慨顓㈠磻閹炬枼妲堥柡鍌濇硶婢ф稒淇婇懠顒夆偓婵嬫煟閵忊晛鐏查柟鍑ゆ嫹
濠电姷顣介埀顒€鍟块埀顒勵棑缁辩偛顓兼径瀣閻庣懓瀚竟鍡欐崲娑斾線鏌i姀鈺佺伈闁瑰嚖鎷�
濠电姷顣介埀顒€鍟块埀顒勵棑缁辩偛顓兼径濠勵吋闂佽鍨庨崟顓фК闂佽閰eḿ褍螞濞戙垺鍋夐柨鐕傛嫹
闂備胶枪缁绘劙骞婃惔銊ョ劦妞ゆ帒鍊哥敮鍫曞箹鐎涙ḿ鐭掔€规洘绻堥弫鎾绘晸閿燂拷
闂備胶枪缁绘劙骞婃惔銊ョ劦妞ゆ巻鍋撻柛姘儑缁﹪鏁傞崜褏鐓撻柣搴岛閺呮繈鎯屽▎鎴犵=濞撴艾锕ョ€氾拷
闂備浇銆€閸嬫挻銇勯弽銊р槈闁伙富鍣i弻娑樷攽閹邦亞鑳虹紓浣靛妽濡炶棄顕i妸鈺婃晬婵炲棙鍨电粭锟犳⒑閸濆嫬鈧骞婇幘鑸殿潟闁跨噦鎷�
闂備礁鎼崯鐗堟叏妞嬪海绀婂鑸靛姈閻擄綁鎮规潪鎷岊劅婵炲眰鍊曢湁闁挎繂妫欑粈鈧梺鍛娚戦悧鐘茬暦閹扮増鏅搁柨鐕傛嫹
婵犵妲呴崹顏堝礈濠靛棭鐔嗘俊顖氬悑鐎氱粯銇勯幘瀵哥畺閻庢熬鎷�
濠电姷顣介埀顒€鍟块埀顒勵棑缁辩偛顓奸崶銊ヮ伕濡炪倖鎸荤换鍐偓姘虫珪娣囧﹪顢涘Δ鈧晶鍙夌節椤喗瀚�
婵犵妲呴崹顏堝礈濠靛棭鐔嗘慨妞诲亾鐎规洦鍓熼、娆撳礂閻撳簶鍋撻悽鍛婄厸闁割偅绻勫瓭婵犳鍣幏锟�
婵犵妲呴崹顏堝礈濠靛棭鐔嗘慨妞诲亾闁哄苯鎳橀崺鈧い鎺嗗亾闁宠閰i獮鎴﹀箛闂堟稒顔嗛梻浣告惈鐎氭悂骞忛敓锟�
婵犵妲呴崹顏堝礈濠靛棭鐔嗘慨妞诲亾鐎规洩缍侀獮瀣攽閸偂绱�
濠电姷顣介埀顒€鍟块埀顒勵棑缁辩偛顓兼径濠勭厬闂佺懓鐡ㄧ换鍕敂鐎涙ü绻嗘い鏍殔婢у弶绻濋~顔藉
闂佽楠搁崢婊堝礈濠靛鍋嬮柟鎯版閻鈹戦悩鎻掓殭闁奸潧缍婇弻銈夋嚍閵夈儱顫嶉梺缁樼壄缂嶄礁鐣峰▎鎾存櫢闁跨噦鎷�
UB闂備礁婀辩划顖炲礉濡ゅ懐宓侀柛銉㈡櫆鐎氭岸鎮楀☉娅虫垿锝為敓锟�
闂備浇澹堟ご绋款潖婵犳碍鐒鹃悗鐢电《閸嬫捇鐛崹顔句痪濠电姭鍋撻柨鐕傛嫹
闂佽楠哥粻宥夊垂閸濆嫸鑰块柛銏㈠殰
闂備礁鎲″缁樻叏妞嬪海绀婂璺虹灱閸楁碍绻涢崱妤€顒㈤柛鐐差槹缁绘稓绱欓悩鍝勫帯闂佺ǹ楠忛幏锟�
缂傚倸鍊烽悞锕傛偡閿曞倸鍨傛繝濠傚椤╅攱銇勯幒宥囶槮缂佹彃婀遍埀顒傚仯閸婃繄绱撳棰濇晩闁跨噦鎷�
©2017 www.mb5u.com婵犵妲呴崹顏堝礈濠靛棭鐔嗘慨妞诲亾鐎殿噮鍣i幃鈺呭箵閹烘挸鐦�
闂備浇銆€閸嬫捇鏌熼婊冾暭妞ゃ儻鎷�&闂備礁鎲$敮鎺懳涢弮鍫燁棅闁跨噦鎷�