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 2, 2006
there's no logout child in the file i downloaded. did you add the child movieclip? if so, will it be visible after its parent is tweened?
December 2, 2006
all the usr_+usrName mc's have a mc in them. When the usr_+usrName movieclip transitions down via the tweenF function and it reaches the bottom, this logout movieclip should slide out as the tween suggests.
kglad
Community Expert
Community Expert
December 2, 2006
what's movieclips have a child logout?
December 2, 2006
okay i cant figure it out - i have tried everything...

new mx.transitions.Tween(tl["usr_"+usrName].logout
does not work
new mx.transitions.Tween(usr_matt.logout
does work

I did a trace right before its called and usrName = matt at this stage...then why on earth doesnt the first one work?!

kglad - the movieclip loaders are what load the editlist.swf into the movie...at least that was the plan lol.
December 2, 2006
i figured one of the issues was because the mymessage function was defined twice (dont laugh it took me a little while to see!) i was trying to generalize that function like you have the rest to take the usrName var and use it instead of wiritng it for each user. I am having problems with this line...

new mx.transitions.Tween(usr_matt.logout, "_x", mx.transitions.easing.Bounce.easeOut, 25, 140, 3, true);

it seems it only works if i reference it like that, if i cange it to ("usr_"+usrName.logout,) it doesnt work, no matter how i try to reference it, but it works for everything else! go figure :S

As well - as i said i want everything but the "usr_"+usrName to fade out (right now its only one that does) now in my head im seeing (and from what ive seen you do) and array will be the way to do it? except somehow exlude usrName?

--][--
kglad
Community Expert
Community Expert
December 2, 2006
oh, i ididn't check myMessage. here's a corrected version with myMessage being called. i'm not sure what your moviecliploader's are supposed to do so they're probably not going to work:

December 1, 2006
Hey kglad - thank you SO much for that! I am doing my best to look it all over and see what you have done to tidy it up! looks so much cleaner!....but....it doesnt work. Im sure its hard writing the code without knowing how it will work lol, you've done amazing! i provided a link at the bottom to the fla's to see for yourself. For one, (and i dont know how to adapt the code for this) when you login as say matt, the "matt box" should fall from its current y position to the specified, while all others (4 of them) fade out. they are all in a column though so i dont think thats going to work like that, as the current tween class is specifiying an y value to start from (in this case 48, which is the matt box y value, the ryan y value may be 130 and so forth...
"var drop:Object = new mx.transitions.Tween(usrName, "_y", mx.transitions.easing.Bounce.easeOut, 48, 380, 2, true);"
as well - give it a test run and see for yourself what goes on - i cant account for it, maybe you can shine some light?

again kglad - i feel really bad for constantly asking you to save me, but i really am getting there (especially with that last bit of cleaned up code!) i have a tendency to make huge long overredundant scripts so this should help me collapse things a little!.

Thanks again good Sir,

link: http://mattgroth.echointernet.net/temp/Lists.zip

--][--
November 30, 2006
kglad I really cannot thank you enough. Honestly! i was going to give you an email but i was wearing of just using that flash form (didnt know when/if you would get it) Again - thank you so much! i have always been able to use flash and write code, not well by any means, but your really helping me take it to the next level for me and thats great because i love this stuff! Thank you again!

--][--
kglad
Community Expert
Community Expert
December 1, 2006
i removed usrA from login.fla. otherwise the following code includes all the coding needed no matter how many users you add to usrA.

kglad
Community Expert
Community Expert
November 30, 2006
i'll let you know how to simplify that when i get back from work. gotta go see patients.
November 30, 2006
not very at all! i mean, not in the least would probably be a better way of putting it!

I would actually considering redoing this all at some point using php/mySQL as suggested in the future - and that will be more secure, but for now, this is MORE than enough for sure.

next thing would be - how on earth do we define all the usrnames and passwrds in a looping array??! im all ears.

p.s. thank you for comming back! lol.
--][--
kglad
Community Expert
Community Expert
November 30, 2006
you just need to keep adding [username,passwords] to usrA to authorize more users.

November 30, 2006
Kglad that works like a dream! a very clever use of the array there i will certainly have to remember that! (its not very secure though you say?)

Okay your going to laugh at me im sure...but i have attatched my code for "desktop.fla" as well as what i got currently for "login.fla" it seems when the button is fired it triggers the the wrong movieclip....as you can see from the code I attatched it works flawleslly with just the 1 MC on the stage coded. But as soon as i add the next one "under the //----ryan---- comment line - no matter who i login be it matt or ryan it fires ryans animations. I have 3 more to add after ryan and i tried it and in the case when all 5 are in, no matter who i login is it fires the last one all the time. I am sure it has something to do with my code structure, i have just been copying the first MC's code and changing the references to it, to the new one as i go...you will see...what have i done wrong? i know its a Sod.
kglad
Community Expert
Community Expert
November 30, 2006
you can list all your username/password combinations in an array and loop through the array to check if a correct login is recognized.

but before you go much further, how secure is this supposed to be?