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

November 30, 2006
Indeed i have seen such options - and to be completly honest that seems beyond the scope of what Im trying to do. If i was doing this for a more serious project and needed expandability and such i would ceratinly try to utilize php/mySQL. Fortunatly/unfortunatly this has just been an idea I started off with that has grown (couldnt have gotten where i am now though without kglads help, hes been great! - But thank you flash2koolforskool, i appreciate the thought!

Still having the issues though with the system i have now, for those who dont know...

lo.change = function(eventObject:Object) {
if (usr_name.text.toLowerCase() == "matt" && usr_pass.text.toLowerCase() == "test") {
submit.enabled = true;
} else {
submit.enabled = false;
}
}
};

is what im using, and i need to somehow get more possible usernames and passowrd in there! not many! just 4 more. ideas?!

--][--
Participant
November 30, 2006
Do you have any experience with php/mySQL?

It sounds like you could use a database to store all of the login data and use php to check if the data entered into the flash form exists in the database , then if it does return yes and if it doesn't return no.

The do whatever is required after the login depending on the php return.

November 30, 2006
I guess i could copy the lo. change function 5 times...i dont know if that would work...and it certainly doesnt seem practicle, im still have a problem with it taking the most recently added username/pass. I cant see any other way of adding the other than "||" after the first pair really. thoughts?

--][--
November 30, 2006
Hey kglad, once again - you are my savior lol.

I have been making some progress (even though im sure im doig it all wrong!)

I have run into an issue, i am not trying to add more sets of usernames and passwords to what we alreayd have, unfotunatly its not like i can just add another if statement to the mix, or append whats there with a ||. So again, i am at a loss, no matter what i do it seems to just accept the last once i entered and completly ignores the rest. Thoughts?
November 30, 2006
// Create window.
var my_win:MovieClip = PopUpManager.createPopUp(this, Window, true, {title:"Please Login", closeButton:true, contentPath:"login.swf"});
var winListener:Object = new Object();
winListener.click = function() {
my_win.deletePopUp();
};
my_win.addEventListener("click", winListener);
my_win.setSize(350, 163);
my_win.move(200, 150);
}
kglad
Community Expert
Community Expert
November 30, 2006
oh no, another component.

but using _global in login.fla saves us from using the path _level0.depthChild0.content to your popup. so, the problem isn't the path, it's your attempt to attach a listener to a variable which has some problems.

there's a more direct solution in this situation: you can call a function in your desktop.fla from your submit button in login.fla:

kglad
Community Expert
Community Expert
November 30, 2006
you shouldn't prefix a variable name with _global (or var) unless you are assigning a value to it. when you're retrieving a value, the prefix should not be used.

so, in login.fla you correctly use

_global.logged_usr = usr_name.text;

removing the _global prefix from desktop.fla may be all you need to do. but if that doesn't work, then i'll need to know how these two swfs are related.

for example, do you use loadMovieNum() to load one of them?
November 30, 2006
Okay I Do appreciate all you have don VERY much, and you are by no means obligated to help me any further if you dont wish, please dont think i am just tryig to get you to do this i really am trying to learn here. I have tried to bring what you did over to my desktop.fla. I was trying to set it up so when you logged in, the variable "_global.logged_usr" would represent who logged in, it would then be collected by the desktop.fla and do a little animation thing. I did this:

log = new Object();
log.change = function(eventObject:Object) {
if (_global.logged_usr.text.toLowerCase() == "matt") {
trace("established");
new Tween(usr_matt, "_alpha", Strong.easeIn, 100, 0, 3, true);
}
}

logged_usr.addEventListener("change", log);

I get no response from the trace so its not even getting to that point. anyideas where i have gone wrong? it looks fine to me based on what we did in the previous movie. and we cant blame components this time neither! lol.
kglad
Community Expert
Community Expert
November 30, 2006
the last line is to make the submit button disabled by default. it's only enabled when the correct user name/pass are entered. that code can be removed.

p.s. i have no messenger clients. i have an email link at my website:

www.gladstien.com
November 30, 2006
Thank you so much kglad - truely a god amoungst mortals. if you dont mind me asking - did you have messenger or anything like that?

as well - the last line of code "submit.enabled = 0" where/what is that doing? the rest is beautiful!
kglad
Community Expert
Community Expert
November 30, 2006
the dreaded components. you're using a textinput component. that's not the same as an input textfield. in particular, there's no variable associated with a textinput component.

anyway, here's a working version of your login.fla. i did not edit desktop.fla:

www.gladstien.com/new/login.fla