TwelvestoneFlash

as2 - controlling timeline with variables loaded into dynamic text field


Sign in

  • Waiting for Godot ( 720 k posts )
    Just conversation.
  • Thunder Dome ( 23 k posts )
    Photoshop Tennis and Collabs.
  • Photography ( 4.8 k posts )
    For all you shutterbugs, sh...
  • Flash ( 18 k posts )
    ActionScripting to tweens, ...
  • Front End ( 5.8 k posts )
    general front end design an...
  • Back End ( 9.6 k posts )
    serverside scripting, progr...
  • Projects and Theory ( 12 k posts )
    This forum is for discussio...
  • FAQ ( 269 posts )
    All those nagging questions...
  • Design ( 17 k posts )
    graphics & all aspects of g...
  • Purgatory ( 3.6 k posts )
    12stone Jail, feel free to ...
arigato
 
2009-11-05

So, basically I need to create a toggle.

I created a dynamic textfield named "alert", with the variable as "alert'.

I then created a text file named "alert.txt" simply containing the following: alert=red

I have a label on frame 2, "red".

Here's the actions I have on my timeline: stop(); urlLoadVar = new LoadVars(); urlLoadVar.load("alert.txt"); urlLoadVar.onLoad = function (success){ if (success == true) { alert.text=urlLoadVar.alert; gotoAndStop(alert);

} }

The text field does indeed display "red" but it don't go. Thoughts?

DontBogartMe
 
2009-11-05

yup, try:

gotoAndStop(urlLoadVar.alert);

  • you missed the "urlLoadVar." bit out.
arigato
 
2009-11-05

like this? stop(); urlLoadVar = new LoadVars(); urlLoadVar.load("alert.txt"); urlLoadVar.onLoad = function (success){ if (success == true) { alert.text=urlLoadVar.alert; gotoAndStop(urlLoadVar.alert);

} }

That doesn't work either.

I also tried stop(); urlLoadVar = new LoadVars(); urlLoadVar.load("alert.txt"); urlLoadVar.onLoad = function (success){ if (success == true) { alert.text=urlLoadVar.alert; gotoAndStop("urlLoadVar.alert");

} } to no avail.

as a test I tried stop(); urlLoadVar = new LoadVars(); urlLoadVar.load("alert.txt"); urlLoadVar.onLoad = function (success){ if (success == true) { alert.text=urlLoadVar.alert; gotoAndStop("red");

} }

Which does indeed go to the correct label.

DontBogartMe
 
2009-11-05

you know why this didn't work right? gotoAndStop("urlLoadVar.alert");

cos the quotes around it tell Flash that it's a string - so just take it as it is. If you remove the quotes as you should, it tells Flash that it's a variable, in other words "give me whatever value the variable urlLoadVar.alert has right now". Which should be "red" of course... but isn't.

I'm stabbing a wild guess myself now TBH, but try this concoction:

gotoAndStop(urlLoadVar.alert.toString());

and also add

trace("urlLoadVar.alert.toString() = " + urlLoadVar.alert.toString()); to see what it really equates to.

arigato
 
2009-11-05

It traces urlLoadVar.alert.toString() = red Which seems correct, no? But still the frame does not advance.

DontBogartMe
 
2009-11-05

have you got a carriage return or any other whitespace at the end of your text file? I tested it here, and it worked fine. Then I added a carriage return and it broke the way you described.

DontBogartMe
 
2009-11-05

you can also end it like this:

alert=red&

with that extra ampersand, since that's the separating character it isn't read in as part of the value of "alert", and having it there means that if you do accidentally add whitespace, it won't mess up your app.

arigato
 
2009-11-05

Noice, that was exactly the problem. Thanks again, you're a gentleman and a scholar.

DontBogartMe
 
2009-11-05

alert=red&

whatever

even that junk worked fine k

DontBogartMe
 
2009-11-05

no prob

Sorry, you must be a member to post to a conversation. Either log in or sign up to get involved.
TwelvestoneFlash

as2 - controlling timeline with variables loaded into dynamic text field