A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: Scroller Not Adjusting to Dynamic Text

  1. #1
    Member
    Join Date
    Nov 2002
    Posts
    46

    Scroller Not Adjusting to Dynamic Text

    I have a dynamic text box that adjust in height according to how much text is inserted by xml. The problem is that my scroll bar is not recognizing that the text box has grown in length, therefore it doesn't scroll all the way.

    I need to find a way to get the scroll to recognize that the text box has grown.

    Help, please! Thanks!
    Attached Files Attached Files

  2. #2
    the friendly canadian DaVulf's Avatar
    Join Date
    Feb 2004
    Location
    Singapore
    Posts
    2,017
    *doesn't know the real answer*

    Couldn't you just have an:

    Code:
    clip.onEnterFrame = function(){
         this._height = this.textbox._height+10
    }
    Wouldn't the textbox grow with the imported text, causing the MC to grow and thus be scrollable?

  3. #3
    Member
    Join Date
    Nov 2002
    Posts
    46
    Hmmmmm.... good theory. Let me try it out real quick. I think that might be the problem, because the scroll is measuring the size of an MC, not a text box.

    I'll be back.........

  4. #4
    Member
    Join Date
    Nov 2002
    Posts
    46
    Errr... actually I have it set up that way already.

    I have the scroller checking the height of "main", which is the instance name of the text box.

    Any other options?

  5. #5
    the friendly canadian DaVulf's Avatar
    Join Date
    Feb 2004
    Location
    Singapore
    Posts
    2,017
    I have something like this set up on one of my files. I'll reply when I get home (on my portable HD in another city :@).

  6. #6
    Member
    Join Date
    Nov 2002
    Posts
    46
    Thanks DaVulf.... I appreciate it.

  7. #7
    the friendly canadian DaVulf's Avatar
    Join Date
    Feb 2004
    Location
    Singapore
    Posts
    2,017
    Okay, this is the code on the first frame of my 'Newsbox' mc.

    PHP Code:
    oadVarsText = new LoadVars();
    loadVarsText.load("news.txt");
    loadVarsText.onLoad = function(success) {
        if (
    success) {
            
    trace ("done loading");
            
    //trace(this.myText);
            
    main.mainText.htmlText this.myText;
            
    main.mainText.autoSize "left";
            
    trace("TEXTFIELD HEIGHT: "+main.mainText._height);
            
    trace("CLIP HEIGHT: "+main._height);
            
    offset main._height main.mainText._height;
            
    trace("OFFSET: "+offset);
            
    bottom = (main._y+mask_mc._height-main._height-space)+offset;
        } else {
            
    trace ("not loaded");
        }
    };

    stop();

    fscommand("allowscale""false");
    //bar.useHandCursor = dragger.useHandCursor=false;
    space = -150;
    friction .6//was 0.9
    speed 4//was 4
    dragger._y;
    top main._y;
    bottom = (main._y+mask_mc._height-main._height-space);

    dragger.onPress = function() {
        
    //trace(this._parent);
        
    drag true;
        
    this.startDrag(falsethis._xthis._parent.ythis._xthis._parent.y+this._parent.bar._height-this._height);
        
    scrollEase1();
    };

    dragger.onMouseUp = function() {
        
    this.stopDrag();
        
    drag false;
    };

    bar.onPress = function() {
        
    drag true;
        if (
    this._parent._ymouse>this._y+this._height-this._parent.dragger._height) {
            
    this._parent.dragger._y this._parent._ymouse;
            
    this._parent.dragger._y this._y+this._height-this._parent.dragger._height;
        } else {
            
    this._parent.dragger._y this._parent._ymouse;
        }
        
    scrollEase1();
    };

    bar.onMouseUp = function() {
        
    drag false;
    };

    moveDragger = function (d) {
        if ((
    dragger._y == y+bar._height-dragger._height && == 1) || (dragger._y == && == -1)) {
            
    clearInterval(myInterval);
        } else {
            
    dragger._y += d;
            
    scrollEase1();
            
    updateAfterEvent();
        }
    };

    up_btn.onPress = function() {
        
    myInterval setInterval(moveDragger18, -1);
    };

    down_btn.onPress = function() {
        
    myInterval setInterval(moveDragger181);
    };

    up_btn.onMouseUp down_btn.onMouseUp=function () {
        
    clearInterval(myInterval);
    };

    MovieClip.prototype.scrollEase1 = function() {
        
    //trace("YO!");
        
    dragger.onEnterFrame = function() {
            if (
    Math.abs(dy) == && drag == false) {
                
    delete this.onEnterFrame;
            }
            
    = (this._y-y)/(bar._height-this._height);
            
    dy Math.round((((top-(top-bottom)*r)-main._y)/speed)*friction);
            
    main._y += dy;
        };
    }; 
    I have attached the .fla with the symbol in it.

    edit: Props to oldnewbie for helping me with this a few months ago.
    Attached Files Attached Files

  8. #8
    Member
    Join Date
    Nov 2002
    Posts
    46
    DaVulf.... I can't open your .fla because I'm using MX. Can you save it in actionscript 1.0?

    Thanks!

  9. #9
    Member
    Join Date
    Nov 2002
    Posts
    46
    I've tried pasting the code above in my movie, but it's not working for me. I noticed that you had a line that wanted to load an external text file, but I'm using an XML file that's running off nodes..... which is a completly different script.

    I'm a little confused with the code you provided. You clarify on how I'm suppose to use it?

  10. #10
    Member
    Join Date
    Nov 2002
    Posts
    46
    Here's the .fla with the updated code that's not working.
    Attached Files Attached Files

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