A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Continuously scrolling text

  1. #1
    Junior Member
    Join Date
    Aug 2002
    Posts
    7

    Continuously scrolling text

    I am trying to create a dynamic text field that continuously scrolls through dynamically loaded text (like a news ticker, except it scrolls down). If have got the text to load in, and I can get it to scroll with buttons, but I don't want it to use buttons. I just want it to scroll, and when it has scrolled through the text, I want it to wait for a little bit and then rescroll through it again. Do you know how I can do this with actionscript?

  2. #2
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    Code:
    _root.createEmptyMovieClip("mc", 0);
    _root.mc.createTextField("t", 0, 0, 0, 100, 100);
    _root.mc.t.text = "BEGIN ovfpkrv werognorw ojnvwor wpjw ijege ovfpkrv werognorw ojnvwor wpjw ijege ovfpkrv werognorw ojnvwor wpjw ijege FINISHED";
    _root.mc.t.wordWrap = true;
    _root.mc.t.border = true;
    function scrollDown() {
    	trace(_root.mc.t.scroll);
    	_root.mc.t.scroll = _root.mc.t.scroll%_root.mc.t.maxscroll+1;
    }
    setInterval(scrollDown, 1000);

  3. #3
    Junior Member
    Join Date
    Aug 2002
    Posts
    7
    thanks mate - could that great. could you just tell me how to specify the font and how to dynamically load the content with that script?

  4. #4
    Junior Member
    Join Date
    Aug 2002
    Posts
    7
    and how can i get it to pause for a few seconds when its finished scrolling through the text, before it starts scrolling again?

  5. #5
    Junior Member
    Join Date
    Aug 2002
    Posts
    7
    and is there a way to possibly make it scroll more smoother rather than line by line? sorry but i'm only a beginner.

  6. #6
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    Code:
    myFormat = new TextFormat();
    myFormat.font = "Verdana";
    myformat.embedFonts = true;
    /*i'm not sure about how to embed a font... if you can't do it, don't ask me cause i don't know more then this
    but i think it's like this: go to the library, on top, on the right, there is a button. in the popUp menu
    choose new font. choose the font that you want,then assign it a name. that's the name wich will appear
    here: myFormat.font = "font name";
    
    to load the text dinamically use loadVariables():
    important!: the text takes some time to load, so you have to be sure that the text has loaded that's why I use onData, but I've had some trouble with it, and there is a known issue about that
    in the external.txt i placed: externalText=BEGINING and more garbish
    */
    //
    _root.createEmptyMovieClip("mc", 0);
    _root.mc.loadVariables("external.txt");
    _root.mc.onData = function() {
    	trace("jong");
    	_root.mc.createTextField("t", 0, 0, 0, 100, 100);
    	_root.mc.t.text = _root.mc.externalText;
    	_root.mc.t.wordWrap = true;
    	_root.mc.t.border = true;
    };
    //
    function scrollDown() {
    	_root.mc.t.scroll = _root.mc.t.scroll%_root.mc.t.maxscroll+1;
    	if (_root.mc.t.scroll == _root.mc.t.maxscroll) {
    		clearInterval(firstInterval);
    		secondInterval = setInterval(wait, 3000);
    	}
    }
    firstInterval = setInterval(scrollDown, 1000);
    function wait() {
    	clearInterval(secondInterval);
    	firstInterval = setInterval(scrollDown, 1000);
    }
    Attached Files Attached Files

  7. #7
    Junior Member
    Join Date
    Aug 2002
    Posts
    7
    you are a genius mate. just one more thing - do you know how i can make this a html text field, and can i make the scroll run more smoothly rather than line by line? so it just looks like a motion tween sort of thing?

  8. #8
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    for the html thing:
    instead of
    Code:
    _root.mc.createTextField("t", 0, 0, 0, 100, 100);
    _root.mc.t.text = _root.mc.externalText;
    _root.mc.t.wordWrap = true;
    use this
    Code:
    _root.mc.createTextField("t", 0, 0, 0, 100, 100);
    _root.mc.t.htmlText = true;
    _root.mc.t.htmlText = _root.mc.externalText;
    _root.mc.t.wordWrap = true;
    it is not possible to make it smoother because, to make it scroll i use textField.scroll, and it receives integers only

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