0 Replies - 1066 Views - Last Post: 28 March 2012 - 08:21 AM

#1 student123  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 77
  • Joined: 18-November 08

how do you do water effects to scripted drawings?

Posted 28 March 2012 - 08:21 AM

I am having problems with apllying watter effects to scripted drawing.

no errors found.

how would i apply a ripple effect to a scripted drawing.

scripted drawing.
import flash.display.Sprite;
import flash.display.Graphics;

var myMathGame:ToRipple = new ToRipple();

var shapes:Sprite = new Sprite ();
var gr:Graphics = shapes.graphics;

gr.lineStyle();
gr.beginFill(0x0000FF,0xFFFFFF)
gr.drawRect(0,5,100,100);
gr.endFill();


shapes.x = 0;
shapes.y = 10;
addChild(shapes);




scripted drawing
package  
{
	

		import flash.display.Bitmap;
		import flash.display.Sprite;
		import flash.events.MouseEvent;
		import flash.display.BitmapData;
		import flash.utils.Timer;
		import flash.events.TimerEvent;
		
		public class ToRipple extends Sprite
		{
		
		private var myRippler:Rippler;
		var rippleTarget:Bitmap;
		
		public function Ripple() 
		{
			var rippleBitmap:BitmapData=new BitmapData(640,480,false,0);
			var ripplePicture:toRipple=new toRipple();
			var timer:Timer=new Timer(100);
			timer.start();
			rippleBitmap.draw(ripplePicture);
			rippleTarget=new Bitmap(rippleBitmap);
			addChild(rippleTarget);
			myRippler=new Rippler(rippleTarget,20,5,5);
			stage.addEventListener(MouseEvent.MOUSE_MOVE,onmousemoveTriggered);
			timer.addEventListener(TimerEvent.TIMER, onTimerTriggered);
		}
		
		private function onmousemoveTriggered(e:MouseEvent):void 
		{
			myRippler.drawRipple(rippleTarget.mouseX,rippleTarget.mouseY,20,1);
		}
		
		private function onTimerTriggered(e:TimerEvent):void 
		{
			var posX:Number=Math.random()*640;
			var posY:Number=Math.random()*480;
			myRippler.drawRipple(posX,posY,15,5);
		}
	}
}


This post has been edited by student123: 28 March 2012 - 08:30 AM


Is This A Good Question/Topic? 0
  • +

Page 1 of 1