Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Avizzv92

macrumors regular
Original poster
Mar 23, 2008
172
0
I'm trying to have an object (ovalShape) to move to a right position when clicked on. I'm using the code snippet from the dashcode library. But I can't seem to get it too work.

Here's the code, tell me if I'm doing something wrong.

// Values you provide
var itemToMove = document.getElementById("ovalShape"); // replace with ID of element to move
var moveToRightPosition = 100; // new right CSS value

// Moving code
var originalRight = parseInt(document.defaultView.getComputedStyle(ite mToMove, null).getPropertyValue("right"));
var moveHandler = function(a, c, s, f){ itemToMove.style.right = c + "px"; };
new AppleAnimator(500, 13, originalRight, moveToRightPosition, fadeHandler).start();

When I do click on the object I get an error "can't find variable fadeHandler"
 

rmazz

macrumors newbie
Feb 25, 2010
1
0
San Francisco, CA
Correction to Dashcode Animation Code

I got caught by this one too. It is actually Apple's mistake in the last line:
new AppleAnimator(500, 13, originalRight, moveToRightPosition, fadeHandler).start();
should read:
new AppleAnimator(500, 13, originalRight, moveToRightPosition, moveHandler).start();

The moveHandler is what is defined in the line above it. Change it and it will work.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.