actionscript-distort-view-distortion-TextExample.mx [swf] flex
<?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:sides="view.sides.*" xmlns:mxeffects="com.adobe.ac.mxeffects.*" creationComplete="rotateCubeFull();" width="600" horizontalAlign="center"> <mxeffects:CubeRotate id="flipType" duration="1000"/> <mxeffects:CubeRotate id="flipType2" duration="1000"/> <mx:ViewStack id="loginViewStack"> <mx:Canvas id="_F" width="320" height="320" hideEffect="{ flipType }" backgroundColor="0X000000"> <mx:Box id="_F11" backgroundColor="0XFF00FF" width="100" height="100" x="5" y="5" click="selectItem(this._F11)"/> <mx:Box id="_F12" backgroundColor="0XFF00FF" width="100" height="100" x="110" y="5" click="selectItem(this._F12)" /> <mx:Box id="_F13" backgroundColor="0XFF00FF" width="100" height="100" x="215" y="5" click="selectItem(this._F13)" /> <mx:Box id="_F21" backgroundColor="0XFF00FF" width="100" height="100" x="5" y="110" click="selectItem(this._F21)" /> <mx:Box id="_F22" backgroundColor="0XFF00FF" width="100" height="100" x="110" y="110" click="selectItem(this._F22)" /> <mx:Box id="_F23" backgroundColor="0XFF00FF" width="100" height="100" x="215" y="110" click="selectItem(this._F23)" /> <mx:Box id="_F31" backgroundColor="0XFF00FF" width="100" height="100" x="5" y="215" click="selectItem(this._F31)" /> <mx:Box id="_F32" backgroundColor="0XFF00FF" width="100" height="100" x="110" y="215" click="selectItem(this._F32)" /> <mx:Box id="_F33" backgroundColor="0XFF00FF" width="100" height="100" x="215" y="215" click="selectItem(this._F33)" /> <mx:ViewStack id="tempViewStack" backgroundColor="0x000000" width="1" height="1"> <mx:Canvas id="tempFront" width="320" height="320" hideEffect="{ flipType2 }"> </mx:Canvas> <mx:Canvas id="tempLeft" width="320" height="320" hideEffect="{ flipType2 }"> </mx:Canvas> </mx:ViewStack> </mx:Canvas> <mx:Canvas id="_L" width="320" height="320" hideEffect="{ flipType }" backgroundColor="0X000000"> <mx:Box id="_L11" backgroundColor="0XFF0000" width="100" height="100" x="5" y="5" click="selectItem(this._L11)"/> <mx:Box id="_L12" backgroundColor="0XFF0000" width="100" height="100" x="110" y="5" click="selectItem(this._L12)" /> <mx:Box id="_L13" backgroundColor="0XFF0000" width="100" height="100" x="215" y="5" click="selectItem(this._L13)" /> <mx:Box id="_L21" backgroundColor="0XFF0000" width="100" height="100" x="5" y="110" click="selectItem(this._L21)" /> <mx:Box id="_L22" backgroundColor="0XFF0000" width="100" height="100" x="110" y="110" click="selectItem(this._L22)" /> <mx:Box id="_L23" backgroundColor="0XFF0000" width="100" height="100" x="215" y="110" click="selectItem(this._L23)" /> <mx:Box id="_L31" backgroundColor="0XFF0000" width="100" height="100" x="5" y="215" click="selectItem(this._L31)" /> <mx:Box id="_L32" backgroundColor="0XFF0000" width="100" height="100" x="110" y="215" click="selectItem(this._L32)" /> <mx:Box id="_L33" backgroundColor="0XFF0000" width="100" height="100" x="215" y="215" click="selectItem(this._L33)" /> </mx:Canvas> <mx:Canvas id="_BA" width="320" height="320" hideEffect="{ flipType }" backgroundColor="0X000000"> <mx:Box id="_BA11" backgroundColor="0X00FF00" width="100" height="100" x="5" y="5" click="selectItem(this._BA11)" /> <mx:Box id="_BA12" backgroundColor="0X00FF00" width="100" height="100" x="110" y="5" click="selectItem(this._BA12)" /> <mx:Box id="_BA13" backgroundColor="0X00FF00" width="100" height="100" x="215" y="5" click="selectItem(this._BA13)" /> <mx:Box id="_BA21" backgroundColor="0X00FF00" width="100" height="100" x="5" y="110" click="selectItem(this._BA21)" /> <mx:Box id="_BA22" backgroundColor="0X00FF00" width="100" height="100" x="110" y="110" click="selectItem(this._BA22)" /> <mx:Box id="_BA23" backgroundColor="0X00FF00" width="100" height="100" x="215" y="110" click="selectItem(this._BA23)" /> <mx:Box id="_BA31" backgroundColor="0X00FF00" width="100" height="100" x="5" y="215" click="selectItem(this._BA31)" /> <mx:Box id="_BA32" backgroundColor="0X00FF00" width="100" height="100" x="110" y="215" click="selectItem(this._BA32)" /> <mx:Box id="_BA33" backgroundColor="0X00FF00" width="100" height="100" x="215" y="215" click="selectItem(this._BA33)" /> </mx:Canvas> <mx:Canvas id="_R" width="320" height="320" hideEffect="{ flipType }" backgroundColor="0X000000"> <mx:Box id="_R11" backgroundColor="0X0000FF" width="100" height="100" x="5" y="5" click="selectItem(this._R11)"/> <mx:Box id="_R12" backgroundColor="0X0000FF" width="100" height="100" x="110" y="5" click="selectItem(this._R12)" /> <mx:Box id="_R13" backgroundColor="0X0000FF" width="100" height="100" x="215" y="5" click="selectItem(this._R13)" /> <mx:Box id="_R21" backgroundColor="0X0000FF" width="100" height="100" x="5" y="110" click="selectItem(this._R21)" /> <mx:Box id="_R22" backgroundColor="0X0000FF" width="100" height="100" x="110" y="110" click="selectItem(this._R22)" /> <mx:Box id="_R23" backgroundColor="0X0000FF" width="100" height="100" x="215" y="110" click="selectItem(this._R23)" /> <mx:Box id="_R31" backgroundColor="0X0000FF" width="100" height="100" x="5" y="215" click="selectItem(this._R31)" /> <mx:Box id="_R32" backgroundColor="0X0000FF" width="100" height="100" x="110" y="215" click="selectItem(this._R32)" /> <mx:Box id="_R33" backgroundColor="0X0000FF" width="100" height="100" x="215" y="215" click="selectItem(this._R33)" /> </mx:Canvas> <mx:Canvas id="_T" width="320" height="320" hideEffect="{ flipType }" backgroundColor="0X000000"> <mx:Box id="_T11" backgroundColor="0XFFFF00" width="100" height="100" x="5" y="5" click="selectItem(this._T11)"/> <mx:Box id="_T12" backgroundColor="0XFFFF00" width="100" height="100" x="110" y="5" click="selectItem(this._T12)" /> <mx:Box id="_T13" backgroundColor="0XFFFF00" width="100" height="100" x="215" y="5" click="selectItem(this._T13)" /> <mx:Box id="_T21" backgroundColor="0XFFFF00" width="100" height="100" x="5" y="110" click="selectItem(this._T21)" /> <mx:Box id="_T22" backgroundColor="0XFFFF00" width="100" height="100" x="110" y="110" click="selectItem(this._T22)" /> <mx:Box id="_T23" backgroundColor="0XFFFF00" width="100" height="100" x="215" y="110" click="selectItem(this._T23)" /> <mx:Box id="_T31" backgroundColor="0XFFFF00" width="100" height="100" x="5" y="215" click="selectItem(this._T31)" /> <mx:Box id="_T32" backgroundColor="0XFFFF00" width="100" height="100" x="110" y="215" click="selectItem(this._T32)" /> <mx:Box id="_T33" backgroundColor="0XFFFF00" width="100" height="100" x="215" y="215" click="selectItem(this._T33)" /> </mx:Canvas> <mx:Canvas id="_BO" width="320" height="320" hideEffect="{ flipType }" backgroundColor="0X000000"> <mx:Box id="_BO11" backgroundColor="0X00FFFF" width="100" height="100" x="5" y="5" click="selectItem(this._BO11)" /> <mx:Box id="_BO12" backgroundColor="0X00FFFF" width="100" height="100" x="110" y="5" click="selectItem(this._BO12)" /> <mx:Box id="_BO13" backgroundColor="0X00FFFF" width="100" height="100" x="215" y="5" click="selectItem(this._BO13)" /> <mx:Box id="_BO21" backgroundColor="0X00FFFF" width="100" height="100" x="5" y="110" click="selectItem(this._BO21)" /> <mx:Box id="_BO22" backgroundColor="0X00FFFF" width="100" height="100" x="110" y="110" click="selectItem(this._BO22)" /> <mx:Box id="_BO23" backgroundColor="0X00FFFF" width="100" height="100" x="215" y="110" click="selectItem(this._BO23)" /> <mx:Box id="_BO31" backgroundColor="0X00FFFF" width="100" height="100" x="5" y="215" click="selectItem(this._BO31)" /> <mx:Box id="_BO32" backgroundColor="0X00FFFF" width="100" height="100" x="110" y="215" click="selectItem(this._BO32)" /> <mx:Box id="_BO33" backgroundColor="0X00FFFF" width="100" height="100" x="215" y="215" click="selectItem(this._BO33)" /> </mx:Canvas> </mx:ViewStack> <mx:Canvas width="100%" height="200"> <mx:Button id="rl" label="Rotate Left" click="changeStack('left');" enabled="false" x="37" y="55"/> <mx:Button id="rr" label="Rotate Right" click="changeStack('right');" enabled="false" x="169" y="55"/> <mx:Button id="ru" label="Rotate Up" click="changeStack('up');" enabled="false" x="95" y="25" width="100"/> <mx:Button id="rd" label="Rotate Down" click="changeStack('down');" enabled="false" x="95" y="85"/> <mx:Button id="rrl" label="Rotate Row Left" click="changeRowStack('left');" enabled="false" x="306" y="55"/> <mx:Button id="rrr" label="Rotate Row Right" click="changeRowStack('right');" enabled="false" x="465" y="55"/> <mx:Button id="rru" label="Rotate Row Up" click="changeRowStack('up');" enabled="false" x="372" y="25" width="127"/> <mx:Button id="rrd" label="Rotate Row Down" click="changeRowStack('down');" enabled="false" x="372" y="85"/> <mx:VRule x="287" y="25"/> <mx:Label x="146" y="115" text="Geduld is een schone zaak!" fontSize="22"/> <mx:Label x="150" y="155" text="Patience is a good matter!" fontSize="22"/> </mx:Canvas> <mx:Script> <![CDATA[ import mx.effects.Glow; [Bindable] private var selectedItem:Box; [Bindable] private var _left:uint = 3; [Bindable] private var _right:uint = 1; [Bindable] private var _front:uint = 0; [Bindable] private var _back:uint = 2; [Bindable] private var _top:uint = 4; [Bindable] private var _bottom:uint = 5; private var timer:Timer; private function rotateLeft():void { var temp:uint = _front; _front = _right; _right = _back; _back = _left; _left = temp; (loginViewStack.getChildAt(_left) as Canvas).removeChild(tempViewStack); (loginViewStack.getChildAt(_front) as Canvas).addChild(tempViewStack); } public function rotateRight():void { var temp:uint = _front; _front = _left; _left = _back; _back = _right; _right = temp; (loginViewStack.getChildAt(_right) as Canvas).removeChild(tempViewStack); (loginViewStack.getChildAt(_front) as Canvas).addChild(tempViewStack); } public function rotateUp():void { var temp:uint = _front; _front = _bottom; _bottom = _back; _back = _top; _top = temp; (loginViewStack.getChildAt(_top) as Canvas).removeChild(tempViewStack); (loginViewStack.getChildAt(_front) as Canvas).addChild(tempViewStack); } public function rotateDown():void { var temp:uint = _front; _front = _top; _top = _back; _back = _bottom; _bottom = temp; (loginViewStack.getChildAt(_bottom) as Canvas).removeChild(tempViewStack); (loginViewStack.getChildAt(_front) as Canvas).addChild(tempViewStack); } public function changeStack(input:String, timerWorking:Boolean=true):void { var direction:int; if (input == "left"){ flipType.direction = "LEFT"; flipType.target = loginViewStack.selectedChild; flipType.siblings = [ loginViewStack.getChildAt(_right) ]; rotateLeft(); } if (input == "right"){ flipType.direction = "RIGHT"; flipType.target = loginViewStack.selectedChild; flipType.siblings = [ loginViewStack.getChildAt(_left) ]; rotateRight(); } if (input == "up"){ flipType.direction = "TOP"; flipType.target = loginViewStack.selectedChild; flipType.siblings = [ loginViewStack.getChildAt(_bottom) ]; rotateUp(); } if (input == "down"){ flipType.direction = "BOTTOM"; flipType.target = loginViewStack.selectedChild; flipType.siblings = [ loginViewStack.getChildAt(_top) ]; rotateDown(); } if (timerWorking) disableAllButtons1sec(); loginViewStack.selectedIndex = _front; } private function disableAllButtons1sec():void{ disableAllButtons(); timer = new Timer(1000); timer.addEventListener(TimerEvent.TIMER, enableAllButtons); timer.start(); } private function disableAllButtons():void{ rru.enabled = false; rrd.enabled = false; rrr.enabled = false; rrl.enabled = false; ru.enabled = false; rd.enabled = false; rr.enabled = false; rl.enabled = false; } private function enableAllButtons(input:TimerEvent=null):void{ rru.enabled = true; rrd.enabled = true; rrr.enabled = true; rrl.enabled = true; ru.enabled = true; rd.enabled = true; rr.enabled = true; rl.enabled = true; if (input){ timer.stop(); timer = null; } } private function selectItem(input:Box):void { if (rr.enabled == true){ if (selectedItem == null) selectedItem = input; else { selectedItem.filters = [ ]; selectedItem = input; } input.filters = [ new GlowFilter( 0xffffff, 3, 12, 12,4,2,true) ]; } } ]]> </mx:Script> <mx:Script> <![CDATA[ import mx.controls.Alert; private var ticker2:Timer; private var what:int = 0; private var latestDirection:String = ""; private var _Row:int = 0; private var _Column:int = 0; private var _Type:String = ""; private var _number:int = 0; private function rotateCubeFull():void{ what = 0; ticker2 = new Timer(340); ticker2.addEventListener(TimerEvent.TIMER, onTick); ticker2.start(); } private function actAfter3Secs():void{ what = 0; ticker2 = new Timer(5); ticker2.addEventListener(TimerEvent.TIMER, doIt); ticker2.start(); } private function doIt(evt:TimerEvent):void{ what++; if (what == 4) tempViewStack.selectedChild = tempLeft; else if (what == 150){ ticker2.stop(); ticker2 = null; rearangeObjects(); } } public function onTick(evt:TimerEvent):void { if (what == 0){ // rotate left. changeStack('left', false); } else if (what == 3){ //rotate left. changeStack('left', false); } else if (what == 6){ // rotate left. changeStack('left', false); } else if (what == 9){ // rotate left. changeStack('left', false); } else if (what == 12){ // rotate up. changeStack('up', false); } else if (what == 15){ // rotate up. changeStack('up', false); } else if (what == 18){ // rotate up. changeStack('up', false); } else if (what == 21){ // rotate up. changeStack('up', false); } else if (what == 25){ // rotate up. if (_number >= 4){ ticker2.stop(); ticker2 = null; enableAllButtons(); } else if (_number == 0){ ticker2.stop(); ticker2 = null; _number++; selectedItem = locateChild(_front, 3, 1); changeRowStack('left'); } else if (_number == 1){ ticker2.stop(); ticker2 = null; _number++; selectedItem = locateChild(_front, 2, 2); changeRowStack('up'); } else if (_number == 2){ ticker2.stop(); ticker2 = null; _number++; selectedItem = locateChild(_front, 1, 3); changeRowStack('right'); } else if (_number == 3){ ticker2.stop(); ticker2 = null; _number++; selectedItem = locateChild(_front, 1, 3); changeRowStack('down'); } } what++; } public function changeRowStack(input:String):void { latestDirection = input; if (selectedItem == null) Alert.show("Please select an Item first!"); else{ _Row = parseInt(selectedItem.id.substr(selectedItem.id.length-2, 1)); _Column = parseInt(selectedItem.id.substr(selectedItem.id.length-1, 1)); _Type = selectedItem.id.substring(1, selectedItem.id.length-2); var first:int; var second:int; switch(input){ case "left": loginViewStack.selectedChild.removeChild(selectedItem); selectedItem.filters = []; tempViewStack.selectedIndex = 0; tempViewStack.width = 320; tempViewStack.height = 110; tempViewStack.x = 0; tempViewStack.y = selectedItem.y-5; tempViewStack.visible = true; if (_Column == 1){ first = 2; second = 3; } else if (_Column == 2){ first = 1; second = 3; } else if (_Column == 3){ first = 1; second = 2; } tempViewStack.selectedChild.addChild(selectedItem); selectedItem.visible = true; selectedItem.y = 5; selectedItem = locateChild(_front, _Row, first); // selectedItem = loginViewStack.selectedChild.getChildByName('_'+ _Type + _Row + first) as Box; // loginViewStack.selectedChild.removeChild(loginViewStack.selectedChild.getChildByName('_'+ _Type + _Row + first)); loginViewStack.selectedChild.removeChild(selectedItem); tempViewStack.selectedChild.addChild(selectedItem); selectedItem.visible = true; selectedItem.y = 5; selectedItem = locateChild(_front, _Row, second); // selectedItem = loginViewStack.selectedChild.getChildByName('_'+ _Type + _Row + second) as Box; // loginViewStack.selectedChild.removeChild(loginViewStack.selectedChild.getChildByName('_'+ _Type + _Row + second)); loginViewStack.selectedChild.removeChild(selectedItem); tempViewStack.selectedChild.addChild(selectedItem); selectedItem.visible = true; selectedItem.y = 5; selectedItem = locateChild(_right, _Row, 1); (loginViewStack.getChildAt(_right) as Canvas).removeChild(selectedItem); (tempViewStack.getChildByName('tempLeft') as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.y = 5; selectedItem = locateChild(_right, _Row, 2); (loginViewStack.getChildAt(_right) as Canvas).removeChild(selectedItem); (tempViewStack.getChildByName('tempLeft') as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.y = 5; selectedItem = locateChild(_right, _Row, 3); (loginViewStack.getChildAt(_right) as Canvas).removeChild(selectedItem); (tempViewStack.getChildByName('tempLeft') as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.y = 5; flipType2.direction = "LEFT"; flipType2.target = tempViewStack.selectedChild; flipType2.siblings = [ tempViewStack.getChildAt(1) as Canvas ]; actAfter3Secs(); disableAllButtons(); break; case "right": loginViewStack.selectedChild.removeChild(selectedItem); selectedItem.filters = []; tempViewStack.selectedIndex = 0; tempViewStack.width = 320; tempViewStack.height = 110; tempViewStack.x = 0; tempViewStack.y = selectedItem.y-5; tempViewStack.visible = true; if (_Column == 1){ first = 2; second = 3; } else if (_Column == 2){ first = 1; second = 3; } else if (_Column == 3){ first = 1; second = 2; } tempViewStack.selectedChild.addChild(selectedItem); selectedItem.visible = true; selectedItem.y = 5; selectedItem = locateChild(_front, _Row, first); // selectedItem = loginViewStack.selectedChild.getChildByName('_'+ _Type + _Row + first) as Box; // loginViewStack.selectedChild.removeChild(loginViewStack.selectedChild.getChildByName('_'+ _Type + _Row + first)); loginViewStack.selectedChild.removeChild(selectedItem); tempViewStack.selectedChild.addChild(selectedItem); selectedItem.visible = true; selectedItem.y = 5; selectedItem = locateChild(_front, _Row, second); // selectedItem = loginViewStack.selectedChild.getChildByName('_'+ _Type + _Row + second) as Box; // loginViewStack.selectedChild.removeChild(loginViewStack.selectedChild.getChildByName('_'+ _Type + _Row + second)); loginViewStack.selectedChild.removeChild(selectedItem); tempViewStack.selectedChild.addChild(selectedItem); selectedItem.visible = true; selectedItem.y = 5; selectedItem = locateChild(_left, _Row, 1); (loginViewStack.getChildAt(_left) as Canvas).removeChild(selectedItem); (tempViewStack.getChildByName('tempLeft') as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.y = 5; selectedItem = locateChild(_left, _Row, 2); (loginViewStack.getChildAt(_left) as Canvas).removeChild(selectedItem); (tempViewStack.getChildByName('tempLeft') as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.y = 5; selectedItem = locateChild(_left, _Row, 3); (loginViewStack.getChildAt(_left) as Canvas).removeChild(selectedItem); (tempViewStack.getChildByName('tempLeft') as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.y = 5; flipType2.direction = "RIGHT"; flipType2.target = tempViewStack.selectedChild; flipType2.siblings = [ tempViewStack.getChildAt(1) as Canvas ]; actAfter3Secs(); disableAllButtons(); break; case "up": loginViewStack.selectedChild.removeChild(selectedItem); selectedItem.filters = []; tempViewStack.selectedIndex = 0; tempViewStack.width = 110; tempViewStack.height = 320; tempViewStack.x = selectedItem.x-5; tempViewStack.y = 0; tempViewStack.visible = true; if (_Row == 1){ first = 2; second = 3; } else if (_Row == 2){ first = 1; second = 3; } else if (_Row == 3){ first = 1; second = 2; } tempViewStack.selectedChild.addChild(selectedItem); selectedItem.visible = true; selectedItem.x = 5; selectedItem = locateChild(_front, first, _Column); // selectedItem = loginViewStack.selectedChild.getChildByName('_'+ _Type + first + _Column) as Box; loginViewStack.selectedChild.removeChild(selectedItem); tempViewStack.selectedChild.addChild(selectedItem); selectedItem.visible = true; selectedItem.x = 5; selectedItem = locateChild(_front, second, _Column); // selectedItem = loginViewStack.selectedChild.getChildByName('_'+ _Type + second + _Column) as Box; //loginViewStack.selectedChild.removeChild(loginViewStack.selectedChild.getChildByName('_'+ _Type + second + _Column)); loginViewStack.selectedChild.removeChild(selectedItem); tempViewStack.selectedChild.addChild(selectedItem); selectedItem.visible = true; selectedItem.x = 5; selectedItem = locateChild(_bottom, 1, _Column); (loginViewStack.getChildAt(_bottom) as Canvas).removeChild(selectedItem); (tempViewStack.getChildByName('tempLeft') as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.x = 5; selectedItem = locateChild(_bottom, 2 , _Column); (loginViewStack.getChildAt(_bottom) as Canvas).removeChild(selectedItem); (tempViewStack.getChildByName('tempLeft') as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.x = 5; selectedItem = locateChild(_bottom, 3 , _Column); (loginViewStack.getChildAt(_bottom) as Canvas).removeChild(selectedItem); (tempViewStack.getChildByName('tempLeft') as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.x = 5; flipType2.direction = "TOP"; flipType2.target = tempViewStack.selectedChild; flipType2.siblings = [ tempViewStack.getChildAt(1) as Canvas ]; actAfter3Secs(); disableAllButtons(); break; case "down": loginViewStack.selectedChild.removeChild(selectedItem); selectedItem.filters = []; tempViewStack.selectedIndex = 0; tempViewStack.width = 110; tempViewStack.height = 320; tempViewStack.x = selectedItem.x-5; tempViewStack.y = 0; tempViewStack.visible = true; if (_Row == 1){ first = 2; second = 3; } else if (_Row == 2){ first = 1; second = 3; } else if (_Row == 3){ first = 1; second = 2; } tempViewStack.selectedChild.addChild(selectedItem); selectedItem.visible = true; selectedItem.x = 5; selectedItem = locateChild(_front, first, _Column); // selectedItem = loginViewStack.selectedChild.getChildByName('_'+ _Type + first + _Column) as Box; // loginViewStack.selectedChild.removeChild(loginViewStack.selectedChild.getChildByName('_'+ _Type + first + _Column)); loginViewStack.selectedChild.removeChild(selectedItem); tempViewStack.selectedChild.addChild(selectedItem); selectedItem.visible = true; selectedItem.x = 5; selectedItem = locateChild(_front, second, _Column); // selectedItem = loginViewStack.selectedChild.getChildByName('_'+ _Type + second + _Column) as Box; // loginViewStack.selectedChild.removeChild(loginViewStack.selectedChild.getChildByName('_'+ _Type + second + _Column)); loginViewStack.selectedChild.removeChild(selectedItem); tempViewStack.selectedChild.addChild(selectedItem); selectedItem.visible = true; selectedItem.x = 5; selectedItem = locateChild(_top, 1, _Column); (loginViewStack.getChildAt(_top) as Canvas).removeChild(selectedItem); (tempViewStack.getChildByName('tempLeft') as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.x = 5; selectedItem = locateChild(_top, 2 , _Column); (loginViewStack.getChildAt(_top) as Canvas).removeChild(selectedItem); (tempViewStack.getChildByName('tempLeft') as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.x = 5; selectedItem = locateChild(_top, 3 , _Column); (loginViewStack.getChildAt(_top) as Canvas).removeChild(selectedItem); (tempViewStack.getChildByName('tempLeft') as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.x = 5; flipType2.direction = "BOTTOM"; flipType2.target = tempViewStack.selectedChild; flipType2.siblings = [ tempViewStack.getChildAt(1) as Canvas ]; actAfter3Secs(); disableAllButtons(); break; } } } private function locateChild(cubeSide:int, row:int, column:int):Box{ var _x:int = 0; var _y:int = 0; if (row == 1){ _y = 5; } else if (row == 2){ _y = 110; } else if (row == 3){ _y = 215; } if (column == 1){ _x = 5; } else if (column == 2){ _x = 110; } else if (column == 3){ _x = 215; } for (var item:int=0;item < (loginViewStack.getChildAt(cubeSide) as Canvas).numChildren; item++){ if (((loginViewStack.getChildAt(cubeSide) as Canvas).getChildAt(item) as Box).x == _x && ((loginViewStack.getChildAt(cubeSide) as Canvas).getChildAt(item) as Box).y == _y){ return ((loginViewStack.getChildAt(cubeSide) as Canvas).getChildAt(item) as Box); } else { // Alert.show("X: " + ((loginViewStack.getChildAt(cubeSide) as Canvas).getChildAt(item) as Box).x + ' - Y: ' + ((loginViewStack.getChildAt(cubeSide) as Canvas).getChildAt(item) as Box).y); } } Alert.show('none found'); return null; } private function rearangeObjects():void{ var _y:int = 0; if (_Row == 1) _y = 5; if (_Row == 2) _y = 110; if (_Row == 3) _y = 215; var _x:int = 0; if (_Column == 1) _x = 5; if (_Column == 2) _x = 110; if (_Column == 3) _x = 215; switch (latestDirection){ case "left": // Change Back to Right! selectedItem = locateChild(_back, _Row, 1); (loginViewStack.getChildAt(_back) as Canvas).removeChild(selectedItem); (loginViewStack.getChildAt(_right) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.y = _y; selectedItem = locateChild(_back, _Row, 2); (loginViewStack.getChildAt(_back) as Canvas).removeChild(selectedItem); (loginViewStack.getChildAt(_right) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.y = _y; selectedItem = locateChild(_back, _Row, 3); (loginViewStack.getChildAt(_back) as Canvas).removeChild(selectedItem); (loginViewStack.getChildAt(_right) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.y = _y; // Change Left to Back! selectedItem = locateChild(_left, _Row, 1); (loginViewStack.getChildAt(_left) as Canvas).removeChild(selectedItem); (loginViewStack.getChildAt(_back) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.y = _y; selectedItem = locateChild(_left, _Row, 2); (loginViewStack.getChildAt(_left) as Canvas).removeChild(selectedItem); (loginViewStack.getChildAt(_back) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.y = _y; selectedItem = locateChild(_left, _Row, 3); (loginViewStack.getChildAt(_left) as Canvas).removeChild(selectedItem); (loginViewStack.getChildAt(_back) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.y = _y; // Change TempSelected to Front! selectedItem = tempLeft.getChildAt(0) as Box; tempLeft.removeChildAt(0); loginViewStack.selectedChild.addChild(selectedItem); selectedItem.visible = true; selectedItem.y = _y; selectedItem = tempLeft.getChildAt(0) as Box; tempLeft.removeChildAt(0); loginViewStack.selectedChild.addChild(selectedItem); selectedItem.visible = true; selectedItem.y = _y; selectedItem = tempLeft.getChildAt(0) as Box; tempLeft.removeChildAt(0); loginViewStack.selectedChild.addChild(selectedItem); selectedItem.visible = true; selectedItem.y = _y; // Change TempLeft to Left! selectedItem = tempFront.getChildAt(0) as Box; tempFront.removeChildAt(0); (loginViewStack.getChildAt(_left) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.y = _y; selectedItem = tempFront.getChildAt(0) as Box; tempFront.removeChildAt(0); (loginViewStack.getChildAt(_left) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.y = _y; selectedItem = tempFront.getChildAt(0) as Box; tempFront.removeChildAt(0); (loginViewStack.getChildAt(_left) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.y = _y; tempViewStack.x = 0; tempViewStack.y = 0; tempViewStack.width = 1; tempViewStack.height = 1; selectedItem = null; tempViewStack.selectedIndex = 0; tempViewStack.visible = false; rotateCubeFull(); break; case "right": // Change Back to Left! selectedItem = locateChild(_back, _Row, 1); (loginViewStack.getChildAt(_back) as Canvas).removeChild(selectedItem); (loginViewStack.getChildAt(_left) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.y = _y; selectedItem = locateChild(_back, _Row, 2); (loginViewStack.getChildAt(_back) as Canvas).removeChild(selectedItem); (loginViewStack.getChildAt(_left) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.y = _y; selectedItem = locateChild(_back, _Row, 3); (loginViewStack.getChildAt(_back) as Canvas).removeChild(selectedItem); (loginViewStack.getChildAt(_left) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.y = _y; // Change Right to Back! selectedItem = locateChild(_right, _Row, 1); (loginViewStack.getChildAt(_right) as Canvas).removeChild(selectedItem); (loginViewStack.getChildAt(_back) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.y = _y; selectedItem = locateChild(_right, _Row, 2); (loginViewStack.getChildAt(_right) as Canvas).removeChild(selectedItem); (loginViewStack.getChildAt(_back) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.y = _y; selectedItem = locateChild(_right, _Row, 3); (loginViewStack.getChildAt(_right) as Canvas).removeChild(selectedItem); (loginViewStack.getChildAt(_back) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.y = _y; // Change TempSelected to Front! selectedItem = tempLeft.getChildAt(0) as Box; tempLeft.removeChildAt(0); loginViewStack.selectedChild.addChild(selectedItem); selectedItem.visible = true; selectedItem.y = _y; selectedItem = tempLeft.getChildAt(0) as Box; tempLeft.removeChildAt(0); loginViewStack.selectedChild.addChild(selectedItem); selectedItem.visible = true; selectedItem.y = _y; selectedItem = tempLeft.getChildAt(0) as Box; tempLeft.removeChildAt(0); loginViewStack.selectedChild.addChild(selectedItem); selectedItem.visible = true; selectedItem.y = _y; // Change TempLeft to Right! selectedItem = tempFront.getChildAt(0) as Box; tempFront.removeChildAt(0); (loginViewStack.getChildAt(_right) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.y = _y; selectedItem = tempFront.getChildAt(0) as Box; tempFront.removeChildAt(0); (loginViewStack.getChildAt(_right) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.y = _y; selectedItem = tempFront.getChildAt(0) as Box; tempFront.removeChildAt(0); (loginViewStack.getChildAt(_right) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.y = _y; tempViewStack.x = 0; tempViewStack.y = 0; tempViewStack.width = 1; tempViewStack.height = 1; selectedItem = null; tempViewStack.selectedIndex = 0; tempViewStack.visible = false; rotateCubeFull(); break; case "up": // Change Back to Bottom! selectedItem = locateChild(_back, 1, _Column); (loginViewStack.getChildAt(_back) as Canvas).removeChild(selectedItem); (loginViewStack.getChildAt(_bottom) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.x = _x; selectedItem = locateChild(_back, 2, _Column); (loginViewStack.getChildAt(_back) as Canvas).removeChild(selectedItem); (loginViewStack.getChildAt(_bottom) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.x = _x; selectedItem = locateChild(_back, 3, _Column); (loginViewStack.getChildAt(_back) as Canvas).removeChild(selectedItem); (loginViewStack.getChildAt(_bottom) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.x = _x; // Change Top to Back! selectedItem = locateChild(_top, 1, _Column); (loginViewStack.getChildAt(_top) as Canvas).removeChild(selectedItem); (loginViewStack.getChildAt(_back) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.x = _x; selectedItem = locateChild(_top, 2, _Column); (loginViewStack.getChildAt(_top) as Canvas).removeChild(selectedItem); (loginViewStack.getChildAt(_back) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.x = _x; selectedItem = locateChild(_top, 3, _Column); (loginViewStack.getChildAt(_top) as Canvas).removeChild(selectedItem); (loginViewStack.getChildAt(_back) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.x = _x; // Change TempSelected to Front! selectedItem = tempLeft.getChildAt(0) as Box; tempLeft.removeChild(selectedItem); loginViewStack.selectedChild.addChild(selectedItem); selectedItem.visible = true; selectedItem.x = _x; selectedItem = tempLeft.getChildAt(0) as Box; tempLeft.removeChild(selectedItem); loginViewStack.selectedChild.addChild(selectedItem); selectedItem.visible = true; selectedItem.x = _x; selectedItem = tempLeft.getChildAt(0) as Box; tempLeft.removeChild(selectedItem); loginViewStack.selectedChild.addChild(selectedItem); selectedItem.visible = true; selectedItem.x = _x; // Change TempLeft to Top! selectedItem = tempFront.getChildAt(0) as Box; tempFront.removeChild(selectedItem); (loginViewStack.getChildAt(_top) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.x = _x; selectedItem = tempFront.getChildAt(0) as Box; tempFront.removeChild(selectedItem); (loginViewStack.getChildAt(_top) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.x = _x; selectedItem = tempFront.getChildAt(0) as Box; tempFront.removeChild(selectedItem); (loginViewStack.getChildAt(_top) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.x = _x; tempViewStack.x = 0; tempViewStack.y = 0; tempViewStack.width = 1; tempViewStack.height = 1; selectedItem = null; tempViewStack.selectedIndex = 0; tempViewStack.visible = false; rotateCubeFull(); break; case "down": // Change Back to Top! selectedItem = locateChild(_back, 1, _Column); (loginViewStack.getChildAt(_back) as Canvas).removeChild(selectedItem); (loginViewStack.getChildAt(_top) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.x = _x; selectedItem = locateChild(_back, 2, _Column); (loginViewStack.getChildAt(_back) as Canvas).removeChild(selectedItem); (loginViewStack.getChildAt(_top) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.x = _x; selectedItem = locateChild(_back, 3, _Column); (loginViewStack.getChildAt(_back) as Canvas).removeChild(selectedItem); (loginViewStack.getChildAt(_top) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.x = _x; // Change Bottom to Back! selectedItem = locateChild(_bottom, 1, _Column); (loginViewStack.getChildAt(_bottom) as Canvas).removeChild(selectedItem); (loginViewStack.getChildAt(_back) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.x = _x; selectedItem = locateChild(_bottom, 2, _Column); (loginViewStack.getChildAt(_bottom) as Canvas).removeChild(selectedItem); (loginViewStack.getChildAt(_back) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.x = _x; selectedItem = locateChild(_bottom, 3, _Column); (loginViewStack.getChildAt(_bottom) as Canvas).removeChild(selectedItem); (loginViewStack.getChildAt(_back) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.x = _x; // Change TempSelected to Front! selectedItem = tempLeft.getChildAt(0) as Box; tempLeft.removeChild(selectedItem); loginViewStack.selectedChild.addChild(selectedItem); selectedItem.visible = true; selectedItem.x = _x; selectedItem = tempLeft.getChildAt(0) as Box; tempLeft.removeChild(selectedItem); loginViewStack.selectedChild.addChild(selectedItem); selectedItem.visible = true; selectedItem.x = _x; selectedItem = tempLeft.getChildAt(0) as Box; tempLeft.removeChild(selectedItem); loginViewStack.selectedChild.addChild(selectedItem); selectedItem.visible = true; selectedItem.x = _x; // Change TempLeft to Bottom! selectedItem = tempFront.getChildAt(0) as Box; tempFront.removeChild(selectedItem); (loginViewStack.getChildAt(_bottom) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.x = _x; selectedItem = tempFront.getChildAt(0) as Box; tempFront.removeChild(selectedItem); (loginViewStack.getChildAt(_bottom) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.x = _x; selectedItem = tempFront.getChildAt(0) as Box; tempFront.removeChild(selectedItem); (loginViewStack.getChildAt(_bottom) as Canvas).addChild(selectedItem); selectedItem.visible = true; selectedItem.x = _x; tempViewStack.x = 0; tempViewStack.y = 0; tempViewStack.width = 1; tempViewStack.height = 1; selectedItem = null; tempViewStack.selectedIndex = 0; tempViewStack.visible = false; rotateCubeFull(); break; } } ]]> </mx:Script> </mx:VBox>
(C) Æliens 27/08/2009
You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.