PDA

View Full Version : Changing someone elses code


rgo
11-04-2007, 05:24 PM
Hi I have a file that some one else did... I am new to flash and I am trying to alter it. their code looks like this

for(i=0; i<itemNum; i++) {

_root.attachMovie("mc_button","mc_button"+i,10+i);
ref = _root["mc_button"+i];
// Vertical Positión (_y)
ref._y = stageHeight/2+10;
// Horizontal Positión (_x) + separation (20px)
ref._x = ( space * i ) + separation;
// Loads the picture description
ref.picName=picturesXML.firstChild.childNodes[i].childNodes[0].firstChild.nodeValue
// unloads the marc
ref.marc.marc.unloadMovie()
// Load the picture(.jpg)
ref.marc.marc.loadMovie(picturesXML.firstChild.chi ldNodes[i].childNodes[1].firstChild.nodeValue)
trace ("1"+picturesXML.firstChild.childNodes[i].childNodes[1].firstChild.nodeValue);
// Large Picture URL
//ref.picURL=picturesXML.firstChild.childNodes[i].childNodes[2].firstChild.nodeValue
// ID
ref.ID=i


}
I am unable to determine what the line _root.attachMovie("mc_button"
means what is "mc_button" and where can I find it in my movie also what is ref.marc.marc.loadMovie.

I know loadMovie is loading a movie... in this case an image but what does the ref.marc.marc have to do with anything

thanks.

RickyNilsson
11-04-2007, 06:27 PM
Ok, first things first.

What you have in your hand is a code using AS2.
This particular code your wondering over is completly different in AS3. (where you have posted your question)
Question you need to ask if you want to go with AS2 or work with the new AS3.
My tip is to go with AS3 since there is where the future is.

Anyway, _root.attachMovie("mc_button"...); is the code which in AS2 loads the MovieClip "mc_button" that you have in your library.
This have been removed in AS3 and you no longer need this but instead just have to define your mc_button in a simple var.

As for your other question.
This code which your looking at uses xml and if your completly new I would advice you not to jump into that pool just yet :)