deno: http://7540.ggii.net/swf/FlyWord.html
下面是源码: 注意 tft 是文本框TextField实例
//bezier的用法 以及函数参数的传递
/*
爱心参数:
TweenMax.to(mc, 3.75, {bezier:[{x:236, y:282}, {x:97, y:93}, {x:50, y:272}, {x:183, y:393}, {x:222, y:387}, {x:332, y:218}, {x:238, y:89}, {x:191, y:237}], orientToBezier:true, scaleX:1, scaleY:1, alpha:1, tint:0x000033, ease:Default (Regular.easeOut)});/
*/
import com.greensock.TweenMax;
txtInfo.text=" の夜の夢首先祝大家元旦节快乐,祝大家在新的一年里,身体健康,万事如意!呵呵!祝光棍群体们早日找到自己的另一半,包括我,哈哈!在新的一年为票子和美女向前冲啊!兄弟朋友们,你们准备好了吗?勒紧你们的裤腰带,向前冲啊!远方的美眉在等着你们!没有2000块钱是不能包夜的哦!哈哈!最后祝大家元旦吃好,喝好,玩好!最后祝大家财运亨通!";
var btnReFly:TextField;
var str:String=txtInfo.text;
var storeStr:String=str;
var countTotal:uint=str.length;
var tft:TextFormat = new TextFormat();
var f :TextFormat= new TextFormat();
f.font="华文行楷";
f.size=20;
tft.size=15;
tft.font="华文行楷";
tft.color=0xff0000;
f.color=0x00ff33;
txtInfo.defaultTextFormat=f;
init();
var t:Timer;
function init() {
t=new Timer(300,countTotal);
t.addEventListener("timer", textFly);
t.addEventListener("timerComplete",reFly);
t.start();
}
function textFly(_evt:TimerEvent=null) {
try {
new LocalConnection().connect('foo');
new LocalConnection().connect('foo');
} catch (e:*) {
//trace (_evt.target.currentCount);
var e_str:TextField=new TextField();
tft.size=Math.random()*20+12;
// tft-----------------------------------
e_str.defaultTextFormat=tft;
e_str.text=str.charAt(0);
e_str.selectable=false;
e_str.scaleX=e_str.width/(e_str.width+1);
e_str.scaleY=e_str.height/(e_str.height+1);
e_str.z=0;
str=str.substr(1);
txtInfo.text=str;
addChild(e_str);
TweenMax.to(e_str, 15, {x:700, y:247, bezier:[{x:236, y:282}, {x:97, y:93}, {x:50, y:272}, {x:183, y:393}, {x:222, y:387}, {x:332, y:218}, {x:238, y:89}, {x:191, y:237}], orientToBezier:true,onComplete:clearText,onCompleteParams:[e_str]}); ;//onCompleteParams:[e_str,true] 指的是函数的参数
trace(System.totalMemory);
}
}
function reFly(_evt:TimerEvent) {
t.stop();
t.removeEventListener("timer", textFly);
t.removeEventListener("timerComplete",reFly);
txtInfo.text=storeStr;
str=txtInfo.text;
btnReFly=new TextField();
btnReFly.text="重新开始";
btnReFly.background=true;
btnReFly.backgroundColor=0x00FFFF;
btnReFly.width=55;
btnReFly.height=20;
btnReFly.x=400;
btnReFly.y=300;
btnReFly.selectable=false;
btnReFly.addEventListener(MouseEvent.CLICK,btnReFlyClk);
addChild(btnReFly);
}
function btnReFlyClk(_evt:MouseEvent) {
btnReFly.removeEventListener(MouseEvent.CLICK,btnReFlyClk);
clearText(_evt.target);
init();
}
function clearText(_mc:*) {
removeChild(_mc);
_mc=null;
}
//=======================下面是添加音乐的代码 和右键菜单的代码
// 右键菜单
buildCopyRight()
function buildCopyRight(){
var myContextMenu= new ContextMenu();
var item0:ContextMenuItem= new ContextMenuItem("作者:夜梦惊魂~dreamnight");
var item1:ContextMenuItem= new ContextMenuItem("进入我的博客");
var item2:ContextMenuItem= new ContextMenuItem("qq:1010013548");
//隐藏自带菜单
myContextMenu.hideBuiltInItems();
myContextMenu.customItems.push(item0);
myContextMenu.customItems.push(item1);
myContextMenu.customItems.push(item2);
item1.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,onSelected,false,1,true)
this.contextMenu=myContextMenu;
}
function onSelected(e:ContextMenuEvent=null):void{
navigateToURL(new URLRequest("http://blog.csdn.net/hu36978"),"_blank");
}
//音乐:
// import flash.media.*;
// import flash.display.Sprite;
// import flash.events.ProgressEvent;
// import flash.events.Event;
// import flash.net.URLRequest;
/*
@author :夜梦惊魂
@email : hujun36978@yahoo.cn
@Blog :http://blog.csdn.net/hu36978
*/
var _sound:Sound;
var array:Array;
var num:uint;
var begain:Boolean;
var channel:SoundChannel;
var len:Number;
var isComplete:Boolean;
Music()
function Music() {
ok();
//addEventListener(Event.ENTER_FRAME,onFrame);
}
function ok() {
num=0;
channel= new SoundChannel();
array= new Array();
array.push("http://www.jjl100.com/QQonline/images/ok.mp3?stdfrom=mp3");
array.push("http://z2.przeklej.pl/prza2090/d4e0b003002b01524ac128d0/super_junior_m_.mp3");
array.push("http://www.redbullmusic.cn//uploadfiles/audios/34d4825f5e6644969b5e9cde9c19f22a.mp3");
array.push("http://blog.funshare.com.cn/gallery/539883/539883-1730.mp3?stdfrom=3/http://pichd.gxnews.com.cn/uploadfiles/mp3/2007/7/26/2007726222129090.mp3");
begain=true;
loadMusic();
addEventListener(Event.ENTER_FRAME,handleEnterFrame);
}
function loadMusic() {
isComplete= false;
_sound = new Sound();
_sound.addEventListener(ProgressEvent.PROGRESS,onProgress);
_sound.addEventListener(Event.COMPLETE,onComplete);
_sound.load(new URLRequest(array[num]));
/*private function onFrame (e:Event):void{
if(){}*/
}
function onProgress(e:ProgressEvent=null):void {
var percent:int=int(e.bytesLoaded*100/e.bytesTotal);
trace(percent+"%");
// len=_sound.length/(e.bytesLoaded*100/e.bytesTotal);//此处不能取约数
// trace("len的长度为:"+len);// NAN
trace(_sound.length);
if (percent>5) {
if (begain) {
channel=_sound.play();
trace("位置为:"+channel.position);
begain=false;
}
}
}
function onComplete(e:Event):void {
isComplete=true;
num++;
begain=true;
len=e.currentTarget.length;
trace("len的长度为:"+len);
//trace(num);
//trace(array.length);
_sound.removeEventListener(ProgressEvent.PROGRESS,onProgress);
_sound.removeEventListener(Event.COMPLETE,onComplete);
_sound=null;
if (num>=array.length) {
//trace(num);
//trace(array.length);
removeEventListener(Event.ENTER_FRAME,handleEnterFrame);
}
}
function handleEnterFrame(e:Event):void {
trace("此处的位置为"+channel.position);
//trace(len)
if(isComplete){
if (num<array.length) {
if (channel.position+40>=len) //channel.position 和len 不相等 故只需大致相等即可
{
loadMusic();
trace("调用成功");
}
}
}}