Skip to main content

Posts

Showing posts from February, 2013

continues looping of a background in as3

/* copy and paste this code on the first frame of your movie and create  need a bg movie clip put that clip in library  */ import flash.display.MovieClip; import flash.events.Event; import flash.display.Sprite; import flash.events.MouseEvent; var max:Number = 800; var speed:Number = -5; stage.frameRate = 24; //a blank sprite thats hold the background var BgClone:MovieClip; //adding background movieClip; //defaut direction addbackground() function addbackground() { //minimum 2 for (var i:Number=0; i<2; i++) { var Bg=new bg(); this.addChild(Bg); Bg.x=(Bg.width/2)+Bg.width*i; Bg.y = Bg.height/2; Bg.addEventListener(Event.ENTER_FRAME,moveBg); } } function moveBg(e:Event) { e.currentTarget.x +=  speed;     if ( e.currentTarget.x<-(e.currentTarget.width/2)) { e.currentTarget.x = 1190; } }

swipe event using jquery and easeljs with a cool example

swipe events are most popular events for the android and ios devices. so here i come with a example where i am using jquery and easeljs. what you need to run this example  ============================================================================ a images floder which contains two pictures one for background and another of a moving  object ========================================================================== files required (jquery and wipetouch files) -------------------------------------------------- http://jquery.com/download/ http://wipetouch.codeplex.com/releases/view/89431 download easeljs (coolest javascript library ) http://www.createjs.com/#!/EaselJS copy and paste the entrie code in html file be sure your directory structure is like mine or you can create you own  ======================================================================= <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML ...

inheritance using EaselJS: a example of bouncing balls create with easejs

its really easy to extend a class in easeljs here is a example with source code ball class extended from the container class with its serval own properties such as vx,vy and gravity   ===================================================== for new guys copy this code in a javascript file rename that file as ball.js   //ball class (function (window) {     function ball(icon,x,y) {         this.initialize(icon,x,y);     }     //Inheritance from Container     ball.prototype = new createjs.Container();  ball.prototype.icon=null; ball.prototype.vx=2; ball.prototype.vy=0; ball.prototype.gravity = .4;     ball.prototype.initialize = function (icon) {   this.icon=icon;   this.addChild(icon);     }      ball.prototype.onTick = function () {                // apply gravi...

unique array in javascript(which contain all unique values)

how to get a unique array in javascript ============================= var list1=create_unique_random_array(20,0,19); var list2=create_unique_random_array(20,0,19); function create_unique_random_array(num_elements,min,max) {     var temp, nums = new Array;     for (var element=0; element<num_elements; element++) {          while((temp=number_found(random_number(min,max),nums))  ==-1);         nums[element] = temp;     }     return (nums); } function number_found (random_number,number_array) {     for (var element=0; element<number_array.length; element++) {         if (random_number==number_array[element]) {             return (-1); }    }     return (random_number); }

cool flash like drag and drop in easejs and html5

here is a cool drag and drop create in easejs+tweenlite what is easejs= easejs is a flash api like java script library  what  is tweenlite = a cool time based animation engine or javascript library   whole code  for your drag and drop with screenshoot you can download  easejs from the below link ================================ http://www.createjs.com/#!/EaselJS you can download tweenlite  from the below link http://www.greensock.com/gsap-js/ because easejs yet not support hit test for collision detetion  so i downloaded a cool collision detection javascript file from https://github.com/olsn/Collision-Detection-for-EaselJS/blob/master/example/index.html ======================================================================= code of  drag and drop <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html ...