Comunidad de diseño web y desarrollo en internet online

resumir formula

Citar            
MensajeEscrito el 07 Nov 2008 10:23 pm
Hola me ayudarian a simplificar esta formulita xfa!... algun Math.Plus, es k en eso de razonamientos ando meo mal! :oops:

Código PHP :

   scX = Stage.width;

   ec1 = (_xmouse * 100)/scX;
   diffX = Number((ec1/100) * scX)/5;

   this._x =  diffX;


GraXs!

Por comicSans

Claber

151 de clabLevel



 

firefox
Citar            
MensajeEscrito el 08 Nov 2008 12:07 am

Código ActionScript :

this._x = _xmouse/5


saludos

Por Maikel

BOFH

5575 de clabLevel

22 tutoriales
5 articulos

Genero:Masculino   Team Cristalab

Claber de baja indefinida

firefox
Citar            
MensajeEscrito el 10 Nov 2008 03:21 pm
Tiene razon Maikel
porque el 100 multiplica primero y luego divide, por lo tanto se anula
y la variable scX primero divide y luego multiplica, por lo tanto tambien se anula
por lo que te queda solo dividir con 5

Pero creo que algo intentabas hacer pero no te salio bien, entonces explica que es lo que intentas hacer...

Por gabynufe

Claber

446 de clabLevel



 

México, D.F.

msie7
Citar            
MensajeEscrito el 10 Nov 2008 09:16 pm
gracias Maikel, gabynufe. Bueno, a lo mejor es algo un poco ocioso pero me intentaba crear desde cero algo asi como mover objetos en perspectiva y la vdd ya no me gusto como va este asunto. Les posteo este codiguin, les comento que no esta funcionando bien, tengo problemas xq principalmente no se si cuando mueves objetos en perspectiva que sea mejor: usarcomo siempre la esquina superior izquierda como punto de inicio, o el centro del escenario(o algun punto x,y, como punto de fuga)

Sus comentarios me ayudaran bastante!:

Código PHP :

// solo apoyo grafico ;)
_root.lineStyle(1, 0xEFEFEF, 100);
_root.moveTo(Stage.width/2, 0);
_root.lineTo(Stage.width/2, Stage.height);
_root.moveTo(0, Stage.height/2);
_root.lineTo(Stage.width, Stage.height/2);
// un objeto en stage
_root.createEmptyMovieClip('sq1', _root.getNextHighestDepth());
sq1.beginFill(0xCC00FF, 30);
sq1.lineStyle(1, 0xFF00FF, 100);
sq1.moveTo(0, 0);
sq1.lineTo(100, 0);
sq1.lineTo(100, 10);
sq1.lineTo(0, 10);
sq1.endFill();
sq1._y = random(Stage.height/2);
sq1._x = random(Stage.width/2);
// guarda posiciones del mclip respecto a stage
stayX = sq1._x;
stayY = sq1._y;
// mientras es arrastrado! ...que feo se oyo (presionado/soltado)
activado = false;
// a moverlo!!
this.onMouseMove=function () {
if (!activado) {
p1 = Math.ceil((stayX * 100)/ Stage.width);
px1 = (p1<50) ? p1 % 50 : 50 - (p1 % 50);
px1 = (px1 < 2)? 2 : px1;
p1_txt= 'Ahorita sq1 esta ' + px1 + '% cerca del centro';
sq1._x = (sq1._x<Stage.width/2) ? stayX + _xmouse/px1 : (stayX - px1) + _xmouse/px1;
// ahora muevo Y
py1 = Math.ceil((stayY * 100)/ Stage.height);
py1 = (py1<50) ? py1 % 50 : 50 - (py1 % 50);
py1 = (py1 < 2)? 2 : py1;
sq1._y = (sq1._y<Stage.height/2) ? stayY + _ymouse/py1 : (stayY - py1) + _ymouse/py1;
}
}
// Activar btn
sq1.onPress = function () { this.startDrag(); activado = true; }
sq1.onRelease = sq1.onReleaseOutside = function () { 
p = Math.ceil((this._x * 100)/ Stage.width);
px = (p<50) ? p % 50 : 50 - (p % 50);
px = (px < 2)? 2 : px;
// vuelve a guardar posiciones
stayX = (this._x>=0) ? this._x : 1;
stayY = (this._y>=0) ? this._y : 1;
activado = false;
stopDrag();
}

Por comicSans

Claber

151 de clabLevel



 

firefox
Citar            
MensajeEscrito el 10 Nov 2008 10:30 pm
le pongo un poco mas:

Código PHP :

_root.createEmptyMovieClip('tool_mc', _root.getNextHighestDepth());
tool_mc.beginFill(0x00CCFF, 30);
tool_mc.lineStyle(1, 0xFF00CC, 100);
tool_mc.moveTo(0, 0);
tool_mc.lineTo(10, 0);
tool_mc.lineTo(10, 10);
tool_mc.lineTo(0, 10);
tool_mc.endFill();
tool_mc._y = random(Stage.height);
tool_mc._x = random(Stage.width/2);

