ok...
este es el codigo de una parte del codigo del cubo... esta dividido en 3 archivos(.as) y se mandan llamar desde un archivo en blanco (flash)... Los archivos estan divididos para tener un mejor orden de trabajar... los otros no tienen nada que ver con el texto... este es el as que contiene todo el texto.
NOTA: No me molesta publicar mi codigo, alcontrario si les ayuda a alguien mas me sentiria muy bien =) pero en esta ocacion no lo veo muy necesario
ok bueno el siguiente codigo es el formato de las caras del cubo (colores y todo ese rollo y el formato del texto)
Código ActionScript :
package com.flashandmath.bitmaps {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.geom.Matrix;
import flash.geom.Point;
import com.flashandmath.bitmaps.ImageLoader;
import com.flashandmath.bitmaps.BitmapTransformer;
public class CubeMenu extends Sprite {
private var imgLoader:ImageLoader;
private var errorBox:TextField;
private var bitmap:BitmapData;
private var bd0:BitmapData;
private var bd1:BitmapData;
private var bd2:BitmapData;
private var bd3:BitmapData;
private var bd4:BitmapData;
private var bd5:BitmapData;
private var bdTransform:BitmapTransformer;
private var vertsArray:Array;
private var facesArray:Array;
private var numVertices:uint;
private var numFaces:uint;
private var boardSize:Number;
private var spBoard:Sprite;
private var shBack:Shape;
private var spCube:Sprite;
private var doRotate:Boolean;
private var prevX:Number;
private var prevY:Number;
private var curTheta:Number;
private var curPhi:Number;
private var cubeSize:Number;
public var fLen:Number;
public var side0:Sprite;
public var side1:Sprite;
public var side2:Sprite;
public var side3:Sprite;
public var side4:Sprite;
public var side5:Sprite;
private var infoBox:TextField;
public function CubeMenu(imgs:Array,size:Number) {
cubeSize=size;
boardSize=2*cubeSize+20;
setUpInfoBox();
fLen=500;
spBoard=new Sprite();
this.addChild(spBoard);
shBack=new Shape();
spBoard.addChild(shBack);
spCube=new Sprite();
spBoard.addChild(spCube);
spCube.x=boardSize/2;
spCube.y=boardSize/2;
side0=new Sprite();
spCube.addChild(side0);
side1=new Sprite();
spCube.addChild(side1);
side2=new Sprite();
spCube.addChild(side2);
side3=new Sprite();
spCube.addChild(side3);
side4=new Sprite();
spCube.addChild(side4);
side5=new Sprite();
spCube.addChild(side5);
side0.doubleClickEnabled=true;
side1.doubleClickEnabled=true;
side2.doubleClickEnabled=true;
side3.doubleClickEnabled=true;
side4.doubleClickEnabled=true;
side5.doubleClickEnabled=true;
doRotate=false;
curTheta=20;
curPhi=70;
drawBack(0x000000,0x333333,0,boardSize);
prepErrorBox();
prepImgs(imgs);
}
private function drawBack(b:Number,r:Number,t:Number,s:Number):void {
shBack.graphics.clear();
shBack.graphics.lineStyle(t,r);
shBack.graphics.beginFill(b);
shBack.graphics.drawRect(0,0,s,s);
shBack.graphics.endFill();
}
private function prepErrorBox():void {
errorBox=new TextField();
this.addChild(errorBox);
errorBox.wordWrap=true;
errorBox.mouseEnabled=false;
errorBox.background=false;
errorBox.border=false;
setErrorBoxSizeAndPos(300,100,20,20);
setErrorBoxFormat(0x999999,14);
errorBox.text="Cargando...";
errorBox.visible=true;
}
private function prepImgs(a:Array):void {
imgLoader=new ImageLoader();
imgLoader.addEventListener(ImageLoader.LOAD_ERROR,errorLoading);
imgLoader.addEventListener(ImageLoader.IMGS_LOADED,allLoaded);
imgLoader.loadImgs(a);
}
private function errorLoading(e:Event):void {
errorBox.visible=true;
errorBox.text="Error en la carga de datos o el servidor se encuentra ocupado, intente refrescar la página.";
}
private function allLoaded(e:Event):void {
errorBox.visible=false;
initApp();
}
private function initApp():void {
var imgsSize:Number;
var tx:TextField = new TextField();
var tx1:TextField = new TextField();
var tx2:TextField = new TextField();
var tx3:TextField = new TextField();
var tx4:TextField = new TextField();
var tx5:TextField = new TextField();
var tf:TextFormat = new TextFormat();
// da formato al texto
tf.size = 30;
tf.color = 0xffffff;
tf.align = TextFormatAlign.CENTER;
tx.defaultTextFormat = tf;
tx.width = 200;// - (200*2);
tx.selectable = false;
tx.height = 220;// - (220*2);
tx.borderColor = 0xffffff;
//tx.border = 3;
tx1.defaultTextFormat = tf;
tx1.width = 200;// - (200*2);
tx1.selectable = false;
tx1.height = 220;// - (220*2);
tx1.borderColor = 0xffffff;
//tx1.border = 3;
tx2.defaultTextFormat = tf;
tx2.width = 200;// - (200*2);
tx2.selectable = false;
tx2.height = 220 ;//- (220*2);
tx2.borderColor = 0xffffff;
//tx2.border = 3;
tx3.defaultTextFormat = tf;
tx3.width = 200;// - (200*2);
tx3.selectable = false;
tx3.height = 220;// - (220*2);
tx3.borderColor = 0xffffff;
//tx3.border = 3;
tx4.defaultTextFormat = tf;
tx4.width = 200;// - (200*2);
tx4.selectable = false;
tx4.height = 220;// - (220*2);
tx4.borderColor = 0xffffff;
//tx4.border = 3;
tx5.defaultTextFormat = tf;
tx5.width = 200;// - (200*2);
tx5.selectable = false;
tx5.height = 220;// - (220*2);
tx5.borderColor = 0xffffff;
//tx5.border = 3;
// set the default text content
tx.text = "Personas";
tx1.text = "Esquemas de fraude";
tx2.text = "Proyectos";
tx3.text = "Incidentes de fraude";
tx4.text = "Negocio";
tx5.text = "50";
// render to a bitmap
var bitmapData:BitmapData = new BitmapData(200, 220, false, 0x000033 );
var bitmapData1:BitmapData = new BitmapData(200, 220, false, 0x000033);
var bitmapData2:BitmapData = new BitmapData(200, 220, false, 0x000033);
var bitmapData3:BitmapData = new BitmapData(200, 220, false, 0x000033);
var bitmapData4:BitmapData = new BitmapData(200, 220, false, 0x000033);
var bitmapData5:BitmapData = new BitmapData(200, 220, false, 0x000033);
bitmapData.draw(tx);
bitmapData1.draw(tx1);
bitmapData2.draw(tx2);
bitmapData3.draw(tx3);
bitmapData4.draw(tx4);
bitmapData5.draw(tx5);
var bitmap:Bitmap = new Bitmap();
var bitmap1:Bitmap = new Bitmap();
var bitmap2:Bitmap = new Bitmap();
var bitmap3:Bitmap = new Bitmap();
var bitmap4:Bitmap = new Bitmap();
var bitmap5:Bitmap = new Bitmap();
bitmap.bitmapData = bitmapData;
bitmap.smoothing = true;
bitmap1.bitmapData = bitmapData1;
bitmap1.smoothing = true;
bitmap2.bitmapData = bitmapData2;
bitmap2.smoothing = true;
bitmap3.bitmapData = bitmapData3;
bitmap3.smoothing = true;
bitmap4.bitmapData = bitmapData4;
bitmap4.smoothing = true;
bitmap5.bitmapData = bitmapData5;
bitmap5.smoothing = true;
//addChild(bitmap);
bd0=bitmap.bitmapData;
bd1=bitmap1.bitmapData;
bd2=bitmap2.bitmapData;
bd3=bitmap3.bitmapData;
bd4=bitmap4.bitmapData;
bd5=bitmap5.bitmapData;
imgsSize=bd0.width;
bdTransform=new BitmapTransformer(imgsSize,imgsSize,20,20);
vertsArray=[];
facesArray=[];
numVertices=8;
numFaces=6;
setVertices();
setFaces();
renderView(curTheta,curPhi);
setUpListeners();
}
private function setVertices():void {
vertsArray[0]=[cubeSize/1.7,-cubeSize/1.7,cubeSize/1.7];
vertsArray[1]=[cubeSize/1.7,cubeSize/1.7,cubeSize/1.7];
vertsArray[2]=[-cubeSize/1.7,cubeSize/1.7,cubeSize/1.7];
vertsArray[3]=[-cubeSize/1.7,-cubeSize/1.7,cubeSize/1.7];
vertsArray[4]=[cubeSize/1.7,-cubeSize/1.7,-cubeSize/1.7];
vertsArray[5]=[cubeSize/1.7,cubeSize/1.7,-cubeSize/1.7];
vertsArray[6]=[-cubeSize/1.7,cubeSize/1.7,-cubeSize/1.7];
vertsArray[7]=[-cubeSize/1.7,-cubeSize/1.7,-cubeSize/1.7];
}
private function setFaces():void {
facesArray[0]=[0,1,5,4,bd0];
facesArray[1]=[1,2,6,5,bd1];
facesArray[2]=[2,3,7,6,bd2];
facesArray[3]=[3,0,4,7,bd3];
facesArray[4]=[4,5,6,7,bd4];
facesArray[5]=[3,2,1,0,bd5];
}
private function setUpListeners():void {
imgLoader.removeEventListener(ImageLoader.LOAD_ERROR,errorLoading);
imgLoader.removeEventListener(ImageLoader.IMGS_LOADED,allLoaded);
spBoard.addEventListener(MouseEvent.ROLL_OUT,boardOut);
spBoard.addEventListener(MouseEvent.MOUSE_MOVE,boardMove);
spBoard.addEventListener(MouseEvent.MOUSE_DOWN,boardDown);
spBoard.addEventListener(MouseEvent.MOUSE_UP,boardUp);
side0.addEventListener(MouseEvent.CLICK,side0Clicked);
side1.addEventListener(MouseEvent.CLICK,side1Clicked);
side2.addEventListener(MouseEvent.CLICK,side2Clicked);
side3.addEventListener(MouseEvent.CLICK,side3Clicked);
side4.addEventListener(MouseEvent.CLICK,side4Clicked);
side5.addEventListener(MouseEvent.CLICK,side5Clicked);
}
private function boardOut(e:MouseEvent):void {
doRotate=false;
}
private function boardDown(e:MouseEvent):void {
prevX=spBoard.mouseX;
prevY=spBoard.mouseY;
doRotate=true;
}
private function boardUp(e:MouseEvent):void {
doRotate=false;
}
private function boardMove(e:MouseEvent):void {
var locX:Number=prevX;
var locY:Number=prevY;
if(doRotate){
prevX=spBoard.mouseX;
prevY=spBoard.mouseY;
curTheta+=(prevX-locX);
curPhi+=(prevY-locY);
renderView(curTheta,curPhi);
e.updateAfterEvent();
}
}
private function side0Clicked(e:MouseEvent):void {
curTheta=0;
curPhi=90;
renderView(curTheta,curPhi);
infoBox.text="ESQUEMAS DE FRAUDE";
}
private function side1Clicked(e:MouseEvent):void {
curTheta=-270;
curPhi=90;
renderView(curTheta,curPhi);
infoBox.text="PROYECTOS";
}
private function side2Clicked(e:MouseEvent):void {
curTheta=-180;
curPhi=90;
renderView(curTheta,curPhi);
infoBox.text="NEGOCIO";
}
private function side3Clicked(e:MouseEvent):void {
curTheta=-90;
curPhi=90;
renderView(curTheta,curPhi);
infoBox.text="PERSONAS";
}
private function side4Clicked(e:MouseEvent):void {
curTheta=0;
curPhi=-180;
renderView(curTheta,curPhi);
infoBox.text="INCIDENTES DE FRAUDE";
}
private function side5Clicked(e:MouseEvent):void {
curTheta=0;
curPhi=0;
renderView(curTheta,curPhi);
infoBox.text="CIFRAS";
}
private function setUpInfoBox():void {
var infoFormat:TextFormat=new TextFormat();
infoBox=new TextField();
this.addChild(infoBox);
infoBox.x=347;
infoBox.y=165;
infoBox.width=255;
infoBox.height=100;
infoBox.wordWrap=true;
infoBox.mouseEnabled=false;
infoFormat.color=0x000987;
infoFormat.align="center";
infoFormat.size=14;
infoFormat.font="Bell Gothic Std";
infoBox.defaultTextFormat=infoFormat;
}
private function renderView(t:Number,p:Number):void {
var i:int;
var distArray=[];
var dispArray=[];
var vertsNewArray=[];
var midPoint:Array=[];
var curv0:Array=[];
var curv1:Array=[];
var curv2:Array=[];
var curv3:Array=[];
var curImg:BitmapData;
var dist:Number;
var curFace:uint;
t=t*Math.PI/180;
p=p*Math.PI/180;
side0.graphics.clear();
side1.graphics.clear();
side2.graphics.clear();
side3.graphics.clear();
side4.graphics.clear();
side5.graphics.clear();
for(i=0;i<numVertices;i++){
vertsNewArray[i]=pointNewView(vertsArray[i],t,p);
}
for(i=0;i<numFaces;i++){
midPoint[0]=(vertsNewArray[facesArray[i][0]][0]+vertsNewArray[facesArray[i][1]][0]+vertsNewArray[facesArray[i][2]][0]+vertsNewArray[facesArray[i][3]][0])/4;
midPoint[1]=(vertsNewArray[facesArray[i][0]][1]+vertsNewArray[facesArray[i][1]][1]+vertsNewArray[facesArray[i][2]][1]+vertsNewArray[facesArray[i][3]][1])/4;
midPoint[2]=(vertsNewArray[facesArray[i][0]][2]+vertsNewArray[facesArray[i][1]][2]+vertsNewArray[facesArray[i][2]][2]+vertsNewArray[facesArray[i][3]][2])/4;
dist=Math.sqrt(Math.pow(fLen-midPoint[0],2)+Math.pow(midPoint[1],2)+Math.pow(midPoint[2],2));
distArray[i]=[dist,i];
}
distArray.sort(byDist);
for(i=0;i<numVertices;i++){
dispArray[i]=[fLen/(fLen-vertsNewArray[i][0])*vertsNewArray[i][1],-fLen/(fLen-vertsNewArray[i][0])*vertsNewArray[i][2]];
}
for(i=3;i<numFaces;i++){
curFace=distArray[i][1];
curv0=[dispArray[facesArray[curFace][0]][0],dispArray[facesArray[curFace][0]][1]];
curv1=[dispArray[facesArray[curFace][1]][0],dispArray[facesArray[curFace][1]][1]];
curv2=[dispArray[facesArray[curFace][2]][0],dispArray[facesArray[curFace][2]][1]];
curv3=[dispArray[facesArray[curFace][3]][0],dispArray[facesArray[curFace][3]][1]];
curImg=facesArray[curFace][4];
spCube.setChildIndex(this["side"+String(curFace)],spCube.numChildren-1);
bdTransform.mapBitmapData(curImg,new Point(curv0[0],curv0[1]),new Point(curv1[0],curv1[1]),new Point(curv2[0],curv2[1]),new Point(curv3[0],curv3[1]),this["side"+String(curFace)]);
}
}
private function byDist(v:Array,w:Array):Number {
if (v[0]>w[0]){
return -1;
} else if (v[0]<w[0]){
return 1;
} else {
return 0;
}
}
private function pointNewView(v:Array,theta:Number,phi:Number):Array {
var newCoords:Array=[];
newCoords[0]=v[0]*Math.cos(theta)*Math.sin(phi)+v[1]*Math.sin(theta)*Math.sin(phi)+v[2]*Math.cos(phi);
newCoords[1]=-v[0]*Math.sin(theta)+v[1]*Math.cos(theta);
newCoords[2]=-v[0]*Math.cos(theta)*Math.cos(phi)-v[1]*Math.sin(theta)*Math.cos(phi)+v[2]*Math.sin(phi);
return newCoords;
}
public function setErrorBoxSizeAndPos(w:Number,h:Number,a:Number,b:Number): void {
errorBox.width=w;
errorBox.height=h;
errorBox.x=a;
errorBox.y=b;
}
public function setErrorBoxFormat(colo:Number,s:Number): void {
var errorFormat:TextFormat=new TextFormat();
errorFormat.color=colo;
errorFormat.size=s;
errorFormat.font="Arial";
errorBox.defaultTextFormat=errorFormat;
}
public function setBackLook(b:Number,r:Number,t:Number): void {
drawBack(b,r,t,boardSize);
}
}
}