A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: loading txt files

  1. #1
    Junior Member
    Join Date
    Feb 2004
    Location
    Flash
    Posts
    4

    loading txt files

    Hi all,

    major actionscript issue here, i am trying to get this bio to work, The movie works however the bio.txt file in the root dir won't load, could someone please assist?

    Greetings from amsterdam, holland

    I have used actionscript in the movie as follows:


    < on the first frame > textbox.loadVariables("bio.txt");
    < on the last frame > textbox.loadVariables("bio.txt");
    stop();
    < the txtbox > contains the following to make it scroll >


    onClipEvent (load) {
    function scrollResize() {
    lastHeight = scrollbar._yscale;
    totalLines = (text.maxscroll - 1) + numLines;
    newHeight = 100 * numLines / totalLines;
    scaleDiff = Math.abs((newHeight - lastHeight));
    currentPosition = scrollbar._y;
    pixelDiff = currentPosition - (arrowUp._height - 1);
    }
    function scrollPosition() {
    scrollbar._y = lineHeight * (text.scroll - 1) + (arrowUp._height - 1);
    }
    numLines = 18;
    tolerance = 1;
    speed = 5;
    origHeight = scrollbar._height;
    origX = scrollbar._x + 1;
    text = "Loading file...";
    }
    onClipEvent (enterFrame) {
    scrollResize();
    if (lastHeight != newHeight) {
    if (scaleDiff < tolerance && scaleDiff > -tolerance) {
    scrollbar._yscale = newHeight;
    heightDiff = origHeight - scrollbar._height;
    lineHeight = HeightDiff / (text.maxscroll - 1);
    rePosition = false;
    text.scroll = 1;
    scrollPosition();
    } else if (newHeight < lastHeight) {
    scrollbar._yscale -= scaleDiff / speed;
    } else if (newHeight > lastHeight) {
    scrollbar._yscale += scaleDiff / speed;
    }
    }
    if (rePosition == true) {
    currentPosition -= pixelDiff / speed;
    scrollbar._y = currentPosition;
    pixelDiff -= pixelDiff / speed;
    if (currentPosition == (arrowUp._height - 1)) {
    rePosition = false;
    }
    }
    if (startScroll == true) {
    if (scroll == "up" && text.scroll > 1) {
    text.scroll--;
    scrollPosition();
    }
    if (scroll == "down" && text.scroll < text.maxscroll) {
    text.scroll++;
    scrollPosition();
    }
    }
    if (paging == true) {
    if (hitLocation < scrollbar._y) {
    text.scroll -= numLines;
    scrollPosition();
    if (hitLocation >= scrollbar._y && hitLocation <= (scrollbar._y + scrollbar._height)) {
    paging = false;
    }
    } else {
    text.scroll += numLines;
    scrollPosition();
    if (hitLocation >= scrollbar._y && hitLocation <= (scrollbar._y + scrollbar._height)) {
    paging = false;
    }
    }
    }
    }
    onClipEvent (mouseDown) {
    if (scrollArea.hitTest(_root._xmouse, _root._ymouse) and !scrollbar.hitTest(_root._xmouse, _root._ymouse)) {
    hitLocation = this._ymouse;
    paging = true;
    resize = false;
    }
    if (arrowUp.hitTest(_root._xmouse, _root._ymouse)) {
    scroll = "up";
    startScroll = true;
    arrowUp.gotoAndPlay(2);
    resize = false;
    }
    if (arrowDown.hitTest(_root._xmouse, _root._ymouse)) {
    scroll = "down";
    startScroll = true;
    arrowDown.gotoAndPlay(2);
    resize = false;
    }
    if (scrollbar.hitTest(_root._xmouse, _root._ymouse)) {
    startDrag(scrollbar, false, origX, (arrowUp._height - 1), origX, (heightDiff + (arrowUp._height - 1)));
    scroll = "scrollbar";
    scrollbar.gotoAndPlay(2);
    resize = false;
    }
    }
    onClipEvent (mouseUp) {
    scroll = "";
    startScroll = false;
    paging = false;
    stopDrag();
    resize = true;
    scrollbar.gotoAndStop(1);
    arrowUp.gotoAndStop(1);
    arrowDown.gotoAndStop(1);
    }
    onClipEvent (mouseMove) {
    if (scroll == "scrollbar") {
    text.scroll = Math.round(((scrollbar._y - arrowUp._height) / lineHeight + 1));
    if (scrollbar._y == Math.ceil(((arrowDown._y - (arrowDown._height - 1)) - scrollbar._height))) {
    text.scroll = text.maxscroll;
    }
    }
    updateAfterEvent();
    }
    onClipEvent (data) {
    rePosition = true;
    scrollResize();
    text.scroll = 1;
    }
    "Life is too important to take seriously. Corky Siegel"

  2. #2
    Senior Member
    Join Date
    Oct 2004
    Posts
    134
    I'm having trouble reading your code. Try to put CODE tags around your code next time. Anyway Here's one line of code that will not work:
    Code:
    if (scrollArea.hitTest(_root._xmouse, _root._ymouse) and !scrollbar.hitTest(_root._xmouse, _root._ymouse)) {
    (&& instead of and)
    And i would strongly suggest you use LoadVars instead of loadVariables. Look it up in the Flash help (type LoadVars put the cursor on the word and press F1)

  3. #3
    go blues ! audas's Avatar
    Join Date
    Oct 2000
    Location
    london ,piccadily circus!
    Posts
    665
    No idea what version of flash you are using so I am going to charge you for a full days parking....................!?

    create a LoadVars object, load the vars into this then assign them to relevant areas.......lika dis
    Code:
    varsholder=new LoadVars();
    varsholder.onLoad=function(){
    textbox.text=this.varname;
    }
    varsholder.load("bio.txt");
    I would recommend placing &varname=your text; into the text file aswell,
    cheerio,
    s
    peace.

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