PDA

View Full Version : Target Previous Duplicate Movie


cphunk
10-23-2003, 05:12 AM
Hey everyone, I have a simple question for you. Hopefully someone can help here.

I'm currently duplicating a clip on the stage as a news item. The problem is. The textfield within the movie clip is resized based on the dynamic text's textHeight. The next duplicated movie must be placed so that it's 10px below the previous - dynamically sized duplicated movie. Do you follow me?

The problem is that, I can't get the previously duplicated clip's height. Is there a way to target your last duplicate somehow?

Here's the code:
You can even download the fla and text file here:
http://www.c-phunk.com/testDup.zip


n = _root.numberOfNewsItems;

objTexts = new LoadVars();
objTexts.load("newsText.txt");
objTexts.pntTimeline = this;
objTexts.onLoad = function() {
this.pntTimeline.dupClips();
};


dupClips = function(){
mc._visible = false;
for(var i = 0; i<n; i++) {

// duplicates mc and sets the text field to newsText.txt text var
var pntThisDupe = mc.duplicateMovieClip("dupe"+i,i);
pntThisDupe.field.text = objTexts["text" + i];
pntThisDupe.date.text = objTexts["Date" + i];
pntThisDupe.field._height = pntThisDupe.field.textHeight;
pntThisDupe.alphaClip._height = pntThisDupe.field.textHeight+10;

// i thought the following would target the prev clip, but it doesn't
if(i > 0) {
var oneLess = i-1;
var newName = "dupe"+oneLess;

// traceing newName returns the correct previous clip
// but i cannot target it's values ..._y, _height for example
trace(newName);

_pntThisDupe._y = newName._height + 10;
}

}
};

farafiro
10-26-2003, 03:24 AM
cphunk
welcome to the forums

the text's height won't reflect the real value befor it is fully loaded
so u do the duplication after u load AND display it

cphunk
10-26-2003, 03:33 AM
The display and duplication is only done after the LoadVars has been successfully loaded. So it's actually being displayed properly.

I did solve the problem already. The issue was that the string needed to be eval'd to be used as a variable. Silly thing I should have known.