再看看豎的效果
wd=15a14a15a17a16a19a16a22a16a25a16a28a17a30a17a33a17a36a17a39a17a42a19a45a
18a48a18a51a19a53a20a55a20a57繼續(xù)套用(x,y) ->(15,14);(15,17);(16,19);(16,22)...
發(fā)現(xiàn)這個(gè)規(guī)律大致也成立,之余那個(gè)16和15的差別,大家可以看看我的線條,不是筆直的,所以可以將它們近似認(rèn)為是直線吧,我們只是根據(jù)特殊情況來找規(guī)律,間隔也近似看作3
從上面兩種情況我們可以理解為wd就是我們操作后的坐標(biāo)數(shù)據(jù),每個(gè)數(shù)據(jù)都是用a來隔開,為什么用a?我想是除了數(shù)值一外,a是比較通用的符號(hào),畢竟在字母序列表里排第一 間隔為3,又是為什么?因?yàn)榇蠹叶贾纼牲c(diǎn)構(gòu)成一線,如果再多一個(gè)點(diǎn),就可以判斷出這3個(gè)點(diǎn)構(gòu)成的線的走勢(shì)是直線還是折線,也就是我們所理解的筆畫了,這個(gè)是極限情況下特殊情況,你也可以理解在flash操作里,mouseDown mouseMove mouseUp
這3個(gè)情況下的,所輸出的極限數(shù)據(jù),即最少的數(shù)據(jù)。
數(shù)據(jù)分析完畢了,剩下的工作就是我們?cè)趂lash中去構(gòu)建我們的邏輯,去實(shí)現(xiàn)了 因?yàn)闀r(shí)間比較晚了。。寫教程真的耗時(shí)間
所以我就先放源文件和效果,因?yàn)榇a比較簡(jiǎn)單,也沒有去優(yōu)化了
代碼是為了湊成合格的數(shù)據(jù)而弄的,所以有點(diǎn)點(diǎn)亂,因?yàn)闀r(shí)間關(guān)系。。沒有去細(xì)化,有問題明天再繼續(xù)
代碼:
var pointTotalArr :Array = []; var pointArr :Array; var sp :Sprite = new Sprite(); var lineSp:Sprite; addChild(sp); function onLoaded(event:Event):void { var str:String = event.target.data; var tempStr:String = str.slice(6,str.length-8); var arr:Array = tempStr.split("\\u"); txt.text =""; for (var i:uint = 1; i<arr.length; i++) { //trace(String.fromCharCode(Number("0x"+arr[i]))); txt.appendText(String.fromCharCode(Number("0x"+arr[i]))+" ") } } writeHotArea.addEventListener(MouseEvent.MOUSE_DOWN,onStageMouseDown); function onStageMouseDown(event:MouseEvent):void { lineSp = new Sprite(); lineSp.graphics.clear(); lineSp.graphics.lineStyle(2); lineSp.graphics.moveTo(mouseX,mouseY); writeHotArea.addEventListener(MouseEvent.MOUSE_MOVE,onStageMouseMove); pointArr = []; pointArr.push(new Point(mouseX,mouseY)); pointTotalArr.push(pointArr); sp.addChild(lineSp); stage.addEventListener(MouseEvent.MOUSE_UP,onStageMouseUP); } function onStageMouseUP(event:MouseEvent):void { writeHotArea.removeEventListener(MouseEvent.MOUSE_MOVE,onStageMouseMove); stage.removeEventListener(MouseEvent.MOUSE_UP,onStageMouseUP); var sendStr:String = ""; for (var j:uint = 0; j<pointTotalArr.length; j++) { if (j!=0) { sendStr+="a"; } for (var i:uint = 0; i<pointTotalArr[j].length; i+=3) { sendStr+=pointTotalArr[j][i].x +"a"+pointTotalArr[j][i].y; if(i<(pointTotalArr[j].length-3))sendStr+="a" } } var urlLoader:URLLoader = new URLLoader(); urlLoader.dataFormat = URLLoaderDataFormat.TEXT; var request:URLRequest = new URLRequest(" request.method = "post"; var urlLV :URLVariables = new URLVariables(); urlLV.wd = sendStr; urlLV.type = 1; request.data = urlLV; urlLoader.load(request); urlLoader.addEventListener(Event.COMPLETE,onLoaded); } function onStageMouseMove(event:MouseEvent):void { lineSp.graphics.lineTo(mouseX,mouseY); pointArr.push(new Point(mouseX,mouseY)); event.updateAfterEvent(); } reWriteBtn.addEventListener(MouseEvent.CLICK,onClick); function onClick(event:MouseEvent):void{ pointTotalArr = []; txt.text =""; while(sp.numChildren>0) sp.removeChildAt(0); }
經(jīng)典論壇交流:http://bbs.blueidea.com/thread-2980733-1-1.html
本文鏈接:http://m.95time.cn/tech/multimedia/2010/7850.asp
出處:藍(lán)色理想
責(zé)任編輯:bluehearts
上一頁 flash手寫輸入 [2] 下一頁
◎進(jìn)入論壇RIA設(shè)計(jì)與應(yīng)用版塊參加討論
|