In honor of Samuel Morse’s birthday, thought I’d throw out this quick little “tool”.
Now, back to work…
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
package com.onebyonedesign.extras { import flash.utils.Dictionary; /** * Converts strings of letters and numbers to Morse code. * @author Devon O. Wolfgang */ public class Morse { private var _morseDict:Dictionary = new Dictionary(); public function Morse() { initDictionary(); } private function initDictionary():void { _morseDict["a"] = ".-"; _morseDict["b"] = "-..."; _morseDict["c"] = "-.-."; _morseDict["d"] = "-.."; _morseDict["e"] = "."; _morseDict["f"] = "..-."; _morseDict["g"] = "--."; _morseDict["h"] = "...."; _morseDict["i"] = ".."; _morseDict["j"] = ".---"; _morseDict["k"] = "-.-"; _morseDict["l"] = ".-.."; _morseDict["m"] = "--"; _morseDict["n"] = "-."; _morseDict["o"] = "---"; _morseDict["p"] = ".--."; _morseDict["q"] = "--.-"; _morseDict["r"] = ".-."; _morseDict["s"] = "..."; _morseDict["t"] = "-"; _morseDict["u"] = "..-"; _morseDict["v"] = "...-"; _morseDict["w"] = ".--"; _morseDict["x"] = "-..-"; _morseDict["y"] = "-.--"; _morseDict["z"] = "--.."; _morseDict[" "] = " "; _morseDict["1"] = ".----"; _morseDict["2"] = "..---"; _morseDict["3"] = "...--"; _morseDict["4"] = "....-"; _morseDict["5"] = "....."; _morseDict["6"] = "-...."; _morseDict["7"] = "--..."; _morseDict["8"] = "---.."; _morseDict["9"] = "----."; _morseDict["0"] = "-----"; } public function convert(msg:String):String { msg = msg.toLowerCase(); var msgArray:Array = msg.split(""); var len:int = msgArray.length; var output:String = ""; for (var i:int = 0; i < len; i++) { var char:* = _morseDict[String(msgArray[i])]; if (char != undefined) output += char + " "; } return output; } } } |
.. .-..—…-. -.—–..- -……—–.
…. . -.– – …. .. … .. … .- .– . … — — .
cools stuff…I was wondering what was going on with Google’s logo today…makes sense now :)
Now attach some sound to the message so that we can also hear what it would sound like!
haha funny app
( …. .- …. .- ..-. ..- -. -. -.– .- .–. .–.)