DAN ZEN EXPO - CODE EXHIBIT -
DRONER!
package {
import com.danzen.frameworks.Easy;
import com.danzen.interfaces.TwoFace;
import com.danzen.utilities.Robin;
import com.danzen.utilities.Falcon;
import flash.desktop.NativeApplication;
import flash.desktop.SystemIdleMode;
import flash.display.MovieClip;
import flash.display.StageAlign;
import flash.display.StageAspectRatio;
import flash.display.StageScaleMode;
import flash.events.DataEvent;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.events.TransformGestureEvent;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.net.URLRequest;
import flash.text.TextField;
import flash.ui.Keyboard;
import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;
import flash.utils.Timer;
public class Droner extends MovieClip {
private var myRobin:Robin;
private var twoFace:TwoFace;
private var sW:Number;
private var sH:Number;
private var m1:MovieClip;
private var m2:MovieClip;
private var assets:Assets;
private var logoSpacing:Number = 20;
private var slideTime:Number = .4;
private var butTimer:Timer;
private var intro:MovieClip;
private var packs:MovieClip;
private var packsCheck:Boolean = false;
private var packCheck:Boolean = false;
private var pack:MovieClip;
private var logoTimer:Timer;
private var busyCheck:Boolean = false;
private var paidPacks:Array = [0]; //[0,1,2,3,4,5,6,7,8,9,10,11];
private var sayLookup:Object = {};
private var packArray:Array = [
["BASIC",
["Hi - how's it going?", "Yes","No","See you later!"],
["GRAB","HIT","OPEN","CLOSE","PUSH","PULL"]
],
["SPY",
["I am 007", "I can't tell you now","Duck! Get down!","I am not who you think I am!"],
["SNEAK","HIDE","IMPERSONATE","STEAL","KARATE","EAVESDROP"]
],
["PARTY",
["Everybody Party!", "Do you come here often?","I dare you...","Chug-a-lug!"],
["BOOGIE","BE DRUNK","SPACE OUT","MINGLE","LAMP SHADE","HANDS UP"]
],
["GOOF",
["Sit on a Potato Pan, Otis", "I know you are but what am I?","I can't hear you!","Outa my way!"],
["TRIP","DROOL","FIB","HI-YUCK","ANNOY","INTERRUPT"]
],
["FLIRT",
["What's your name?", "So... what do you do?","You look beautiful","Want to go back to my place?"],
["TICKLE","KISS","HUG","POKE","WAVE","POSE"]
],
["FUNNY",
["Knock knock", "Borky bork de bork dork","Scandanavian watch!","My hovercraft is full of eels"],
["JOKE","LAUGH","YODEL","DO SLAPSTICK","MIME","MAKE FACES"]
],
["DANGER",
["Keep going!", "The force is strong in this one!","Danger is my middle name","Cowabunga!"],
["CLIMB","PARKOUR","DODGE","PUNCH","GO FAST","CLOSE EYES"]
],
["SEXY",
["I'm so hot!", "They say, he is Hollander Maui","Smokin!","Watch this..."],
["LURE","TWERK","LAMBADA","JIGGLE","REVEAL","BREATH HEAVILY"]
],
["MACHO",
["Eat my shorts", "Yippee Ki-yay!","I'll be back","Feel this..."],
["FLEX MUSCLES","DISCO","NOOGY","HULK","BULLY","PREEN"]
],
["GIRLY",
["Oh... I broke a nail!", "Goodness Gracious!","Unicorn dew power!","Like, then she said..."],
["SKIP","CURTSY","GIGGLE","FIX HAIR","SHRIEK","BE PRINCESS"]
],
["CRUDE",
["Up yours!", "Ass wagon!","Fork you!","Lick it!"],
["FART","BURP","SWEAR","GESTICULATE","ITCH","BARF"]
],
["ANIMAL",
["The sky is falling!", "What does the Fox say?","Moooooo Moooo","Hee Haw!"],
["ACT CAT","ACT DOG","ACT CHICKEN","ACT MEERKAT","ACT KANGAROO","ACT MONKEY"]
]
];
private var dataLookup:Array = ["CRAWL", "WALK", "RUN", "DANCE", "SIT", "CROUCH", "STAND", "LIE", "LOOK BACK LEFT", "LOOK BACK RIGHT", "LOOK LEFT", "LOOK RIGHT", "LOOK FRONT LEFT", "LOOK FRONT RIGHT", "LOOK FRONT", "TURN BACK", "TURN BACK LEFT", "TURN BACK RIGHT", "TURN LEFT", "TURN RIGHT", "TURN FRONT LEFT", "TURN FRONT RIGHT", "TURN FRONT", "REACH BACK", "REACH BACK LEFT", "REACH BACK RIGHT", "REACH LEFT", "REACH RIGHT", "REACH FRONT LEFT", "REACH FRONT RIGHT", "REACH FRONT", "GRAB", "HIT", "OPEN", "CLOSE", "PUSH", "PULL", "BASIC0", "BASIC1", "BASIC2", "BASIC3", "SNEAK", "HIDE", "IMPERSONATE", "STEAL", "KARATE", "EAVESDROP", "SPY0", "SPY1", "SPY2", "SPY3", "BOOGIE", "BE DRUNK", "SPACE OUT", "MINGLE", "LAMP SHADE", "HANDS UP", "PARTY0", "PARTY1", "PARTY2", "PARTY3", "TRIP", "DROOL", "FIB", "HI-YUCK", "ANNOY", "INTERRUPT", "GOOF0", "GOOF1", "GOOF2", "GOOF3", "TICKLE", "KISS", "HUG", "POKE", "WAVE", "POSE", "FLIRT0", "FLIRT1", "FLIRT2", "FLIRT3", "JOKE", "LAUGH", "YODEL", "DO SLAPSTICK", "MIME", "MAKE FACES", "FUNNY0", "FUNNY1", "FUNNY2", "FUNNY3", "CLIMB", "PARKOUR", "DODGE", "PUNCH", "GO FAST", "CLOSE EYES", "DANGER0", "DANGER1", "DANGER2", "DANGER3", "LURE", "TWERK", "LAMBADA", "JIGGLE", "REVEAL", "BREATH HEAVILY", "SEXY0", "SEXY1", "SEXY2", "SEXY3", "FLEX MUSCLES", "DISCO", "NOOGY", "HULK", "BULLY", "PREEN", "MACHO0", "MACHO1", "MACHO2", "MACHO3", "SKIP", "CURTSY", "GIGGLE", "FIX HAIR", "SHRIEK", "BE PRINCESS", "GIRLY0", "GIRLY1", "GIRLY2", "GIRLY3", "FART", "BURP", "SWEAR", "GESTICULATE", "ITCH", "BARF", "CRUDE0", "CRUDE1", "CRUDE2", "CRUDE3", "ACT CAT", "ACT DOG", "ACT CHICKEN", "ACT MEERKAT", "ACT KANGAROO", "ACT MONKEY", "ANIMAL0", "ANIMAL1", "ANIMAL2", "ANIMAL3"];
private var droneMustSoundArray:Array = ["d0","d1","d2","d4"];
private var timeTimer:Timer;
private var timeTimer2:Timer;
private var flashTextTimer:Timer;
private var sessionType:String = "none";
private var talkTextDefault:String = "Enter a Droner ID like your name. Get others to use the same DiD. Then press START and they can operate you!";
private var instructionsTextDefault:String = "Drone player will enter a Droner ID (DiD). Droner must enter the same ID then they can send commands to the Drone. See PACKS for more commands. Have Fun!";
private var busyTimer:Timer;
private var masterTimeCheck:Boolean = false;
private var totalTime:Number = 120; // total seconds for session
private var timerGoingCheck:Boolean = false;
private var timeOffset:Number = 0;
private var droneID:Number;
private var currentSound:String;
private var storeType:String;
private var store:Object;
private var myData:MyData;
private var dzRandomCheck:Boolean = false;
private var deactivateCheck:Boolean = false;
private var restoreCheck:Boolean = false;
private var ip:String;
public function Droner() {
trace ("hi from Droner");
//doLookup();
NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;
Multitouch.inputMode = MultitouchInputMode.GESTURE;
myData = new MyData();
//myData.addProduct("dp1");
//myData.addProduct("dp2");
for (var i:uint=0; i 0) {
sW = stage.fullScreenWidth;
sH = stage.fullScreenHeight;
} else {
sW = stage.stageWidth;
sH = stage.stageHeight;
}
stage.color = 0xffffff;
stage.frameRate = 30;
stage.setAspectRatio( StageAspectRatio.PORTRAIT );
butTimer = new Timer(slideTime/2*1000,1);
butTimer.addEventListener(TimerEvent.TIMER, toggleContent);
logoTimer = new Timer(1*1000,1);
logoTimer.addEventListener(TimerEvent.TIMER, logoSwitch);
timeTimer = new Timer(1*1000,totalTime);
timeTimer.addEventListener(TimerEvent.TIMER, doTime);
timeTimer.addEventListener(TimerEvent.TIMER_COMPLETE, doTimeEnd);
timeTimer2 = new Timer(1*1000,totalTime);
timeTimer2.addEventListener(TimerEvent.TIMER, doTime2);
timeTimer2.addEventListener(TimerEvent.TIMER_COMPLETE, doTime2End);
flashTextTimer = new Timer(.5*1000,4);
flashTextTimer.addEventListener(TimerEvent.TIMER, flashTextDone);
busyTimer = new Timer(5*1000,1);
busyTimer.addEventListener(TimerEvent.TIMER, busyDone);
makeAssets();
twoFace = new TwoFace(this, m1, m2, slideTime, 0, TwoFace.VERTICAL);
twoFace.addEventListener(TwoFace.MOTION_COMPLETE, motionDone);
twoFace.addEventListener(TransformGestureEvent.GESTURE_SWIPE, onSwipe);
addChild(twoFace);
addChild(intro);
addListeners();
var obj:Object = {app:"droner", pass:"dz"};
var myFalcon:Falcon = new Falcon("http://danzen.com/robin/ip.php?r="+Math.random(), Falcon.VARIABLES, obj);
myFalcon.addEventListener(Event.COMPLETE, whistleComplete);
}
private function whistleComplete (e:Event):void {
trace (e.target.data.ip);
trace (e.target.data);
ip = e.target.data.ip;
}
// ------------------ PURCHASES -----------------------
private function doDebug(e:Event):void {
m2.content.didText.text = store.debug;
m2.content.didText.text = "";
}
// put back in for apple
// ------------- take out below for android
private function doRestore(e:Event):void {
//m2.content.didText.text = "p="+store.currentProduct;
//packs.packTypes.myText.appendText("p="+store.currentProduct+"-\n");
if (restoreCheck) {
// only clear the data once when data comes in
// this prevents clearing data each restored entry
// it also gives them a chance to cancel the restore
myData.clearProducts();
paidPacks = [0];
restoreCheck = false;
}
myData.addProduct(store.currentProduct);
var n:Number = Number(String(store.currentProduct).substr(2,2))
paidPacks.push(n);
MovieClip(packs.packTypes.packButtons.getChildAt(n)).alpha = 1;
}
private function doRestoreFail(e:Event):void {
restoreCheck = false;
if (packs.packTypes.restoreBut.contains(packs.packTypes.restoreBut.busyInner)) {
packs.packTypes.restoreBut.removeChild(packs.packTypes.restoreBut.busyInner);
}
packs.packTypes.restoreBut.addChild(packs.packTypes.restoreBut.restoreInner);
}
private function doRestoreDone(e:Event):void {
if (packs.packTypes.restoreBut.contains(packs.packTypes.restoreBut.busyInner)) {
packs.packTypes.restoreBut.removeChild(packs.packTypes.restoreBut.busyInner);
}
packs.packTypes.restoreBut.addChild(packs.packTypes.restoreBut.restoredInner);
}
// -------------- take out above for android
private function doGetComplete(e:Event):void {
//m2.content.didText.text = store.currentProduct;
if (storeType && store.currentProduct == "fail") {
pack.content.promo.messageBox.messageText.text = "FAIL";
pack.content.promo.addChild(pack.content.promo.messageBox);
return;
} else {
if (pack.content.promo.contains(pack.content.promo.messageBox)) {
pack.content.promo.removeChild(pack.content.promo.messageBox);
}
}
if (storeType && store.currentProduct == "cancel") {
return;
}
myData.addProduct(store.currentProduct);
paidPacks.push(Number(String(store.currentProduct).substr(2,2)));
MovieClip(packs.packTypes.packButtons.getChildAt(pack.n)).alpha = 1;
if (pack.content.contains(pack.content.promo)) {
pack.content.removeChild(pack.content.promo);
}
}
private function doLookup():void {
for (var i:uint=0; i< dataLookup.length; i++) {
//trace (i + " " +dataLookup[i]);
}
}
// ------------------ ROBIN -----------------------
private function startRobin(n:String, t:String):void {
sessionType = t;
myRobin = new Robin("Droner_"+n.toLowerCase(),0,true,ip);
myRobin.addEventListener(Event.CONNECT, init);
myRobin.addEventListener(DataEvent.DATA, receiveData);
myRobin.addEventListener(Robin.CLIENT_LEFT, clientLeft);
myRobin.addEventListener(IOErrorEvent.IO_ERROR, connectError);
myRobin.addEventListener(Event.CLOSE, connectError);
if (!deactivateCheck) {
// this has nothing to do with Robin really
// was getting deactivate event firing 5 seconds after starting in debug
// this just delays the setting of the event until it is really needed
// and we really only need to shut down if Robin is running
NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, handleDeactivate);
NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_DOWN, handleKeys);
deactivateCheck = true;
}
}
private function stopRobin():void {
trace ("stop robin");
if (sessionType != "none") {
sessionType = "none";
myRobin.removeEventListener(Event.CONNECT, init);
myRobin.removeEventListener(DataEvent.DATA, receiveData);
myRobin.removeEventListener(Robin.CLIENT_LEFT, receiveData);
myRobin.removeEventListener(IOErrorEvent.IO_ERROR, connectError);
myRobin.dispose();
myRobin = null;
}
}
private function connectError(e:Event):void {
trace ("connectError");
m1.content.talkText.text = "Make sure you have an Internet connection. Server not found.";
m2.content.joinHolder.instructionsText.text = "Make sure you have an Internet connection. Server not found.";
flashText();
if (m1.content.startBut.contains(m1.content.startBut.stopText)) {
m1.content.startBut.removeChild(m1.content.startBut.stopText);
m1.content.startBut.addChild(m1.content.startBut.startText);
}
timeTimer.stop();
timeTimer.reset();
timeTimer2.stop();
timeTimer2.reset();
if (m2.content.contains(m2.content.directions)) {
m2.content.removeChild(m2.content.directions);
}
packsDown();
if (contains(packs)) {
removeChild(packs);
}
m2.content.addChild(m2.content.joinHolder);
m1.content.timeText.text = getTime(totalTime);
m2.content.timeText.text = getTime(totalTime);
stopRobin();
}
private function init(e:Event):void {
trace("Connected!");
if (sessionType == "drone") {
startDrone();
droneID = 0;
if (myRobin.getLatestValue("did")) {
droneID = Number(myRobin.getLatestValue("did"));
droneID++;
}
myRobin.setProperties({session:sessionType, did:droneID});
trace ("did" + droneID);
// find if any other drone
if (isDrone()) {
//startTimeTimer2(); // let master timer time command do this
} else {
// this is masterTime Drone
myRobin.setProperties({t:totalTime, mt:"y"}); // time and masterTime
masterTimeCheck = true;
timeTimer.start();
timerGoingCheck = true;
}
} else {
showDirections();
if (isDrone()) {
//startTimeTimer2(); // let master timer time command do this
}
myRobin.setProperties({session:sessionType});
}
}
private function clientLeft(e:Event):void {
trace ("clientLeft");
// if there is no mt and you are a drone then
// check if you are lowest droneID
// if yes, then send MT and time left according to your countdown and start timeTimer there
var mtArray:Array = myRobin.getProperties("mt");
var mtCheck:Boolean = false;
if (mtArray) {
for (var i:uint=0; i maxWidth) {
clip.scaleX = clip.scaleY = 1;
clipScale = maxWidth / originalWidth;
clip.scaleX = clip.scaleY = clipScale;
clip.x = minX;
if (clip == packs.packTypes) {
clip.y = packs.bar.height + (packs.backing.height-packs.bar.height-clip.height)/2;
} else if (clip == pack.content) {
clip.y = pack.bar.height + (pack.backing.height-pack.bar.height-clip.height)/2;
} else if (clip == intro.content) {
clip.y = (sH - originalHeight*clipScale) / 2;
} else {
clip.y = (sH - m1.logo.height/2 - logoSpacing - originalHeight*clipScale) / 2 ;
}
} else {
clip.x = (sW - originalWidth*clipScale) / 2;
clip.y = minY;
}
}
// ------------------ PAGE NAVIGATION -----------------------
private function addListeners():void {
m1.content.but.addEventListener(MouseEvent.CLICK, go2);
m1.content.but.buttonMode = true;
m2.content.but.addEventListener(MouseEvent.CLICK, go1);
m2.content.but.buttonMode = true;
m1.logo.addEventListener(MouseEvent.CLICK, toggleIntro);
m1.logo.buttonMode = true;
}
private function onSwipe(e:TransformGestureEvent):void {
if (contains(intro)) {
toggleIntro(null);
return;
}
if (e.offsetX == 1 || e.offsetX == -1) {
doHelp(null);
}
if (e.offsetY == 1) { // swipe towards bottom
if (twoFace.state == TwoFace.CENTER) {
go2(null);
} else if (twoFace.state == TwoFace.DOWN) {
go3(null);
}
}
if (e.offsetY == -1) { // swipe towards top
if (twoFace.state == TwoFace.CENTER) {
go1(null);
} else if (twoFace.state == TwoFace.UP) {
go3(null);
}
}
}
private function onPacksSwipe(e:TransformGestureEvent):void {
if (e.offsetY == -1) { // to top
if (packs.y > sH/2) {
togglePacks(null);
}
} else {
if (packs.y < sH/2) {
togglePacks(null);
}
}
}
private function onPackSwipe(e:TransformGestureEvent):void {
if (e.offsetY == 1) { // to bottom
if (pack.y < sH/2) { // pack open
togglePack(null);
}
}
}
private function removeListeners():void {
if (m1.content.but.hasEventListener(MouseEvent.CLICK)) {
m1.content.but.removeEventListener(MouseEvent.CLICK, go2);
m1.content.but.buttonMode = false;
}
if (m2.content.but.hasEventListener(MouseEvent.CLICK)) {
m2.content.but.removeEventListener(MouseEvent.CLICK, go1);
m2.content.but.buttonMode = false;
}
if (m1.logo.hasEventListener(MouseEvent.CLICK)) {
if (twoFace.state == TwoFace.CENTER) {
m1.logo.removeEventListener(MouseEvent.CLICK, go3);
} else {
m1.logo.removeEventListener(MouseEvent.CLICK, toggleIntro);
}
m1.logo.buttonMode = false;
}
}
private function toggleContent(e:TimerEvent):void { // called in middle of tween
if (m1.content.contains(m1.content.but)) {
m1.content.removeChild(m1.content.but);
m2.content.removeChild(m2.content.but);
if (m2.content.contains(m2.content.directions)) {
m2.content.removeChild(m2.content.directions);
}
m2.content.addChild(m2.content.joinHolder);
} else {
m1.content.addChild(m1.content.but);
m2.content.addChild(m2.content.but);
if (contains(packs)) {
removeChild(packs);
}
}
}
private function motionDone(e:Event):void { // end of tween
if (twoFace.state == TwoFace.CENTER) {
addListeners();
} else if (twoFace.state == TwoFace.UP) {
m1.logo.addEventListener(MouseEvent.CLICK, go3);
m1.logo.buttonMode = true;
} else if (twoFace.state == TwoFace.DOWN) {
m1.logo.addEventListener(MouseEvent.CLICK, go3);
m1.logo.buttonMode = true;
}
}
private function go1(e:MouseEvent):void { // droner
twoFace.down();
butTimer.start();
removeListeners();
if (m2.content.joinHolder.joinBut.contains(m2.content.joinHolder.joinBut.leaveText)) {
m2.content.joinHolder.joinBut.removeChild(m2.content.joinHolder.joinBut.leaveText);
m2.content.joinHolder.joinBut.contains(m2.content.joinHolder.joinBut.joinText);
}
m2.content.joinHolder.instructionsText.text = instructionsTextDefault;
packsDown();
}
private function go2(e:MouseEvent):void { // drone
twoFace.up();
butTimer.start();
removeListeners();
if (m1.content.startBut.contains(m1.content.startBut.stopText)) {
m1.content.startBut.removeChild(m1.content.startBut.stopText);
m1.content.startBut.addChild(m1.content.startBut.startText);
}
m1.content.talkText.text = talkTextDefault;
}
private function go3(e:MouseEvent):void { // center
if (sessionType == "drone") {
m1.content.talkText.text = "Press STOP button to leave screen. This will stop everyone if you are the only Drone.";
flashText();
return;
} else if (sessionType == "droner") {
timeTimer2.stop();
timeTimer2.reset();
timerGoingCheck = false;
m2.content.timeText.text = getTime(totalTime);
m2.content.joinHolder.instructionsText.text = instructionsTextDefault;
stopRobin();
}
twoFace.center();
butTimer.start();
removeListeners();
packsDown();
}
// ------------------ PAGE 1 METHODS -----------------------
private function toggleStart(e:MouseEvent):void {
if (m1.content.startBut.contains(m1.content.startBut.startText)) {
if (m1.content.didText.text == "") {
m1.content.talkText.text = talkTextDefault;
flashText();
return;
}
startRobin(m1.content.didText.text, "drone");
// waits for robin to connect then calls startDrone()
} else {
m1.content.startBut.removeChild(m1.content.startBut.stopText);
m1.content.startBut.addChild(m1.content.startBut.startText);
m1.content.timeText.text = getTime(totalTime);
m1.content.talkText.text = talkTextDefault;
timerGoingCheck = false;
timeTimer2.stop();
timeTimer2.reset();
timeTimer.stop();
timeTimer.reset();
m2.content.timeText.text = getTime(totalTime);
m2.content.joinHolder.instructionsText.text = instructionsTextDefault;
// if last drone then cancel session
if (!isDrone()) {
stopRobin();
doAbort();
} else {
stopRobin();
}
}
}
private function startDrone():void {
m1.content.talkText.text = "Do everything you hear.\nSay anything you read here that Droners send.";
flashText();
m1.content.startBut.removeChild(m1.content.startBut.startText);
m1.content.startBut.addChild(m1.content.startBut.stopText);
}
private function flashText():void {
m1.content.flashRect.visible = false;
m2.content.joinHolder.flashRect.visible = false; // piggybacking
flashTextTimer.reset();
flashTextTimer.start();
}
private function flashTextDone(e:TimerEvent):void {
m1.content.flashRect.visible = !m1.content.flashRect.visible;
m2.content.joinHolder.flashRect.visible = !m2.content.joinHolder.flashRect.visible;
}
private function doHelp(e:MouseEvent):void {
if (intro.content.contains(intro.content.definitions)) {
intro.content.removeChild(intro.content.definitions);
}
intro.content.addChild(intro.content.description);
addChild(intro);
}
private function toggleIntro(e:MouseEvent):void {
if (intro.content.contains(intro.content.description)) {
intro.content.removeChild(intro.content.description);
}
if (intro.content.contains(intro.content.complete)) {
intro.content.removeChild(intro.content.complete);
}
if (intro.content.contains(intro.content.aborted)) {
intro.content.removeChild(intro.content.aborted);
}
intro.content.addChild(intro.content.definitions);
if (contains(intro)) {
removeChild(intro);
} else {
addChild(intro);
}
}
// ------------------ PAGE 2 METHODS -----------------------
private function doJoin(e:MouseEvent):void {
if (m2.content.didText.text == "") {
m2.content.joinHolder.instructionsText.text = instructionsTextDefault;
flashText();
return;
}
startRobin(m2.content.didText.text, "droner");
}
private function showDirections():void {
m2.content.removeChild(m2.content.joinHolder);
m2.content.addChild(m2.content.directions);
scalePacks();
addChild(packs);
var i:uint;
if (m2.content.didText.text == "DZRANDOM") {
// gives random pack once per app open
if (dzRandomCheck) {return;}
dzRandomCheck = true;
paidPacks = [0];
for (i=0; i -1) {
currentPack.alpha = 1;
} else {
currentPack.alpha = 0;
}
}
}
private function togglePacks(e:MouseEvent):void {
if (packs.y > sW/2) {
packsUp();
} else {
packsDown();
}
}
private function packsDown():void {
packs.y = sH - packs.bar.height;
packs.bar.leftArrow.rotation = 180;
packs.bar.rightArrow.rotation = 180;
if (contains(pack)) {
removeChild(pack);
packCheck = true;
}
if (pack.content.promo.contains(pack.content.promo.messageBox)) {
pack.content.promo.removeChild(pack.content.promo.messageBox);
}
}
private function packsUp():void {
packs.y = sH - packs.backing.height;
packs.bar.leftArrow.rotation = 0;
packs.bar.rightArrow.rotation = 0;
// put back in for apple
// ---- take out below for android
if (packs.packTypes.restoreBut.contains(packs.packTypes.restoreBut.busyInner)) {
packs.packTypes.restoreBut.removeChild(packs.packTypes.restoreBut.busyInner);
}
packs.packTypes.restoreBut.addChild(packs.packTypes.restoreBut.restoreInner);
if (packCheck) {
addChild(pack);
}
// ----- take out above for android
}
private function togglePack(e:MouseEvent):void {
if (pack.y > sW/2) {
addChild(pack);
packCheck = true;
} else {
removeChild(pack);
packCheck = false;
if (pack.content.promo.contains(pack.content.promo.messageBox)) {
pack.content.promo.removeChild(pack.content.promo.messageBox);
}
}
}
// put back in for apple
// ----- take out below for android
private function doRestoreBut(e:MouseEvent):void {
if (!storeType || !store.checkStore()) {
return;
}
if (packs.packTypes.restoreBut.contains(packs.packTypes.restoreBut.busyInner)) {
return;
}
if (packs.packTypes.restoreBut.contains(packs.packTypes.restoreBut.restoredInner)) {
return;
}
trace ("doRestoreBut");
if (packs.packTypes.restoreBut.contains(packs.packTypes.restoreBut.restoreInner)) {
packs.packTypes.restoreBut.removeChild(packs.packTypes.restoreBut.restoreInner);
}
packs.packTypes.restoreBut.addChild(packs.packTypes.restoreBut.busyInner);
restoreCheck = true;
store.restoreTransactions();
}
// ---- take out above for android
private function doGet(e:MouseEvent):void {
// go to store
// check if store is true - if not, add no store message
// (remove no store message when they close the pack)
// add connecting message to pack
// adjust below to the right p
if (!storeType || !store.checkStore()) {
pack.content.promo.messageBox.messageText.text = "NO STORE";
pack.content.promo.addChild(pack.content.promo.messageBox);
return;
}
trace ("dp"+pack.n);
store.getProduct("dp"+pack.n);
pack.content.promo.messageBox.messageText.text = "CONNECTING";
pack.content.promo.addChild(pack.content.promo.messageBox);
//store.getProduct("dp"+pack.n);
/*
paidPacks.push(pack.n);
MovieClip(packs.packTypes.packButtons.getChildAt(pack.n)).alpha = 1;
if (pack.content.contains(pack.content.promo)) {
pack.content.removeChild(pack.content.promo);
}
*/
}
private function doPack(e:MouseEvent):void {
pack.n = MovieClip(packs.packTypes.packButtons).getChildIndex(MovieClip(e.target));
pack.bar.packText.text = packArray[pack.n][0];
// backing color
for (var i:uint=0; i= 0) {
command = packArray[pack.n][0]+""+match;
}
m = m.toUpperCase();
pack.content.sendBut.removeEventListener(MouseEvent.CLICK, doSendBut);
pack.content.sendBut.buttonMode = false;
logoTimer.start();
if (m.indexOf("TELL DRONE WHAT TO SAY") >= 0 || m == "") {
m1.logo.message.messageText.text = "TYPE SOMETHING";
m1.logo.message.messageText2.messageText2.text = "";
} else {
m1.logo.message.messageText.text = "SENDING SAY";
m1.logo.message.messageText2.messageText2.text = "SENDING SAY";
// ROBIN SEND -----------------------------
if (busyCheck) {
//m1.logo.message.messageText.text = "* DRONE BUSY *";
//m1.logo.message.messageText2.messageText2.text = "";
m1.logo.message.addChild(m1.logo.message.busy);
} else if (!isDrone()) {
m1.logo.message.messageText.text = "* NO DRONE *";
m1.logo.message.messageText2.messageText2.text = "";
} else {
if (command != "") {
myRobin.setProperties({command:dataLookup.indexOf(command), type:"command"});
} else {
myRobin.setProperties({say:m, type:"say"});
}
doBusy();
}
}
}
private function doPackButs(e:MouseEvent):void {
m1.logo.addChild(m1.logo.message);
var i:uint = pack.content.packButs.getChildIndex(MovieClip(e.target));
var m:String = String(packArray[pack.n][2][i]);
m = m.toUpperCase();
m1.logo.message.messageText.text = m;
m1.logo.message.messageText2.messageText2.text = m;
pack.content.packButs.removeEventListener(MouseEvent.CLICK, doPackButs);
pack.content.packButs.buttonMode = false;
logoTimer.start();
// ROBIN SEND -----------------------------
if (busyCheck) {
m1.logo.message.addChild(m1.logo.message.busy);
} else if (!isDrone()) {
m1.logo.message.messageText.text = "* NO DRONE *";
m1.logo.message.messageText2.messageText2.text = "";
} else {
myRobin.setProperties({command:dataLookup.indexOf(m), type:"command"});
doBusy();
}
}
private function handleActivate(event:Event):void {
NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;
}
private function handleDeactivate(event:Event):void {
// going to the store was stopping Droner on Android
if (contains(pack) && pack.contains(pack.content) && pack.content.contains(pack.content.promo)) {
return;
}
NativeApplication.nativeApplication.exit();
}
private function handleKeys(event:KeyboardEvent):void {
if(event.keyCode == Keyboard.BACK) {
NativeApplication.nativeApplication.exit();
}
}
}
}
package com.danzen.interfaces {
import com.greensock.TweenLite;
import com.greensock.easing.Quad;
import flash.display.MovieClip;
import flash.events.Event;
public class TwoFace extends MovieClip {
public static const VERTICAL:String = "vertical";
public static const HORIZONTAL:String = "horizontal";
public static const UP:String = "up";
public static const DOWN:String = "down";
public static const LEFT:String = "left";
public static const RIGHT:String = "right";
public static const CENTER:String = "center";
public static const MOTION_COMPLETE:String = "complete";
public var direction:String;
private var outer:MovieClip;
private var clip1:MovieClip;
private var clip2:MovieClip;
private var speed:Number;
private var offset:Number;
private var sW:Number;
private var sH:Number;
private var upStart:Number;
private var downStart:Number;
private var centerAdjust:Number;
private var clip1H:Number;
private var clip2H:Number;
private var _state:String = "center";
public function TwoFace(theParent:MovieClip, theClip1:MovieClip, theClip2:MovieClip, theSpeed:Number=.5, theOffset:Number=0, theDirection:String="vertical") {
trace ("hi from TwoFace");
outer = theParent;
// set up stage and bring in assets
if (outer.stage.fullScreenWidth > 0) {
sW = outer.stage.fullScreenWidth;
sH = outer.stage.fullScreenHeight;
} else {
sW = outer.stage.stageWidth;
sH = outer.stage.stageHeight;
}
speed = theSpeed;
clip1 = theClip1;
clip2 = theClip2;
clip1H = (clip1.desiredHeight) ? clip1.desiredHeight : clip1.height;
clip2H = (clip2.desiredHeight) ? clip2.desiredHeight : clip2.height;
offset = theOffset;
direction = theDirection;
clip1.y = (sH - (clip1H + clip2H)) / 2;
clip2.y = clip1.y + clip1H;
centerAdjust = clip1.y;
addChild(clip2);
addChild(clip1);
upStart = -clip1.y;
downStart = sH - clip1H - clip2H - centerAdjust;
}
public function up():void {
_state = TwoFace.UP;
TweenLite.to(this,speed,{y:upStart-offset, ease:Quad.easeInOut, onComplete:doneMove})
}
public function down():void {
_state = TwoFace.DOWN;
TweenLite.to(this,speed,{y:downStart+offset, ease:Quad.easeInOut, onComplete:doneMove})
}
public function center():void {
_state = TwoFace.CENTER;
TweenLite.to(this,speed,{y:0, ease:Quad.easeInOut, onComplete:doneMove})
}
private function doneMove():void {
dispatchEvent(new Event(TwoFace.MOTION_COMPLETE));
}
public function get state():String {
return _state;
}
}
}