Quantcast
Channel: Adobe Community : All Content - Edge Animate
Viewing all articles
Browse latest Browse all 9897

Dynamic Mouse Follow

$
0
0

Hey Gang,

 

I'm trying to generate symbols on the stage that when they are added begin to follow the mouse position. Once I get it down I will add easing etc.

 

Currrently its adding new symbols every sec but once they genrerate they are no longer following the mouse position.

 

Here is the code:

 

any thoughts?

 

// vars --------------------

 

 

sym.timer;

sym.spawnFrequency = 1000;

sym.particleArray = [];

sym.pageX;

sym.pageY;

 

 

// funcs --------------------

 

 

// called by trigger @ 0ms

sym.startTimer = function(){

          sym.timer = setInterval(sym.createParticle, sym.spawnFrequency);

};

 

 

sym.createParticle = function(){

          // pull symbol from library, add to Stage

          sym.trailParticle = sym.createChildSymbol("ani_loop_test", "Stage");

          // position based on mouse position

          sym.trailParticle.getSymbolElement().css({"position":"absolute", "left":sym.pageX, "top":sym.pageY});

          sym.particleArray.push( sym.trailParticle );

 

 

          //console.log("x:",trailParticle.getSymbolElement().css("left"), "y:",trailParticle.getSymbolElement().css("top"));

}

 

 

this.offsetX = 125;

this.offsetY = 125;

 

 

this.onMove = function( posX, posY ){

          sym.trailParticle.getSymbolElement().css('left', posX - this.offsetX);

          sym.trailParticle.getSymbolElement().css('top', posY - this.offsetY);

}


Viewing all articles
Browse latest Browse all 9897

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>