dcsimg
A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Problem with loading variables

  1. #1
    Junior Member
    Join Date
    Jul 2000
    Posts
    15
    Hi,
    I'm trying to load variables from an external file into a movie within my flash file. If I load the variable into a dynamic text box which is in a movie within my main movie, then the text doesn't appear. If I place the dynamic textbox directly on the main stage then the text is displayed. How do I use this text in a textbox in a sub movie? Do I have to reference the variable explicitly? Here is the contents of the variable at runtime

    Variable _level0.scrolltext = "This is the text"

    Any help would be appreciated

    Keith

  2. #2
    Senior Member
    Join Date
    Mar 2000
    Posts
    182
    yo!

    say your external variable is named "lorem":

    lorem = "lorem ipsum"

    now you load it:

    loadVariable (textfile.txt)

    now you have to convert this new variable into string before operating with it:

    String(lorem);

    now you can use it

  3. #3
    Junior Member
    Join Date
    Jul 2000
    Posts
    15
    OK Daemon, I'll try that when I get the chance. I've no problem loading the variable and displaying the text in a text box on my main stage though, so not sure how this will help.

    Keith

  4. #4
    Senior Member
    Join Date
    Jun 2001
    Posts
    2,943
    Remember to give your movie clip within the main movie a name. An instance name as opposed to its symbol name in the library (though the two can be the same name).

    If the text box inside the clip is called myText, and the clip is called myClip, then you can display a variable in it from the main timeline using:
    Code:
    myClip.myText = myVariable;
    Likewise, you could display the same information using actions inside the movie clip using:
    Code:
    myText = _root.myVariable;

  5. #5
    Senior Member
    Join Date
    Mar 2000
    Posts
    182
    Ooopsie, i misunderstood.

    What you need is a named movie clip.

    So you have your variable loaded, and you need to set it insode that mc.

    _level0.yourclip.yourtxt = variable

    I got it right this time, eh?

  6. #6
    Junior Member
    Join Date
    Jul 2000
    Posts
    15
    Thanks guys, I've managed to sort this out. I hadn't given you enough information, due to posting hastily. Here's some more info on the problem.
    I had created a new movie and inserted a movie clip. One of the actions in the clip was to load the variable 'loadtext' from an external .txt file. I then placed a dynamic text box on the clip and given it the variable 'loadtext'. When I placed this movie clip on the main stage, the text didn't display the contents of the variable from the external file. If I placed the text box directly on the main stage, it did. From Daemon's suggestion, I changed the variable on the text box to explicitly reference the loaded variable eg. '_level0.loadtext' This did the trick.

    Thanks for all your help.

    Keith

  7. #7
    FK Doubt Killer hufersil's Avatar
    Join Date
    Apr 2001
    Location
    São Paulo, Brazil
    Posts
    186
    hmmm,

    in your text file, write this

    myVar=test


    then try this code below:

    Code:
    //Past this in the main timeline (_root) at FIRST FRAME
    loadVariable("myText.txt", _root);
    
    
    //Past this code at your movie clip actions panel
    //Inside your movie clip, named your variable to myVar
    //Your movie clip must be at second frame of main timeline
    onClipEvent(load) {
            myVar=_root.myVar
    }
    Its should work
    If you have some question...

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