Skip to main content
November 29, 2006
Question

refreshing without looping???

  • November 29, 2006
  • 41 replies
  • 2635 views
Hello everyone - i am trying to build something using mostly code but i am having a SERIOUS issue with the fact that i can only get it to work properly if i have it spanning 2 frames with my code on the first, and code on frame 2 simply "gotoAndPlay(1);" to loop it so my script keeps being rechecked for changes in variables. Because i have things trigger when variables change...heres what i mean.

if(_global.logged=="true"&&faded==false){
new Tween(usr_matt, "_alpha", Strong.easeOut, 100, 0, 2, true);
faded==true;
}

which should trigger when a loaded swf sets the global logged variable to true. But unless i loop the timeline to keep checking the variables nothing happens because it doesnt know its changed, it doesnt watch/listen to it. the problem with this in this case is everytime the timeline loops it reinitilizes that if statement and starts the tween all over again, meaning it never fades because it keeps restarting the fade!

another example being -

if (usr_name.text=="Matt"&&usr_pass.text=="test"){
submit.enabled=true
}else{
submit.enabled=false
}

here i disable the submit button until the fields match, so again i needed to loop the timeline to keep the variables updating to see when the fields did match! unfortunatly that messed up the next bit of code so i had to impliment a work around for it

if(init<=1){
usr_name.text = des_usr;
init=3
}

where i have a text field that inherits its .text value initially from a global variable, but then in order (just in case) the user wants to change the value (if they dont like the default) i needed to break to loop by making a whole new variable to cancel it out once its been triggered once!

My head is just starting to hurt with ALL the variables im assinging and i havnt really even dont anything yet but make a popup box and pass some variables...but christ...i cant have every timeline on a loop that would bog everything down SO much, eventually i will have 4-5 loaded swf's on at once, all looping? i dont think so...

There HAS to be a better way to do it, to assing certain If statements to constatly update without looping the whole damn thing!

--][--
This topic has been closed for replies.

41 replies

kglad
Community Expert
Community Expert
December 3, 2006
you're welcome. :)
December 3, 2006
Thank you SO much klad!

I have it all sorted, and running now so thats wonderful! i owe it all to you my friend. Thank you so much for all the gracious help you have extended towards me, its rare to get such wonderful help from people on forums, but your a breath of fresh air. Thank you.
December 2, 2006
1. all loginbuttons fade to zero except the usr that correctly logged-in
2. the correctly logged usr log-in button drops to stage bottom and displays a logout tag
3. when the logout tag is pressed, the logout button retracts.
4.The usr login-in button slides back to its original location.
5.other login-in buttons fade back in.
6.whole process is ready to start again.

better? Great idea that by the way.

thanks again!

--][--
kglad
Community Expert
Community Expert
December 3, 2006
try:

December 3, 2006
so nearly there! you have been an absolute star thus far! i really, cannot tell you how thankful i am! As i said, SO nearly.

Everything works to a tee except; this is what happens.

1.click usr login button and login screen appears - login no problem
2.button drops down flawlessly, others fade off
3. logout button slides out.
4. click logout it resets perfectly
5. login as another user, drops down and logout slides out again no problem.
6. click to logout and your presented with the login screen again.

as near as i can tell from a trace, after the first login and cleanup pass the logged_usr variable is not being defined anymore. the cleanup resets the variable to " "; and after loggin in a second time with another user the trace still says " "; so ther variable stops being passed after the first login it seems.

you have the desktop code there, i attatched the login code as thats where the variable is defined. i cant understand why it would just stop working after the first go...hmm

--][--
kglad
Community Expert
Community Expert
December 2, 2006
ok, what do you want to have happen after a correct login is recognized? answer with something like:

1. all loginbuttons fade to zero except the usr that correctly logged-in
2. the correctly logged usr log-in button drops to stage bottom and displays a logout tag
3. something happens when the logout tag is clicked?

December 2, 2006
okay i understand that, looks good.

I was able to make it work for the dropping down

var drop:Object = new mx.transitions.Tween(tl["usr_"+usrName], "_y", mx.transitions.easing.Bounce.easeOut, tl["usr_"+usrName].startY, 380, 2, true);

but it doesnt seem to do anything unless i say (for example) usr_ryan or something, it wont seem to pick it up for me using "tl["usr_"+usrName]." as shown.

new mx.transitions.Tween(tl["usr_"+usrA[0]], "_y", mx.transitions.easing.Bounce.easeOut, 380, tl["usr_"+usrName].startY, 2, true);

thoughts?
as well - how do i fade everyone, except the usr+usrname? right now it fades ONLY the usr_+usrName, whereas i want them all to fade except.

new Tween(tl["usr_"+usrName], "_alpha", Strong.easeIn, 100, 0, 2, true);
December 2, 2006
ah sorry - didnt noticed the drop.onMotionFinished changed - that fixed it! your a genius.

Next thing - if you run that file you just downloaded (although the version you have doesnt work with the changes you just mentioned) you should be able to figure out that if say you login as matt, the matt button drops down fine - and you can then logout just fine. it will bounce back up where it needs to be. Now try with say kat, as soon as you login it starts the drop from matts y value, and when you click logout it bounces up again to matts y value. how do make it so it remembers its initial y value and starts/returns to there instead of setting a predefined one?

sorry its hard to explain, if you run it you will see what i mean. Thanks again kglad, i owe you one!

--][--
kglad
Community Expert
Community Expert
December 2, 2006
in the for-loop you can assign a variable to each usr that will store their initial _y property:

kglad
Community Expert
Community Expert
December 2, 2006
you didn't use the code i supplied in my most recent posted code.

replace your code for myMessage() with mine and change your drop.onMotionFinished function to match mine.
December 2, 2006
kglad
Community Expert
Community Expert
December 2, 2006
404 errror.
December 2, 2006
http://mattgroth.echointernet.net/works.zip

just publish the login to get the SWF then run the desktop.fla to see what i mean - login as matt - test to see how it should work. you will not i had to change the code to new mx.transitions.Tween(usr_matt.logout for it to work (which means if you try loggin in as anyone else it will be wrong. hope that helps. thanks again kglad.