[F8] drag and drop sound
I am trying to make a drag and drop sound player. I can get it to work if I hard code it, but the variables just aren't being passed. The user should drop a button on a target and when the user presses submit the sound should play.
Code:
_parent.createEmptyMovieClip("soundHolder_mc", 2);
click_sound = new Sound(soundHolder_mc);
click_sound.loadSound(songTitle);
function onClick() {
click_sound.start();
}
function sStop() {
click_sound.stop();
}
circle.onRollOver = function() {
_root.songTitle = "song1.mp3";
onClick();
}
circle.onRollOut = function() {
sStop();
}
circle.onPress = function() {
sTitle = "song1.mp3";
this.startDrag();
startx = this._x;
starty = this._y;
}
circle.onRelease = function() {
this.stopDrag();
theDrop = eval(this._droptarget);
_root.songTitle = "song1.mp3";
_root.debug = songTitle;
this._x = startx;
this._y = starty;
sStop();
}
square.onPress = function() {
this.startDrag();
sTitle = "song2.mp3"
startx = this._x;
starty = this._y;
}
square.onRelease = function() {
this.stopDrag();
theDrop = eval(this._droptarget);
_root.songTitle = "song2.mp3";
_root.debug = songTitle;
this._x = startx;
this._y = starty;
}
submitSound.onPress = function() {
click_sound.loadSound(songTitle);
}
Thanks in advance for any posts!
Attached Files
Maybe try something like this...
Code:
stop();
var songArray = ["song1.mp3", "song2.mp3", "song3.mp3"];
var objsArray = ["circle", "square", "star"];
var numOfObjs = objsArray.length;
var songTitle = "";
//
function doPress() {
this.startDrag();
}
function doRelease() {
stopDrag();
if (eval(this._droptarget)._name == "targetArea") {
songTitle = songArray[this.num];
trace("Song selected: " + songTitle);
}
this._x = this.startX;
this._y = this.startY;
}
//
this.createEmptyMovieClip("soundHolder_mc", 2);
var click_sound = new Sound(soundHolder_mc);
click_sound.onLoad = function(success) {
if (success) {
click_sound.start();
trace("Song playing: " + songTitle);
} else {
trace("Sound failed to Load");
}
};
submitSound.onPress = function() {
if (songTitle != "") {
click_sound.loadSound(songTitle);
}
};
//
for (var i = 0; i < numOfObjs; i++) {
var myObj = this[objsArray[i]];
myObj.num = i;
myObj.startX = myObj._x;
myObj.startY = myObj._y;
myObj.onPress = doPress;
myObj.onRelease = doRelease;
}
Last edited by dawsonk; 10-17-2007 at 11:02 AM .
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width