Ok, i’m a little lost, so i’m reaching out to others for some help with this.
So i’m making a drag and drop audio mixer. there are some dynamic clips that are dragged into a “track timeline”. when the item is dropped on the timeline, i am placing two duplicate clips on the “track timeline”. one’s width is sized to the length of the song attached to that draggable clip that was dropped, and the other is a text field, printing the number of seconds with a “close” button to remove both duplicate clips from the “track timeline” if it’s pressed.
my problem is this:
i have the duplicate movie part within a “for each” loop for the draggable sounds. for each of the close buttons, i am trying to attach code that will close just the button it is placed on. but since the button’s path is in a dynamically created movie clip, i’ve used a variable to tell which clip it will close.
however it always closes the last clip placed cause that’s the current value of the variable. is it possible to set a fixed variable value for when the button onPress code is written? i’ve highlighted the troublesome part is red below.
any help or anyone else’s ideas on how i can do this would be greatly appreciated.
if (this.onTarg == track1_mc) {
if (_root.track1.length>0) {
_root.songNumber1++;
track1[_root.songNumber1] = this+".mp3";
trackAudio1.onLoad = function(success:Boolean) {
var totalSeconds:Number = this.duration/1000;
var seconds = Math.floor(totalSeconds)%60;
if (seconds<10) {
seconds = "0"+seconds;
}
trace(seconds+" seconds");
ph = _root.empty_track_mc.duplicateMovieClip("track1Holder"+songNumber1+"_mc", _root.getNextHighestDepth());
ch = _root.emptyTop_mc.duplicateMovieClip("track1Top_mc"+songNumber1, _root.getNextHighestDepth());
newNum = songNumber1-1;
if (newNum == 0) {
oldNum = "trackHolder_mc1";
} else {
oldNum = "track1Holder"+newNum+"_mc";
}
endNum = getProperty(oldNum, _width);
nextNum = getProperty(oldNum, _x);
_root["track1Top_mc"+songNumber1].clipTest_txt = seconds+" sec.";
ph._x = endNum+nextNum;
ph._y = _root.track1_mc._y;
ph._width = seconds*8;
ch._x = endNum+nextNum;
ch._y = _root.track1_mc._y;
[COLOR=“Red”] ch.close_mc.onPress = function() {
track1.deleteAt(_root.songNumber1);
unloadMovie(ph);
unloadMovie(ch);
}[/COLOR]
};
trackAudio1.loadSound(track1[_root.songNumber1], false);