Skip to main content

Posts

超簡單版MobileSharedObject class

其實這個分享是比較有點懶人系列(Erin最愛)的意味, 只是將Mobile SharedObject建立步驟用class包裝起來, 請注意!這邊不是在講PC版的SharedObject用法喔! ◎MobileSharedObject(soName:String) + onLoad(init:Boolean) + write (attribute:String, value:Object) + read (attribute:String):Object + readAll():Object + clear() 用法很簡單: var mySo = new MobileSharedObject(); mySo.onLoad = function(init) { if (init) { trace("First time to see you"); this.write("author", "Erin"); this.write("date", "04/02/2007"); } else { trace("Hello "+this.read("author")+", nice to see you again"); var obj = this.readAll(); for (var i in obj) { trace(i+"="+obj[i]); } } }; 有興趣可以按此下載

Adobe User Group 12月份網聚

點我報名!

地圖元件左右循環移動

由於龍龍仔在上上篇題問了一個關於地圖左右移動的寫法, 又剛好Erin荒廢兩個多月沒有更新, 所以就把這個簡單的移動原理在這邊公開: 說明: 1. 製作一段由A到B , B到C, C到A的連續動畫 MovieClip 2. 在這段連續動畫,僅在各自的key frame上加入action stop(); _num=n;// 這個變數只是在告訴外面,動畫停在哪個東西上...=P 3. 當使用者按下左右鍵的時候,便執行onEnterFrame來告訴連續動畫往前跑或往後跑...=P (其實這跟倒帶的原理是一樣的) move_mc.onEnterFrame = function() { if (this._num != num) { //當指定的位置跟停止的keyFrame不同 if (isR) { // 如果是按右鍵 if (this._currentframe == this._totalframes) { this.gotoAndStop(1); } else { this.nextFrame(); } } else { //如果是按左鍵,,,=P if (this._currentframe == 1) { this.gotoAndStop(this._totalframes); } else { this.prevFrame(); } } } else { trace("number is "+this._num); delete this.onEnterFrame; } } 有興趣可以下載 原始檔

FL2.0 Key Listener Control

當FL2.0不接受按鈕用on (keyPress "PageDown") and on (keyPress "PageUp")來控制RSK (右soft key) and LSK (左soft key)時,大家非不得已要開始使用Key listener來做按鈕控制。Key Listener其實很好用,但是前提是你不可以將它搞亂,不然會出現有趣的bug喔! 以下是一個簡單範例包含list menu外加 RSK 點選後會pop-up 一個詢問離開的視窗: 重點整理: 1. RSK and LSK key listener最好與其它操作的listener分開。 - 因為這個範例只有一層所以會看不出哪邊方便,但是如果你的程式是需要包含很多key event操作,每個listener都要寫入RSK的動作就太沒效率了。 2. removeListener的動作最好寫在listener object身上。 - 好處就是...你不用煩惱哪邊忘了remove掉而出現白癡的bug.... var _listener=new Object(); _listener.onKeyDown = function() { var code = Key.getCode(); if (code ==13) { Key.removeListener(this); } } 3.當詢問離開視窗pop-up後,整個程式的key event的控制會進入所謂的pause階段,所有跟現階段操作有關的key listeners都應該先被移除掉。 - Key._listeners, 會回傳所有被註冊在Key裡的listeners, 回傳型態Array - 利用一個新的Array 拷貝 Key._listeners _cacheListeners = new Array(); _cacheListeners = _cacheListeners.concat(Key._listeners); for (var i in _cacheListeners) { Key.removeListener(_cacheListeners[i]); } - 當然要記得在離開pop-up 視窗後將所有該用的listeners註冊回去 for (var i in _cacheListeners) ...

Nice to meet you.... lite version

Flash lite 2.0 176 x 208 S60 這個作品大概是Erin在2000年所做,當初以Flash5版本寫出 並於Erin惡搞的個人網站 GreenTown 發表, 前陣子小無聊就花了"一點"心力將它改成FL2.0版本, 第一版先處理成效能型,所以沒有華麗動畫, 只有完美結局由朋友Erica跨刀畫了一張圖來當隱藏結局, 沒有玩過或者是想重溫Erin這個亂搞的泡美眉作品的 請按此下載中文版version 1.02 EDIT: 修改了一些小bug BTW...難度當然比以前還高...因為幾乎需要驅動所有事件才泡的到...XD English version will be released soon.... EDIT.05202007:英文版放棄了...= = 口語要翻譯簡直會要了我的命,怎樣翻都不好笑乾脆放棄囉

Smooth movement --- JUMP ACTION

這個教學是上一篇 Smooth movement in FL1.1的加強版,並加入了跳躍動作。在FL1.1中是沒有所謂的hitTest(),所以這邊利用了一個方法來達到簡易的碰撞測試,讓火柴人可以跳到移動平台上: 取得跳躍平台的方塊四頂點的座標,與跳躍 MC作座標檢測 call hitTest: (mc = main control movieclip's name) W =hitTestTarget._width/2; xMin = hitTestTarget._x-W; xMax = hitTestTarget._x+W; H =hitTestTarget._height/2; yMin =hitTestTarget._y-H; yMax = hitTestTarget._y+H; if (mc._x>xMin && mc._x if (mc._y>yMin && mc._y hitTarget =hitTestTarget; trace(hitTarget add " be hit"); mc._y = yMin; } } Key controler : on (keyPress "") { hitTarget = ""; if (!jump_co.jump) { trace("跳躍開始"); jump_co.ymov = -21; jump_co.jump = true; jump_co.status = "jump"; tellTarget ("mc") { gotoAndStop("jump"); } } } Jump controler 跳躍控制器(jump_co): if (jump) { ymov += 3; if (status eq "stand") { //在hitTest中,如果確定碰撞到平台,status會設定為stand jump = false; tellTarget (__target) { gotoAndStop("stand"); } } else { //drop eval(__target)._y...

Smooth movement in FL1.1

曾經玩過某家公司針對FL1.1所推出的動作冒險遊戲,但是對那個死板的左右鍵移動與Jump動作頗有微詞。 手機的反應不如電腦那樣即時,所以在動作順暢度調整上,需要作一點點的手腳。 也許接下來所提供的方法並不是最好的,但是希望可以給有心學習FL1.1的網友們一點啟發 =) hint: 使用時間來控制移動判定 原理:當使用者點選nevi-key(四方鍵)時,只宣告狀態與點選時間(getTimer()),利用一個不停迴圈的MovieClip來控制整個移動系統 key cacher action: on (keyPress "") { keyPressTime = getTimer(); move_co.left = true; } movement controler( a movieClip has two frames) action: if (left) { right = false; tellTarget (__target) { _x -= 3; gotoAndStop("left"); } num = getTimer()-/:keyPressTime; if (num>300) { left = false; tellTarget (__target) { gotoAndStop("stand"); } } } [下載原始檔] 本教學僅針對FL1.1語法版本,FL2.0不需要使用這種方法撰寫...=)