PDA

View Full Version : problem passing a variable to a button inside a movieclip



neiro
December 7th, 2004, 10:24 PM
Hello,

I have list that is generated from a database that when click it calls a seperate movieclip in the library called comments and loads data from the database in it. I the movieclip i have buttons that I am trying to pass the data to but it doesnt seem to be working.

here is my actionscript:

getReleaseInfo_Result = function (releasesID,track1url,track2url,track3url,track4ur l) {

_root.container.attachMovie("comments", "comments", 100);
_root.container.comments._x = 325;
_root.container.comments._y = 150;
_root.container.comments.track1.text = releasesID.getItemAt(0).track1
var track1url = releasesID.getItemAt(0).track1url
_root.container.comments.track1url.text = track1url
trace(track1url);
};

Track1url is the variable I am trying to pass to use it in the on press fuction below.

on (press) {
_root.splayer.doPlay(track1url);
trace(track1url);
}

Can anyone steer me in the right direction.

thanks,

chad

3rdeye
December 8th, 2004, 01:12 AM
that's some **** confusing code you got there... talk about obscure naming practice... ummm let's see... I don't see how the top function relates to the onPress? <I'd recommend using onRelease for buttons, just for useability sake>

What I think you're looking for is a way to create a class... ie. after getting the data, you want to instantiate a certain number of buttons, correct? Well...


MovieClip.prototype.buttons = function() {
movieID = String(this);
textNum = movieID.indexOf(".")+1;
movieID = movieID.substr(textNum);
this.info = movieID;
this.onRollOver = function() {
this.gotoAndStop("over");
};
this.onRollOut = function() {
this.gotoAndStop("off");
};
this.onRelease = function() {
statusTxt.text = this.info;
this.gotoAndStop("down");
};
};
this bit of code controls how a movie clip responds depending on the mouse. It also has it's own target (instance name) embedded in
<movie clip>.info

to apply this very simple class to a movie clip, simply use:
<movie clip>.buttons();

for a whole bunch of duplicate movie clips this kind of info can be stuffed into the original MC being duplicated. This probably isn't clear but maybe it'll help... ;)