Wednesday, 10 March 2010

Drag and Drop

The next thing I wanted to do was to make it so the user could pick up the objects and move them around, The first thing I did was give all the objects an instance name and put each object on its own layer. The I put the following actionscript on to each layer changing the instance name to match each object.

beachball.onPress = function(){
startDrag(this)
}

beachball.onRelease = function(){
this.stopDrag();
}

The part I changed was the 'beachball.' part so for example, to be able to let the user drag and drop the starfish, the actionscript was be added to the starfish layer and would look like this:

starfish.onPress = function(){
startDrag(this)
}

starfish.onRelease = function(){
this.stopDrag();
}

No comments:

Post a Comment

Followers