A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Loading variables question

  1. #1
    Senior Member
    Join Date
    Nov 2000
    Location
    Columbus OH
    Posts
    178
    I have some questions about loading variables.

    This is probably a really dumb question and will kick myself later for it.

    I'm trying to load variables from a .txt file into some text fields in a movie clip. I have a graphic symbol with text variable fields named show1, show2, ect. up to 5. I have that symbol in a movie clip called show dates. I then have that movie clip on the main timeline. How do I get the variables to load into those text variable fields in the graphic symbol. I used Load Variable("shows.txt" "/")target instead of level. I tried putting that in an actions frame on the main timeline, the movie clip timeline and the graphic symbol timeline. I also tried using "../" and "../../" but nothing is working. What am I doing wrong? Thanks in advance.

    Delstrange

  2. #2
    Member
    Join Date
    Feb 2001
    Posts
    68
    Be sure your text file is in the same directory as the .swf calling them

    Put this on the first frame of the _root of your movie.
    loadVariablesNum ("data.text",0)

    This loads the variables from your text file into "_level0"


    Now from inside your movie clip scope the variables with an absolute path.

    _root.myVariable1

    etc.

    I hope this helps, Happy days.

    Garth

  3. #3
    Registered User
    Join Date
    Feb 2001
    Posts
    184
    If I understand correctly, you have the main timeline, then an MC, then an graphic, inside which is a text box?

    Make the graphic a movie clip, then give it an instance name. Then you'll need something like this:

    loadVariables ("show.txt", "_root.showdates.displayText");

    ...where "displayText" is the instance name of the graphic (now MC) containing the text box, and "showdates" is the MC containing the displayText MC.

    Any help?

  4. #4
    Member
    Join Date
    Feb 2001
    Posts
    68
    Both methods (MrBoris & and myself (agmundi)) will do the job although there is one advantage to the method I've proposed.

    Lets say that you are loading more than just a few variables,..lets say you are loading a hundred! all of wich will be used by many different movie clips all with different targets.

    Using MrBoris method you would have to scope each variable from the "loadVariables" action in the _root timeline to each seperate movie clip target.

    With my method all variables would be loaded into the _root of the main movie. This makes it very easy to scope them because you will be calling each variable from each movie clip with an absolute path.

    Example: _root.myVariable1 .... _root.variable2 ...

    It dosen't matter how convoluted or complex the target path for any of the clips calling these variables is.

    "_root" tells the clip to look for the variable in the main timeline no matter where the clip is calling it from.

    In the future this will save you much unneeded scoping.

    Hope this helps.

    Ps. MrBoris I'm not trying to best you...just trying to give an alternative. The fact that you help out (unlike many) makes you a very cool dooby.

    All the best Garth

  5. #5
    Registered User
    Join Date
    Feb 2001
    Posts
    184
    Hey Garth,

    I think we were replying to the orginal post at the same time, so I hadn't seen your reply until after I'd posted mine.

    Anyway, yours is a better solution. Damn.

  6. #6
    Senior Member
    Join Date
    Nov 2000
    Location
    Columbus OH
    Posts
    178
    Thank you very much, I got it working the way I want it to. But I had to use MrBoris' method. I like your idea Agmundi but I don't understand the scoping. How do I scope the path or what do I go to to just put in a path without using like tell target or something like that? Is there a command that just lets you enter a path in the actions tab. I looked for scope but didn't see anything. Otherwise, thank you very much for your help.

    Delstrange

  7. #7
    Member
    Join Date
    Feb 2001
    Posts
    68
    Hi there Del, I'm excited to teach you this because I know what a revilation it was for me. "Scopeing" is just a term, there is no command for it in any of the "actions menus" ...... Think of the "scope" of a variable as you would think of the "target" of a movieclip. A variable may be scoped in either direction, the fist direction is what you are using now .
    1. When you initialize a variable you can scope it to the object that will be using it. (like you've been doing)
    2. Or.. you can scope the variable from the object that will be using it, it's sort of like calling the variable in reverse. Try the following ....It will explain everything.

    On a frame in the _ root. of your main timeline set a variable myText = "Chuck Berry"

    Now select one of your dynamic text boxes.
    In the variable window of the Text Options for your dynamic text enter _root.myText

    it doesn't matter where the dynamic text box is (inside a movie clip, or even inside of a clip, inside of a clip, etc.)
    "_root." makes it skip all of the targeting and start looking for the variable,... guess where?..at the _root.
    Eureka!....All the best,...Garth

  8. #8
    Junior Member
    Join Date
    Apr 2001
    Posts
    14
    I tried doing this, with no luck.. Here's the situation:

    I need the data to be displayed from a txt file into a movie clip. I can do this in the main timeline, but no luck from inside the MC.

    My text file: top10.txt
    variables look like this:
    artist_01=blahblahblah
    &song_01=yayayaya

    I have dynamic text fields in the MC named according to the above variables.(artist_01, etc)

    I tried using this:
    loadVariablesNum ("data.txt", 0);
    (in the first frame on the main timeline)

    then tried loading them in the main timeline by renaming the dynamic variable fields to:

    _root.artist_01

    NO LUCK! (cries)

    I can accomplish this using the "set variables" as mentioned just above this post, but no luck loading variables from the top10.txt file.

    Someone PLEASE help me ....
    [Edited by net-kinetix on 06-16-2001 at 08:21 PM]

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