A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: dynam texField height

  1. #1

    dynam texField height

    dynam textfields _height

    I'm trying to get data from two arrays in dynamically created textboxes under eachother (it's for a news-section, it's a newsstory, the date, a newsstory, the date,...)

    I get the data out, but the textfields containing the news (after each date) always add extra space. This space is, strangely enough, dependand on how many lines of text are in the news textfield.

    Here's the code for the functions:


    Code:
    function createNewTextField(whichOne, whichArray, howManyEntries){
    	if(whichArray == "theNews"){
    		_root.createTextField(whichOne, whichOne, 20, _root.ypos, 100, 30);
    		_root[whichOne].border = 1;
    		_root[whichOne].autoSize= "left";
    		_root[whichOne].wordWrap=1;
    		_root[whichOne].multiline=0;
    		_root[whichOne].text = _root.theData[whichOne];
    		_root[whichOne].setTextFormat(_root.newsFormat);
    	}
    	if(whichArray == "theDate"){
    		_root.createTextField(whichOne + howManyEntries, whichOne + howManyEntries, 20, _root.ypos, 100, 30);
    		_root[whichOne + howManyEntries].border = 1;
    		_root[whichOne + howManyEntries].autoSize= "left";
    		_root[whichOne + howManyEntries].wordWrap = 1;
    		_root[whichOne + howManyEntries].multiline = 0;
    		_root[whichOne + howManyEntries].text = theDay[whichOne] + " " + theMonth[whichOne] + " " + theYear[whichOne];
    		_root[whichOne + howManyEntries].setTextFormat(_root.dateFormat);
    		trace("i'm working on " +  _root.theData[whichOne]);
    	}
    	_root.ypos += _root[whichOne]._height;
    	_root.ypos += _root[whichOne + howManyEntries]._height;
    	textFieldArLen = _root.textFieldAr.length;
    	_root.textFieldAr[textFieldArLen] = whichOne;
    	_root.textFieldAr[textFieldArLen + 1] = whichOne + howManyEntries;
    	
    
    
    }
    
    function displayNews(howManyEntries){
    
    	for(x=0; x<howManyEntries; x++){
    		createNewTextField(x, "theNews", howManyEntries);
    		createNewTextField(x, "theDate", howManyEntries);
    	}
    }
    Any idea what I'm doing wrong?

    I'm probably going to rescript it to use movieclips, but it'd be cool if I could get it working with createTextField

    Thanks

  2. #2
    I think it's got something to do with the fact that the first textfield isn't completely created when the code starts the date field....

  3. #3
    yep, it's at least got something to do with it, because with one textfield a time, it works great

  4. #4

    solution

    well, for anyone having a similar problem, using two functions seems to solve it. code gets a bit more redundant, but it DOES work

    Code:
    function createNewsField(whichOne, howManyEntries){
    		_root.createTextField("news"+whichOne, whichOne, 20, _root.ypos, 100, 30);
    		_root["news"+whichOne].border = 1;
    		_root["news"+whichOne].autoSize= "left";
    		_root["news"+whichOne].wordWrap=1;
    		_root["news"+whichOne].multiline=0;
    		_root["news"+whichOne].text = _root.theData[whichOne];
    		_root["news"+whichOne].setTextFormat(_root.newsFormat);
    		_root.ypos += _root["news"+whichOne]._height;
    }
    
    function createDateField(whichOne, howManyEntries){
    		_root.createTextField("date"+whichOne, whichOne+howManyEntries, 20, _root.ypos, 100, 30);
    		_root["date" + whichOne].border = 1;
    		_root["date" + whichOne].autoSize= "left";
    		_root["date" + whichOne].wordWrap = 1;
    		_root["date" + whichOne].multiline = 0;
    		_root["date" + whichOne].text = theDay[whichOne] + " " + theMonth[whichOne] + " " + theYear[whichOne];
    		_root["date" + whichOne].setTextFormat(_root.dateFormat);
    		_root.ypos += _root["date"+whichOne]._height + 4;
    }
    	
    function displayNews(howManyEntries){
    	for(x=0; x<howManyEntries; x++){
    		createNewsfield(x, howManyEntries);
    		createDateField(x, howManyEntries);
    	}
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center