PDA

View Full Version : Dashcode Animation Code




Avizzv92
Apr 4, 2008, 04:14 PM
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
Feb 25, 2010, 02:10 AM
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.