PDA

View Full Version : y row spacing with dynamic content



soundman
September 7th, 2009, 01:34 PM
Hey Guys,

As3 newbie...Im trying to build an rss reader, i've managed to parse the xml and get the content scrolling. I have 2 textfields inside a single movieclip for each news item, but what id like to do is position the movieclips on the y-axis releative to the height and y position of the preceding movieclip. Here's my code so far, any help/pointers will be greatly appreciated!


for (var i:uint=0; i<il.length(); i++) {

var holders_mc:MovieClip = new MovieClip();
rss_mc.addChild(holders_mc);

var bg_mask:Sprite = new Sprite();
bg_mask.graphics.beginFill(0xFF6600);
bg_mask.graphics.drawRect( 0, 0, 365, 545);
bg_mask.graphics.endFill();

if (i%2==0) {
var even:MovieClip = new evenBG();
holders_mc.addChild(even);
holders_mc.addChild(bg_mask);
even.mask=bg_mask;
} else {
var odd:MovieClip = new oddBG();
holders_mc.addChild(odd);
holders_mc.addChild(bg_mask);
odd.mask=bg_mask;
}

var titleText:TextField = new TextField();
titleText.defaultTextFormat=titleFormat;
titleText.htmlText="<a href=\""+il.link[i]+"\" target=\"_blank\">"+il.title[i]+"</a>";
titleText.multiline=true;
titleText.wordWrap=true;
titleText.embedFonts=true;
titleText.antiAliasType=AntiAliasType.ADVANCED;
titleText.autoSize=TextFieldAutoSize.LEFT;
titleText.width=360;
titleText.x=5;
titleText.y=5;

holders_mc.addChild(titleText);

var descText:TextField = new TextField();
descText.styleSheet=style;
descText.htmlText=il.description[i];
descText.multiline=true;
descText.selectable=false;
descText.wordWrap=true;
descText.autoSize=TextFieldAutoSize.LEFT;
descText.width=360;
descText.x=5;
descText.y=titleText.textHeight+25;

holders_mc.addChild(descText);

var tHeight:Number = titleText.textHeight+25+descText.textHeight+25;
trace(tHeight);

holders_mc.y=i*tHeight;
}

soundman
September 7th, 2009, 03:33 PM
found the solution here http://snipplr.com/view/15020/spacing-items-vertically-y-axis/ but now face another issue, some of the news items contain images which are loaded into the textfield descText, the full height of the image is not included with the textfield height, but the actual registered height seems to be consistent. Any clues?