// This will hold the API player instance once it is initialized.
var player:Object;
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);
Security.allowDomain("www.youtube.com");
Security.allowDomain("s.ytimg.com");
Security.allowDomain("i.ytimg.com");
loader.load(new URLRequest("http://www.youtube.com/v/hWqIRY4sDRo?version=3"));
function onLoaderInit(event:Event):void {
addChild(loader);
loader.content.addEventListener("onReady", onPlayerReady);
loader.content.addEventListener("onError", onPlayerError);
loader.content.addEventListener("onStateChange", onPlayerStateChange);
loader.content.addEventListener("onPlaybackQualityChange", onVideoPlaybackQualityChange);
}
function onPlayerReady(event:Event):void {
trace("player ready:", Object(event).data);
player=loader.content;
player.setSize(240, 180);
player.playVideo();
}
function onPlayerError(event:Event):void {
trace("player error:", Object(event).data);
}
function onPlayerStateChange(event:Event):void {
trace("player state:", Object(event).data);
}
function onVideoPlaybackQualityChange(event:Event):void {
trace("video quality:", Object(event).data);
}
this.addEventListener(MouseEvent.CLICK,clicouGeral);
function clicouGeral(evt:MouseEvent) {
if (evt.target.name=="botao_apagar") {
loader.unloadAndStop();
removeChild(loader);
}
if (evt.target.name=="botao_pause") {
player.pauseVideo();
}
if (evt.target.name=="botao_play") {
player.playVideo();
}
}
quarta-feira, 28 de dezembro de 2011
AS3 - Embed Youtube
terça-feira, 27 de dezembro de 2011
AS3 - Stage Align
stage.align = StageAlign.TOP;
stage.scaleMode = StageScaleMode.NO_SCALE;
AS3 Google Analytics
Track do Google Analytics para AS3
Código no html:
import flash.net.*;
import flash.external.ExternalInterface;
trace("tipo="+Capabilities.playerType)
function marcaAcesso(str:String) {
trace("marca="+str)
ExternalInterface.call("pageTracker._trackPageview","/"+str);
}
marcaAcesso("entrada")
Código no html:
//Google Analytics Flash
domingo, 25 de dezembro de 2011
Rapunzel com Palomino Black Wing
Estou treinando desenho usando como referência os esboços da Rapunzel (Tangled) feitos pelo Glen Keane da Disney.
sexta-feira, 16 de dezembro de 2011
AS3 - Caurina com função e parametros
import caurina.transitions.Tweener;
Tweener.addTween(objeto, {x:10, time:1, delay:.5, transition:"easeInOutSine", onComplete:minhaFuncao, onCompleteParams:[meuParametro]});
Tweener.addTween(objeto, {x:10, time:1, delay:.5, transition:"easeInOutSine", onComplete:minhaFuncao, onCompleteParams:[meuParametro]});
AS3 - Timer
function criaTimer() {
meuTimer=new Timer(5*1000,0);
meuTimer.addEventListener("timer", timerHandler);
}
function timerHandler(event:TimerEvent):void {
//trace("timerHandler: " + event);
}
meuTimer.reset();
meuTimer.start();
meuTimer=new Timer(5*1000,0);
meuTimer.addEventListener("timer", timerHandler);
}
function timerHandler(event:TimerEvent):void {
//trace("timerHandler: " + event);
}
meuTimer.reset();
meuTimer.start();
AS3 - Listener
this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
this.addEventListener(MouseEvent.CLICK,clicouGeral);
this.addEventListener(MouseEvent.MOUSE_OVER,funcao_over);
this.addEventListener(MouseEvent.MOUSE_OUT,funcao_out);
subMenu.addEventListener(MouseEvent.ROLL_OUT,subMenu_out);//para submenus
function onEnterFrame(ev : Event):void {
}
function clicouGeral(evt:MouseEvent) {
trace(evt.target.name)
}
this.addEventListener(MouseEvent.CLICK,clicouGeral);
this.addEventListener(MouseEvent.MOUSE_OVER,funcao_over);
this.addEventListener(MouseEvent.MOUSE_OUT,funcao_out);
subMenu.addEventListener(MouseEvent.ROLL_OUT,subMenu_out);//para submenus
function onEnterFrame(ev : Event):void {
}
function clicouGeral(evt:MouseEvent) {
trace(evt.target.name)
}
AS3 - Por um vídeo no Flash
import fl.video.VideoEvent;
import fl.video.*;
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream=new NetStream(nc);
ns.bufferTime=3;
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
ns.play("meu_video.f4v");
function asyncErrorHandler(event:AsyncErrorEvent):void {
// ignore error
}
var vid:Video = new Video();
vid.attachNetStream(ns);
//vid.setBufferTime(3);
vid.x=0;
vid.y=0;
vid.width=640
vid.height=480
painelVideo.addChild(vid);
//EVENTOS DO VIDEO
ns.addEventListener(NetStatusEvent.NET_STATUS, statusHandler);
ns.pause();
function statusHandler(event:NetStatusEvent):void {
//texto.text="status="+event.info.code;
trace(event.info.code)
switch (event.info.code) {
case "NetStream.Play.Start" :
trace("Start [" + ns.time.toFixed(3) + " seconds]");
break;
case "NetStream.Play.Stop" :
trace("Stop [" + ns.time.toFixed(3) + " seconds]");
videoStop()
break;
case "NetStream.Buffer.Empty" :
texto.text="carregando stream, aguarde...";
break;
case "NetStream.Buffer.Full" :
texto.text=" ";
break;
}
}
videoTocando=fakse;
function videoPlay() {
videoTocando=true;
ns.seek(0);
ns.resume();
painelVideo.visible=true;
}
function videoStop() {
if (videoTocando==true) {
videoTocando=false;
atracoesTimer.start();
ns.seek(0);
ns.pause();
painelVideo.visible=false;
}
}
Usei um componente de FLVPlayback na biblioteca.
import fl.video.*;
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream=new NetStream(nc);
ns.bufferTime=3;
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
ns.play("meu_video.f4v");
function asyncErrorHandler(event:AsyncErrorEvent):void {
// ignore error
}
var vid:Video = new Video();
vid.attachNetStream(ns);
//vid.setBufferTime(3);
vid.x=0;
vid.y=0;
vid.width=640
vid.height=480
painelVideo.addChild(vid);
//EVENTOS DO VIDEO
ns.addEventListener(NetStatusEvent.NET_STATUS, statusHandler);
ns.pause();
function statusHandler(event:NetStatusEvent):void {
//texto.text="status="+event.info.code;
trace(event.info.code)
switch (event.info.code) {
case "NetStream.Play.Start" :
trace("Start [" + ns.time.toFixed(3) + " seconds]");
break;
case "NetStream.Play.Stop" :
trace("Stop [" + ns.time.toFixed(3) + " seconds]");
videoStop()
break;
case "NetStream.Buffer.Empty" :
texto.text="carregando stream, aguarde...";
break;
case "NetStream.Buffer.Full" :
texto.text=" ";
break;
}
}
videoTocando=fakse;
function videoPlay() {
videoTocando=true;
ns.seek(0);
ns.resume();
painelVideo.visible=true;
}
function videoStop() {
if (videoTocando==true) {
videoTocando=false;
atracoesTimer.start();
ns.seek(0);
ns.pause();
painelVideo.visible=false;
}
}
Usei um componente de FLVPlayback na biblioteca.
Expression no After Effects
After Effects, Expression.
Essa expression linka a propriedade "x" do layer pela de ou outro layer de referencia.
thisComp.layer("layer_de_referencia").position[0]
Para adicionar uma expressão a uma propriedade, use ALT+reloginho.
O Array de position é [ x , y , z ]
link util:
http://www.jjgifford.com/expressions/basics/range.html
Para mover em relação ao tempo:
http://www.jjgifford.com/expressions/basics/range.html
Para mover em relação ao tempo:
position[0]+time*400
domingo, 11 de dezembro de 2011
Assinar:
Postagens (Atom)