Main

http://www.ontological.com/mission.html



Dream Decoder

Dream Decoder

package { import flash.display.Sprite; import flash.events.Event; import flash.text.TextField; import flash.text.TextFormat; import flash.text.TextFieldType; import flash.text.TextFormatAlign; import flash.events.MouseEvent; import flash.net.FileReference; import flash.utils.Dictionary; public class DreamDecoder extends Sprite { private var wordMap:Dictionary = new Dictionary(); private var stopWords:Array = [ “he”, “she”, “it”, “they”, “him”, “her”, “his”, “hers”, “its”, “them”, “theirs”, “i”, “you”, “we”, “us”, “mine”, “our”, “ours”, “your”, “yours”, “and”, “but”, “so”, “to”, “is”, “are”, “was”, “were”, “be”, “been”, “being”, “have”, “has”, “had”, “having”, “take”, “make”, “get”, “come”, “go”, “do”, “does”, “did”, “doing”, “can”, “could”, “will”, “would”, “should”, “might”, “must”, “shall”, “ought”, “to”, “from”, “with”, “by”, “as”, “that”, “which”, “who”, “what”, “this”, “these”, “those”, “there”, “of”, “in”, “on”, “at”, “for”, “with”, “about”, “into”, “up”, “down”, “off”, “under”, “over”, “again”, “more”, “then”, “now”, “no”, “a”, “an”, “the”, “next”, “big”, “small”, “large”, “round”, “flat”, “long”, “short”, “tall”, “wide”, “narrow”, “heavy”, “light”, “thick”, “thin”, “thin”, “bright”, “dark”, “flat”, “clear”, “smooth”, “rough”, “hard”, “soft” ]; private var dreamElements:Array = []; private var inputText:TextField; private var resultText:TextField; private var button:TextField; private var questionArea:TextField; private var decodeButton:TextField; public function DreamDecoder() { setupUI(); } private function setupUI():void { var format:TextFormat = new TextFormat(); format.size = 18; format.font = “Arial”; // Input Text Field inputText = new TextField(); inputText.defaultTextFormat = format; inputText.width = 400; inputText.height = 80; inputText.type = TextFieldType.INPUT; inputText.border = true; inputText.wordWrap = true; inputText.x = 50; inputText.y = 20; inputText.text = “Describe your dream…”; addChild(inputText); // Decode Button decodeButton = new TextField(); decodeButton.defaultTextFormat = format; decodeButton.text = “Decode Dream”; decodeButton.selectable = false; decodeButton.x = 50; decodeButton.y = 110; decodeButton.setTextFormat(format); decodeButton.addEventListener(MouseEvent.CLICK, onDecodeClick); addChild(decodeButton); // Result Output resultText = new TextField(); resultText.defaultTextFormat = format; resultText.width = 400; resultText.height = 150; resultText.border = true; resultText.wordWrap = true; resultText.x = 50; resultText.y = 250; addChild(resultText); // Question Area questionArea = new TextField(); questionArea.defaultTextFormat = format; questionArea.width = 400; questionArea.height = 150; questionArea.border = true; questionArea.wordWrap = true; questionArea.x = 50; questionArea.y = 180; addChild(questionArea); } private function onDecodeClick(event:MouseEvent):void { var dreamText:String = inputText.text.trim(); if (!dreamText) { resultText.text = “Please describe your dream first!”; return; } // Extract core words and remove stop words var words:Array = dreamText.split(/\s+/); dreamElements = []; for each (var word:String in words) { var cleanedWord:String = word.toLowerCase().replace(/[.,;:]/g, “”); if (stopWords.indexOf(cleanedWord) == -1 && dreamElements.indexOf(cleanedWord) == -1) { dreamElements.push(cleanedWord); } } if (dreamElements.length === 0) { resultText.text = “No core words identified. Try adding more descriptive words.”; return; } // Show questions to interpret words questionArea.text = “Personal Interpretations:\n”; for (var i:int = 0; i < dreamElements.length; i++) { questionArea.appendText("What personal meaning does the word '" + dreamElements[i] + "' have for you?\n"); } // Decode Button after questions are provided var decodedText:String = decodeDream(); resultText.text = decodedText; } private function decodeDream():String { var decodedText:String = ""; for (var i:int = 0; i < dreamElements.length; i++) { // If no interpretation provided, keep word intact decodedText += dreamElements[i] + " "; } return decodedText; } } }