Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Orlando, FL
    Posts
    177
    Rep Power
    12

    Recognizing Variables


    When I load variables from a text file into my Flash movie, it works properly. But when I try to set up "If" conditions based upon the variables, it fails to read them correctly and I have to manually type the variables in.
    Is there any way to fix this? All help is much appreciated.
  2. #2
  3. No Profile Picture
    flash junkie
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Location
    CO, USA
    Posts
    172
    Rep Power
    12
    do you have an example of your code? how you access the variables depends on how you loaded them in.

    bret
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Orlando, FL
    Posts
    177
    Rep Power
    12

    re: Variables


    Hello,

    Thank you for your assistance. It was very strange... When I started to build a working example to show you... It actually worked. The one that I am having difficulty with is the calendar at www.thedarkcontent.com because it refuses to respond to the "If" conditions based upon the text file variables. I have included an fla to show you what I was having problems with.

    Sincerely,
    Jamie Michels
    Attached Files
  6. #4
  7. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Orlando, FL
    Posts
    177
    Rep Power
    12
    Oops... I made a mistake. The file that I posted does not work properly. It too, does not act upon the conditions that I specified. It should go to and stop on keyframe 2, but it refuses.
  8. #5
  9. No Profile Picture
    flash junkie
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Location
    CO, USA
    Posts
    172
    Rep Power
    12
    i think that your problem has to do with pathing. in your text file, you have "&_root.variables=Loaded" when you probably shouldn't assign the path of the variable in the text file (in fact, it was most likely the main problem).

    when you say loadVariablesNum("variables.txt",0);, you are telling flash to load all of the variables into the _level0 timeline. this means that whatever variables are present in your text file, will now exist in whatever object you loaded them in to (our object just happens to be _level0; you can load them into movieclips, timelines or _levels.) So i changed the text file to "&variables=Loaded" and then changed your script in the first frame to:

    PHP Code:
    //actionscript
    loadVariablesNum ("variables.txt"0);
    this.onEnterFrame = function ()
    {
        if (
    variables == "Loaded") {
            
    gotoAndStop (2);
            
    delete this.onEnterFrame;
        }
    };
    stop (); 
    notice i also put an onEnterFrame function to it, and changed "eq" to "==" (eq is deprecated now...) So, because i'm on the _level0 timeline, i don't need to reference anything but "variables". Once it's loaded, i kill the onEnterFrame function and then it goes to the next frame fine.

    the reason that we need the onEnterFrame function is, even when we play the file locally, it still doesn't get loaded in fast enough for just one check of if(variables=="Loaded").. so we need to check it until it resolves. hope that helps.

    cheers,

    bret
  10. #6
  11. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Orlando, FL
    Posts
    177
    Rep Power
    12
    Bret,

    Thank you very much for helping me! Your actionscript totally fixed the issue and I appreciate it.

    Sincerely,
    Jamie Michels
  12. #7
  13. No Profile Picture
    flash junkie
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Location
    CO, USA
    Posts
    172
    Rep Power
    12
    glad i can help
  14. #8
  15. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    2
    Rep Power
    0
    bret,

    I have a similar problem . I have 2 frames flash movie and a data.txt file that contains data. I want to load all data in the data.txt file in the first frame and then go to second frame. But I want to be sure that all data is loaded before going to the second frame.

    my data.txt file:

    &url1=http://www.trgamer.com
    &url2=http://www.shockhaber.com

    frame 1:
    PHP Code:
    myVars = new LoadVars();
    myVars.onLoad = function(success){
        if(
    success){
            
    trace("variables loaded successfully");
            
    gotoAndStop(2);
        } else {
            
    trace("something went wrong...");
        }
    }
    myVars.load("data.txt");
    stop(); 
    frame 2:
    PHP Code:
    getURL(url2"_blank"); 
    I expect trgamer.com open in a new window but it doesn't.
    Another problem is I can't use the variables in the data.txt file.
    For example :

    PHP Code:
    myDynamicText.text url2
    myDynamicText is dynamic text field. and it should have the text "http://www.shockhaber.com" but it hasn't

    can you help me about this?

    thank you,
    Den
    Attached Files
  16. #9
  17. No Profile Picture
    flash junkie
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Location
    CO, USA
    Posts
    172
    Rep Power
    12
    your problem seems to be much more straight forward after looking at how you loaded your variables, you just need to make sure that you refer to your LoadVars object. So, all you need to change is :

    mytext.text = myVars.url2;
    getURL(myVars.url2, "_blank");

    Because the variables that you loaded in, actually reside in the object that you loaded them in to. Your LoadVars object was called "myVars" so in order to access the variables from the text file, you need to say "myVars.url2"... hope that helps.

    cheers,

    bret
  18. #10
  19. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    2
    Rep Power
    0
    bret, thanks for the quick answer

    I was struggling with this for days
  20. #11
  21. No Profile Picture
    flash junkie
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Location
    CO, USA
    Posts
    172
    Rep Power
    12
    glad i can help (assuming it works.. which it was working when i tested it

    bret
  22. #12
  23. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Location
    Valdosta, GA
    Posts
    4
    Rep Power
    0

    you probably already answered this...


    but i'm too stupid to make this work. please help *begs*

    okay i'm using flash 5. i simplified my problem down to the bare essentials so that the flash file would be easy to read. okay here is what i've been doing.

    i create a text file named "text.txt". inside the text file i have put (on the top line)

    Version one: boo=carnival
    Version two: &boo=carnival
    Version three: boo=carnival&

    I have tried all three of these but none of them seem to work.

    okay in my flash movie. on the first frame i put the action:

    loadVariablesNum ("text.txt", 0);
  24. #13
  25. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Location
    Valdosta, GA
    Posts
    4
    Rep Power
    0

    continued


    on the fourth frame i have the action:

    if (boo == "carnival") {
    gotoAndPlay (10);
    }
  26. #14
  27. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Location
    Valdosta, GA
    Posts
    4
    Rep Power
    0

    still continued (why is it cutting off my message?)


    on the fifth frame is the action: "stop ();"
    on the tenth frame is the action: "stop ();"
  28. #15
  29. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Location
    Valdosta, GA
    Posts
    4
    Rep Power
    0

    arg .. another continue .. sorry :/


    on every frame (1-10) i have put a text box that is just a normal text box that only has the name of the frame so i know what frame number the flash movie is stopping on.

    then on every frame (1-10) i have put a dynamic text box with the variable: boo

    okay .. that is basically the file. the thing that is frustrating me so much is that in the dynamic text box it will fill in the word 'carnival'. so i know that it is opening up the right file and finding the variable for boo. it just wont go to frame 10. i've tried changing it to _root.boo or _level0.boo but these don't work either.

    if anyone understands this please help. after 3 agonizing days i'm about to give up
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo