Código :
import fl.transitions.*; import fl.transitions.easing.*; import flash.display.BitmapData; import flash.display.Bitmap; import flash.display.Sprite; import flash.events.*; import flash.display.Shape; import flash.events.Event; loading.visible = false; error.visible = false; //////////// VARIABLES GLOBALES //// import VariableGlobal; VariableGlobal.vars.root = this; const WIDTH:Number = 600; const HEIGHT:Number = 450; var cam:Camera; var vid:Video; cam = Camera.getCamera(); //traer cam.setMode(WIDTH,HEIGHT,15); vid = new Video(WIDTH,HEIGHT); if (cam!=null){ //Si cam no es null (que está funcando) vid.attachCamera(cam); error.visible = false; }else{ error.visible = true; //trace("FAVOR DE CONECTAR SU WEBCAM Y SETEARLA"); } vid.filters = [new BlurFilter(10,10,1)]; var videoContainer:Sprite= new Sprite(); videoContainer.x= 0; videoContainer.y= 0; videoContainer.addChild(vid); var empieza2:Timer = new Timer (4000); empieza2.addEventListener(TimerEvent.TIMER, dale); empieza2.start(); function dale(e:TimerEvent):void{ // var miColor:ColorTransform=transform.colorTransform; if (!VariableGlobal.vars.color2){ miColor.color=0xFF0000; }else{ miColor.color=VariableGlobal.vars.color2; } clip.transform.colorTransform=miColor; // var _stageBitmap:BitmapData; _stageBitmap = new BitmapData(stage.width, stage.height); _stageBitmap.draw(vid); var pix:uint = _stageBitmap.getPixel(300,225); /// trace(pix.toString(16)); // un trace al pedo pero sirve para explicar var color0x:String = "0x" + pix.toString(16); //perfecto ahora en color0x tengo el pure dato. VariableGlobal.vars.colorGlobal = color0x; var color2:uint = uint(color0x); VariableGlobal.vars.color2 = color2; //trace(color2); // function to transition from one colorTransform to another function interpolateColor(start:ColorTransform, end:ColorTransform, t:Number):ColorTransform { var result:ColorTransform = new ColorTransform(); result.redMultiplier = start.redMultiplier + (end.redMultiplier - start.redMultiplier)*t; result.greenMultiplier = start.greenMultiplier + (end.greenMultiplier - start.greenMultiplier)*t; result.blueMultiplier = start.blueMultiplier + (end.blueMultiplier - start.blueMultiplier)*t; result.alphaMultiplier = start.alphaMultiplier + (end.alphaMultiplier - start.alphaMultiplier)*t; result.redOffset = start.redOffset + (end.redOffset - start.redOffset)*t; result.greenOffset = start.greenOffset + (end.greenOffset - start.greenOffset)*t; result.blueOffset = start.blueOffset + (end.blueOffset - start.blueOffset)*t; result.alphaOffset = start.alphaOffset + (end.alphaOffset - start.alphaOffset)*t; return result; } // start and end colors for tween var startColor:ColorTransform = new ColorTransform(); // default color, no tint if(!VariableGlobal.vars.valorcolor){ loading.visible=true; }else{ loading.visible=false; startColor.color = parseInt(VariableGlobal.vars.valorcolor, 16); } var endColor:ColorTransform = new ColorTransform(); endColor.color = VariableGlobal.vars.color2; var tween:Tween = new Tween(clip, "", Strong.easeOut, 0, 1, 50); tween.addEventListener(TweenEvent.MOTION_CHANGE, tweenTransform); function tweenTransform(event:TweenEvent):void { clip.transform.colorTransform = interpolateColor(startColor, endColor, tween.position); var valorcolor = clip.transform.colorTransform.color.toString(16); VariableGlobal.vars.valorcolor = valorcolor; } }
y el codigo de la variable global
Código :
package { public class VariableGlobal { public static var vars:Object = []; } }
clip es lo que cambia de color y vid es el video..
Por favor, brindenme una mano.. no lo pude cambiar ni por codigo ni desde flash.
Lionel