KineticJS icon indicating copy to clipboard operation
KineticJS copied to clipboard

Arrays objects and mouse Events (KineticJS)

Open ConTrast77 opened this issue 13 years ago • 2 comments

I need animation with vector sprites. (none use transform, none use rotate).

Examples using IMG lot. I need an example of an ARRAY of vector animation pictures.

My first problem is in preparation for the animation code KineticJS. Here's the code: http://jsfiddle.net/SLrTj/2/

When I remove the lines: pageListS[0].on('mouseover touchstart', function() { this.setFill('#FCC'); layer.draw(); }); pageListS[0].on('mouseout touchend', function() { this.setFill('#CCF'); layer.draw(); });

Then a completely different result (or one or the other no works). Together does not work. Then working again without intervention into the code. The link code. http://jsfiddle.net/SLrTj/2/ . Does not work in link.

It's a bug? with use array? or my code ...

Then the show two-dimensional array, and mouse Event to array, with the code: a) Single array, Events worked: http://jsfiddle.net/ConTrast77/47xhb/1/ << updated b) Two-dimensional array, Events BUG-works: http://jsfiddle.net/ConTrast77/47xhb/3/ << updated

a) pageList[0 +i_2] .... pageList[1 +i_2] b) pageList[0,i] ... pageList[1,i]

ConTrast77 avatar Aug 21 '13 19:08 ConTrast77

I'm not sure what your goal is but here are some things I noticed.

In http://jsfiddle.net/SLrTj/2/ in line 77 in the JavaScript you have PageListS[0]. I think you want pageListS[0] (lower case p at the beginning).

Check out Mozilla's Array documentation for using two-dimensional arrays: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array

The section on 2d arrays in near the end but basically, I think you want something like:

// Create an array of 2 arrays
pageList = [[],[]];
// Access the 3rd element of the 0th array
pageList[0][3] 
// As you had:
pageList[0][i] // similar to your pageList[0+i*2]
pageList[1][i] // similar to your pageList[1+i*2]

ippo615 avatar Aug 25 '13 15:08 ippo615

Thank you for your help, the error is partially. This line is needed: var pageList = [[], []];

ConTrast77 avatar Aug 27 '13 16:08 ConTrast77