dcsimg
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: external text file problem

Hybrid View

  1. #1
    Senior Member
    Join Date
    Apr 2002
    Posts
    2,849
    I have a text file, called images.txt. Inside the text file it says:

    &booya=DSC_1794.jpg

    On the first frame of the movie, it says:

    loadVariables("images.txt", _root);

    On the second frame of the movie, it says:

    loadMovie(booya, "thumb1");
    trace(booya);
    stop();


    On both frame 1 and 2, there is a movie clip with the instance name of thumb1. There is also a dynamic text box with the variable name of booya.

    The dynamic text box correctly reports the value of booya as being DSC_1794.jpg. However, the trace() command reports the value of booya as being undefined.

    How can Flash MX think a variable is both full and empty at the same time? Needless to say, the image is not loading, which is the goal of this little exercise before I expand it to a Flash gallery template for the site I work on.


    -Richard

  2. #2
    Senior Member
    Join Date
    Jul 2000
    Posts
    126
    The loading of the text file is taking longer than one frame. It probably completes some short time after the frame 2 actions.

    Thus your frame 2 actions see 'undefined' - but your textfield shows the correct value some time later (but probably too fast for you to notice the delay).

    You need to wait until the booya variable has a value - best way is by using the onData() event handler.

  3. #3
    Member
    Join Date
    Oct 2000
    Posts
    40
    Put your trace and your movie clip on Frame 3 (always give 2 frames for loading external files at least)


  4. #4
    Senior Member
    Join Date
    Jul 2000
    Posts
    126
    Originally posted by AoX
    Put your trace and your movie clip on Frame 3 (always give 2 frames for loading external files at least)

    If the text file is being loaded over a dial-up connection it may take dozens of frames before it is loaded, if ever.

    You also have to handle the case where the request fails, so some sort of timeout is probably also a good idea.

  5. #5
    Senior Member
    Join Date
    Apr 2002
    Posts
    2,849
    Well that seems stupid, but you're right....when I moved the actions from Frame 2 to 5, it worked. I also found that I could do the actions in concurrent frames if I just moved the loadVariables action to Frame 2 instead of 1.

    Very strange, I've never had that problem before. Thanks for the help though!

    -Richard

  6. #6
    Member
    Join Date
    Oct 2000
    Posts
    40
    Yup, # of frames needed for variables varies for different scenario. That's why it is always a must (well, at least is my strategy) to put in a check mechanism to check if variables are loaded before moving on playing the movie.

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