dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [MX] path problem with loading variables

  1. #1
    Member
    Join Date
    Oct 2005
    Posts
    84

    [MX] path problem with loading variables

    Flash MX version 6 on Mac OSX platform.

    Hi I am trying to get a text field load variables from a txt file to work when I click a button.

    It works when the text field is on the main timeline, but when it is in a movie clip it doesnt work. I know it is a path problem, but I have tryed adding _root. and all that but I cant get it to work.

    This is the code I have on the button at the moment:

    on (press) {
    loadVariables ("document1.txt", "");
    _root.infobox.mytext.scroll=x
    }

    The text field variable name is: mytext

    and I have named the movieclip the text field is in: infobox

    I haved spent hours on this and any help would be loved!

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    main problem could be timing
    trying to access the variable before it has completed loading
    plus, does the movieclip have the <instance name> - infobox ?

    try this method, using a LoadVars object -
    Code:
    // button on main timeline, <instance name> - a_btn
    // code on main timeline
    
    a_btn.onRelease = function(){
    getVars():
    };
    
    function getVars(){
    lv = new LoadVars();
    lv.onLoad = function(){ // runs when all variables have loaded
    trace(lv.x);
    _root.infobox.mytext.scroll = lv.x;
    };
    lv.load("document1.txt");
    }; // end function

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