tool_mc.onEnterFrame = function() {
   scX = Stage.width/2;
   scY = Stage.height/2;
   diffX = (_xmouse<=scX) ? (scX-_xmouse)/4 : -(_xmouse-scX)/4;
   diffY = (_ymouse<=scY) ? (scY-_ymouse)/10 : -(_ymouse-scY)/10;
   this._x = (_xmouse+diffX) - this._width/2;
   this._y = (_ymouse+diffY) - this._height/2;
   // distancia del objeto al mouse
   distX.text = 'X: ';
   distY.text = 'Y: ';
   //
   target_mc._x = this._x; // - (target_mc._width/2);
   target_mc._y = this._y; // - (target_mc._height/2);
};
//
this.createTextField("coords_txt", this.getNextHighestDepth(), 10, 10, 100, 22);
coords_txt.html = true;
coords_txt.multiline = true;
coords_txt.autoSize = true;
_root.createTextField('distX', _root.getNextHighestDepth(), 10, 60, 100, 22);
_root.createTextField('distY', _root.getNextHighestDepth(), 10, 85, 100, 22);

var mouseListener:Object = new Object();
mouseListener.onMouseMove = function() {
    var point:Object = {x:_xmouse, y:_ymouse};
    tool_mc.globalToLocal(point);
    var rowHeaders = "<b> &nbsp; \t</b><b>_x\t</b><b>_y</b>";
    var row_1 = "_root\t"+_xmouse+"\t"+_ymouse;
    var row_2 = "target_mc\t"+Math.abs(point.x)+"\t"+Math.abs(point.y);
    coords_txt.htmlText = "<textformat tabstops='[100, 150]'>";
    coords_txt.htmlText += rowHeaders;
    coords_txt.htmlText += row_1;
    coords_txt.htmlText += row_2;
    coords_txt.htmlText += "</textformat>";
};
Mouse.addListener(mouseListener);

Por comicSans

Claber

151 de clabLevel



 

firefox
Citar            
MensajeEscrito el 11 Nov 2008 08:59 pm
:( ....no me sale...

en serio nadie q me oriente un poco, miren les pongo aqui un fla de lo q estoy haciendo. Este es el AS:

Código PHP :

var myPoint:Object = {x:0, y:0}; // Create your generic point object.
this.attachMovie("square", "myMovieClip", this.getNextHighestDepth());
myMovieClip._xscale = myMovieClip._yscale = 50;
myMovieClip._x = Stage.width/2; // _x for movieclip x position
myMovieClip._y = 100; // _y for movieclip y position

myMovieClip.globalToLocal(myPoint);
trace ("x: " + myPoint.x); // output: -100
trace ("y: " + myPoint.y); // output: -100
//
//
this.onEnterFrame = function () {
   clip1._x = _xmouse/8;    // frente
   clip2._x = _xmouse/15;   // medio
   clip3._x = _xmouse/25;   // atras
   //
   vs1._x = Stage.width + _xmouse/16;
   vs2._x = Stage.width + _xmouse/30;
   vs3._x = Stage.width + (_xmouse/50);
   //
   sq2.globalToLocal(myPoint);
   // if (_xmouse<Stage.width/2) { trace ('lado izq'); }
   mover = (_xmouse<Stage.width/2) ? Math.abs(sq2._x - _xmouse) : sq2._xmouse;
   cant = Math.ceil(Math.abs((mover * 100)/(Stage.width/2))); // + ' %';
   // CANT es para ver q tan lejos estan los objetos del centro del escenario
   sq2._x = (Stage.width/2); // + _xmouse/(100 - cant);
   //
   //
}
stayX = sq1._x;
stayY = sq1._y;
activado = false;
this.onMouseMove=function () {
   // Obj 1
   if (!activado) {
   p1 = Math.ceil((stayX * 100)/ Stage.width);
   px1 = (p1<50) ? p1 % 50 : 50 - (p1 % 50);
   px1 = (px1 < 2)? 2 : px1;
   p1_txt= 'Ahorita sq1 esta ' + px1 + '% cerca del centro';
   sq1._x = (sq1._x<Stage.width/2) ? stayX + _xmouse/px1 : (stayX - px1) + _xmouse/px1;
   //
   py1 = Math.ceil((stayY * 100)/ Stage.height);
   py1 = (py1<50) ? py1 % 50 : 50 - (py1 % 50);
   py1 = (py1 < 2)? 2 : py1;
   //p1_txt= 'Ahorita sq1 esta ' + px1 + '% cerca del centro';
   sq1._y = (sq1._y<Stage.height/2) ? stayY + _ymouse/py1 : (stayY - py1) + _ymouse/py1;
   }
}
//
sq1.onPress = function () { this.startDrag(); activado = true; }
sq1.onRelease = sq1.onReleaseOutside = function () { 
p = Math.ceil((this._x * 100)/ Stage.width);
px = (p<50) ? p % 50 : 50 - (p % 50);
px = (px < 2)? 2 : px;
p_txt = this._name + 'esta en ' + px + '% (' + this._x + ')' + ' --> ' + px;
stayX = (this._x>=0) ? this._x : 1;
stayY = (this._y>=0) ? this._y : 1;
activado = false;
stopDrag();
}

Por comicSans

Claber

151 de clabLevel



 

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.