1. 1. Se crea el proyecto en Flash Develope, agregamos la clase y seguido importamos la clase “MovieClip” seguido de la clase “event”., tambien importamos la clase “geom.ColorTransform” la cual recopila datos acerca de las transformaciones de color y transformaciones de coordenadas que se aplican a un objeto de visualización. package { importflash.display.MovieClip; importflash.events.*; importflash.geom.ColorTransform; /** * ... * @authorDefaultUser (Tools -> CustomArguments...) */ publicclasspointXextendsMovieClip { publicfunctionpointX() { pintura.addEventListener(MouseEvent.MOUSE_DOWN, iniciarArrastre); pintura.addEventListener(MouseEvent.MOUSE_UP, detenerArrastre); getColor(); }
2. 2. En el constructor creaomos 2 escuchas “Listener” de tipo “Mouse” detenerArrastre iniciarArrastre y luego llamamos el metodo “getColor();” package { importflash.display.MovieClip; importflash.events.*; importflash.geom.ColorTransform; /** * ... * @authorDefaultUser (Tools -> CustomArguments...) */ publicclasspointXextendsMovieClip { publicfunctionpointX() { pintura.addEventListener(MouseEvent.MOUSE_DOWN, iniciarArrastre); pintura.addEventListener(MouseEvent.MOUSE_UP, detenerArrastre); getColor(); }
3. 3. Este metodo genera los valores aleatorios para los canales rojo, verde y azul, crea y devuelve un objeto con el color cambiado segun los valores de colores aleatorios functiongetColor():ColorTransform { varred:Number = (Math.random() * 512) - 255; vargreen:Number = (Math.random() * 512) - 255; varblue:Number = (Math.random() * 512) - 255; return new ColorTransform(1, 1, 1, 1, red, green, blue, 0); }
4. 4. Se ejectua una el metodo iniciar arraster el cual permitira mover el bote de pintura con el metodostarDrag(); y seguido se crea un condicional “If” donde utilizamos el metodo “hitTestPoint” el cual permite que el bote de pintura colisione con la flor en las coordenadas establecidas dependiendo de cada punto de colicion cambiara el color de la flor de manera aleatoria por medio del metrodogetColor. publicfunctioniniciarArrastre(e:MouseEvent):void { pintura.startDrag(); if(pintura.hitTestPoint(florecita.x +0, florecita.y +75)){ florecita.transform.colorTransform = getColor(); } if(pintura.hitTestPoint(florecita.x +12, florecita.y +50)){ florecita.transform.colorTransform = getColor(); } if(pintura.hitTestPoint(florecita.x +83, florecita.y +0)){ florecita.transform.colorTransform = getColor(); } if(pintura.hitTestPoint(florecita.x +157, florecita.y +85)){ florecita.transform.colorTransform = getColor(); } }
5. 5. El metodo “detenerArrastre” permitira llamar el metodo “stopDrag();” que hace posible soltar el bote de pintura en cualquier parte del escenario. publicfunctiondetenerArrastre(e:MouseEvent):void { pintura.stopDrag(); } } }