Olá pessoal, estou testando um novo aplicativo para o Twitter, é o TwitterFeed.
E sobre novos posts e tutoriais... Estou analisando alguns bons assuntos. Em breve terão novidades...
Se tiverem idéias, enviem para idemax@gmail.com.
public function Main()
{
stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMoveHandler);
}
private function onMouseMoveHandler($event:MouseEvent):void
{
graphics.clear();
rotateEye(eye1);
rotateEye(eye2);
$event.updateAfterEvent();
}
var catAdj:Number = mouseX - $eye.x;
var catOp:Number = mouseY - $eye.y;
var hipot:Number = Math.sqrt((catAdj * catAdj) + (catOp * catOp));
var radians:Number = Math.asin(catOp / hipot);
var degree:Number = radians * (180 / Math.PI);
if (catAdj >= 0)
{
$eye.rotation = degree;
}
else
{
$eye.rotation = 180 - degree;
}
log.text = 'catAdj: ' + catAdj;
log.appendText('\ncatOp: ' + catOp);
log.appendText('\nhipot: ' + hipot);
log.appendText('\nradians: ' + radians);
log.appendText('\ndegree: ' + degree);
graphics.lineStyle(1, 0xff0000);
graphics.moveTo($eye.x, $eye.y);
graphics.lineTo(mouseX, mouseY);
graphics.lineStyle(1, 0xcccccc);
graphics.lineTo(mouseX, $eye.y);
graphics.lineTo($eye.x, $eye.y);
private function rotateEye($eye:MovieClip):void
{
var catAdj:Number = mouseX - $eye.x;
var catOp:Number = mouseY - $eye.y;
var hipot:Number = Math.sqrt((catAdj * catAdj) + (catOp * catOp));
var radians:Number = Math.asin(catOp / hipot);
var degree:Number = radians * (180 / Math.PI);
if (catAdj >= 0)
{
$eye.rotation = degree;
}
else
{
$eye.rotation = 180 - degree;
}
log.text = 'catAdj: ' + catAdj;
log.appendText('\ncatOp: ' + catOp);
log.appendText('\nhipot: ' + hipot);
log.appendText('\nradians: ' + radians);
log.appendText('\ndegree: ' + degree);
graphics.lineStyle(1, 0xff0000);
graphics.moveTo($eye.x, $eye.y);
graphics.lineTo(mouseX, mouseY);
graphics.lineStyle(1, 0xcccccc);
graphics.lineTo(mouseX, $eye.y);
graphics.lineTo($eye.x, $eye.y);
}
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.text.TextField;
/**
* ...
* @author www.idemax.net
*/
public class Main extends MovieClip
{
public var eye1:MovieClip;
public var eye2:MovieClip;
public var log:TextField;
public function Main()
{
stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMoveHandler);
}
private function onMouseMoveHandler($event:MouseEvent):void
{
graphics.clear();
rotateEye(eye1);
rotateEye(eye2);
$event.updateAfterEvent();
}
private function rotateEye($eye:MovieClip):void
{
var catAdj:Number = mouseX - $eye.x;
var catOp:Number = mouseY - $eye.y;
var hipot:Number = Math.sqrt((catAdj * catAdj) + (catOp * catOp));
var radians:Number = Math.asin(catOp / hipot);
var degree:Number = radians * (180 / Math.PI);
if (catAdj >= 0)
{
$eye.rotation = degree;
}
else
{
$eye.rotation = 180 - degree;
}
log.text = 'catAdj: ' + catAdj;
log.appendText('\ncatOp: ' + catOp);
log.appendText('\nhipot: ' + hipot);
log.appendText('\nradians: ' + radians);
log.appendText('\ndegree: ' + degree);
graphics.lineStyle(1, 0xff0000);
graphics.moveTo($eye.x, $eye.y);
graphics.lineTo(mouseX, mouseY);
graphics.lineStyle(1, 0xcccccc);
graphics.lineTo(mouseX, $eye.y);
graphics.lineTo($eye.x, $eye.y);
}
}
}
package
{
import fl.controls.Slider;
import fl.events.SliderEvent;
import flash.display.MovieClip;
/**
* ...
* @author www.idemax.net
*/
public class Main extends MovieClip
{
public var avatar:MovieClip;
public var xAxis:Slider;
public var yAxis:Slider;
public var zAxis:Slider;
public function Main()
{
xAxis.addEventListener(SliderEvent.CHANGE, onSliderChange);
yAxis.addEventListener(SliderEvent.CHANGE, onSliderChange);
zAxis.addEventListener(SliderEvent.CHANGE, onSliderChange);
}
private function onSliderChange(event:SliderEvent):void
{
var slider:Slider = event.target as Slider;
switch(slider)
{
case xAxis:
avatar.rotationX = slider.value;
break;
case yAxis:
avatar.rotationY = slider.value;
break;
case zAxis:
avatar.rotationZ = slider.value;
break;
}
}
}
}
package
{
import flash.events.Event;
/**
* ...
* @author www.idemax.net
*/
public class MeuEvento extends Event
{
public static const GIRAR_ELEMENTO:String = 'girarElemento';
public function MeuEvento(type:String, bubbles:Boolean=false, cancelable:Boolean=false)
{
super(type, bubbles, cancelable);
}
}
}
public var instancia:String;
public var elemento:MovieClip;
package
{
import flash.display.MovieClip;
import flash.events.Event;
/**
* ...
* @author www.idemax.net
*/
public class MeuEvento extends Event
{
public static const GIRAR_ELEMENTO:String = 'girarElemento';
public var instancia:String;
public var elemento:MovieClip;
public function MeuEvento(type:String, bubbles:Boolean=false, cancelable:Boolean=false)
{
super(type, bubbles, cancelable);
}
}
}
public function Main()
{
addEventListener(MeuEvento.GIRAR_ELEMENTO, onGirarElementoHandler);
btnAzul.addEventListener(MouseEvent.CLICK, onBtnClick);
btnVerde.addEventListener(MouseEvent.CLICK, onBtnClick);
btnVermelho.addEventListener(MouseEvent.CLICK, onBtnClick);
}
var buttonClicked:Button = event.target as Button;
var evt:MeuEvento = new MeuEvento(MeuEvento.GIRAR_ELEMENTO);
switch(buttonClicked)
{
case btnAzul:
evt.elemento = azul;
break;
case btnVerde:
evt.instancia = 'verde';
break;
case btnVermelho:
evt.elemento = vermelho;
break;
}
dispatchEvent(evt);
private function onBtnClick(event:MouseEvent):void
{
var buttonClicked:Button = event.target as Button;
var evt:MeuEvento = new MeuEvento(MeuEvento.GIRAR_ELEMENTO);
switch(buttonClicked)
{
case btnAzul:
evt.elemento = azul;
break;
case btnVerde:
evt.instancia = 'verde';
break;
case btnVermelho:
evt.elemento = vermelho;
break;
}
dispatchEvent(evt);
}
if (event.elemento == null && event.instancia == null) return; // Se não for declarado algum elemento para ser girado
if (event.elemento != null && event.instancia != null) return; // Se os dois argumentos forem declarados, deve-se escolher um
var girarElemento:MovieClip;
if (event.elemento != null)
{
girarElemento = event.elemento as MovieClip;
}
else if (event.instancia != null)
{
girarElemento = this[event.instancia as String] as MovieClip;
}
girarElemento.rotation = Math.random() * 360;
private function onGirarElementoHandler(event:MeuEvento):void
{
if (event.elemento == null && event.instancia == null) return; // Se não for declarado algum elemento para ser girado
if (event.elemento != null && event.instancia != null) return; // Se os dois argumentos forem declarados, deve-se escolher um
var girarElemento:MovieClip;
if (event.elemento != null)
{
girarElemento = event.elemento as MovieClip;
}
else if (event.instancia != null)
{
girarElemento = this[event.instancia as String] as MovieClip;
}
girarElemento.rotation = Math.random() * 360;
}
package
{
import fl.controls.Button;
import flash.display.MovieClip;
import flash.events.MouseEvent;
/**
* ...
* @author www.idemax.net
*/
public class Main extends MovieClip
{
public var vermelho:MovieClip;
public var verde:MovieClip;
public var azul:MovieClip;
public var btnVermelho:Button;
public var btnVerde:Button;
public var btnAzul:Button;
public function Main()
{
addEventListener(MeuEvento.GIRAR_ELEMENTO, onGirarElementoHandler);
btnAzul.addEventListener(MouseEvent.CLICK, onBtnClick);
btnVerde.addEventListener(MouseEvent.CLICK, onBtnClick);
btnVermelho.addEventListener(MouseEvent.CLICK, onBtnClick);
}
private function onBtnClick(event:MouseEvent):void
{
var buttonClicked:Button = event.target as Button;
var evt:MeuEvento = new MeuEvento(MeuEvento.GIRAR_ELEMENTO);
switch(buttonClicked)
{
case btnAzul:
evt.elemento = azul;
break;
case btnVerde:
evt.instancia = 'verde';
break;
case btnVermelho:
evt.elemento = vermelho;
break;
}
dispatchEvent(evt);
}
private function onGirarElementoHandler(event:MeuEvento):void
{
if (event.elemento == null && event.instancia == null) return; // Se não for declarado algum elemento para ser girado
if (event.elemento != null && event.instancia != null) return; // Se os dois argumentos forem declarados, deve-se escolher um
var girarElemento:MovieClip;
if (event.elemento != null)
{
girarElemento = event.elemento as MovieClip;
}
else if (event.instancia != null)
{
girarElemento = this[event.instancia as String] as MovieClip;
}
girarElemento.rotation = Math.random() * 360;
}
}
}
public class MeuEvento extends Event
public static const GIRAR_FORMA_AZUL:String = 'girarFormaAzul';
public static const GIRAR_FORMA_VERMELHA:String = 'girarFormaVermelha';
package
{
import flash.events.Event;
/**
* ...
* @author www.idemax.net
*/
public class MeuEvento extends Event
{
public static const GIRAR_FORMA_AZUL:String = 'girarFormaAzul';
public static const GIRAR_FORMA_VERMELHA:String = 'girarFormaVermelha';
public function MeuEvento(type:String, bubbles:Boolean=false, cancelable:Boolean=false)
{
super(type, bubbles, cancelable);
}
}
}
public class Main extends MovieClip
botao.addEventListener(MouseEvent.CLICK, onClickBotao);
addEventListener(MeuEvento.GIRAR_FORMA_AZUL, girarFormaAzul);
addEventListener(MeuEvento.GIRAR_FORMA_VERMELHA, girarFormaVermelha);
private function onClickBotao(event:MouseEvent):void
{
switch(radioButtonGroup.selection.value)
{
case 'forma1':
dispatchEvent(new MeuEvento(MeuEvento.GIRAR_FORMA_AZUL));
break;
case 'forma2':
dispatchEvent(new MeuEvento(MeuEvento.GIRAR_FORMA_VERMELHA));
break;
}
}
private function girarFormaAzul(event:MeuEvento):void
{
forma1.rotation += 45;
}
private function girarFormaVermelha(event:MeuEvento):void
{
forma2.rotation -= 45;
}
package
{
import fl.controls.Button;
import fl.controls.CheckBox;
import fl.controls.RadioButton;
import fl.controls.RadioButtonGroup;
import flash.display.MovieClip;
import flash.events.MouseEvent;
/**
* ...
* @author www.idemax.net
*/
public class Main extends MovieClip
{
public var botao:Button;
public var radioButtonGroup:RadioButtonGroup = new RadioButtonGroup('radioButtonGroup');
public var radioButtonAzul:RadioButton;
public var radioButtonVermelho:RadioButton;
public var forma1:MovieClip;
public var forma2:MovieClip;
public function Main()
{
addEventListener(MeuEvento.GIRAR_FORMA_AZUL, girarFormaAzul);
addEventListener(MeuEvento.GIRAR_FORMA_VERMELHA, girarFormaVermelha);
botao.addEventListener(MouseEvent.CLICK, onClickBotao);
}
private function onClickBotao(event:MouseEvent):void
{
switch(radioButtonGroup.selection.value)
{
case 'forma1':
dispatchEvent(new MeuEvento(MeuEvento.GIRAR_FORMA_AZUL));
break;
case 'forma2':
dispatchEvent(new MeuEvento(MeuEvento.GIRAR_FORMA_VERMELHA));
break;
}
}
private function girarFormaAzul(event:MeuEvento):void
{
forma1.rotation += 45;
}
private function girarFormaVermelha(event:MeuEvento):void
{
forma2.rotation -= 45;
}
}
}