flash actionscript:
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! --][--
thank you kglad for the quick response! would you mind just a quick "how" say with one of the example i provided that would be great! obviously i have never heard of the watch function and it sounds like exactly what im looking for!, again - thank you!
if you associate variables with your textfields, you can use: loginCheck = function (prop, oldVal, newVal) { if (usrNameVar == "Matt" && usrPassVar == "test") { submit.enabled = true; } else { submit.enabled = false; } return newVal; }; watch("usrNameVar", loginCheck); watch("usrPassVar", loginCheck);
yes. you will probably want to use different functions for the various tasks, but any variable can be watched. object properties can be watched, too but i had trouble setting up a watch method for the text property of a textfield. that's why i resorted to using a variable associated with a textfield.
Ah well you just answered my next question - i was going to say can i not just get it to watch the .text property instead of putting it to a variable first. No matter though i think i can sort that out. by different functions you do mean loginCheck = function (prop, oldVal, newVal changing the loginCheck name right? by the way what are the handlers on there? prop, oldVal, newVal - what are they each doing? cheers!
okay next question - how am i appending the text fields .text property to the variables usrNameVar - usrPassVar? because again - it wont update the variable while i type, only when its reloaded...so...are we not just back to where we started?
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: // in your login.fla submit.onRelease = function() { _level0.tweenF(usr_name.text.toLowerCase()); _parent.deletePopUp(); }; // in your desktop.fla function tweenF(usrName) { new Tween(_level0["usr_"+usrName], "_alpha", Strong.easeIn, 100, 0, 3, true); }
if your textfields are created in the authoring environment check the properties panel. there's a Var: input region where you can enter a variable name. or you can use the variable property of textfields to add the variable name using actionscript. for example: usr_name.variable="usrNameVar";
usr_name.variable=usrNameVar; usr_pass.variable=usrPassVar; loginCheck = function (prop, oldVal, newVal) { if (usrNameVar == "Matt" && usrPassVar == "test") { submit.enabled = true; } else { submit.enabled = false; } return newVal; }; watch("usrNameVar", loginCheck); watch("usrPassVar", loginCheck); does absolutly nothing...doesnt disable the box or anything...
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
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!
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
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.
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?
// 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); }
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?
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? --][--
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.
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... [code] lo.change = function(eventObject:Object) { if (usr_name.text.toLowerCase() == "matt" && usr_pass.text.toLowerCase() == "test") { submit.enabled = true; } else { submit.enabled = false; } } }; [/code] is what im using, and i need to somehow get more possible usernames and passowrd in there! not many! just 4 more. ideas?! --][--
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?
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 do that?! im all ears. p.s. thank you for comming back! lol. --][--
you just need to keep adding [username,passwords] to usrA to authorize more users. usrA = [["matt", "test"], ["joe", "joepass"], ["roger", "mypass"]]; // <-- this is the only line that needs to be changed to allow more users. lo.change = function(eventObject:Object) { for (var i = 0; i<usrA.length; i++) { if (usr_name.text.toLowerCase() == usrA[i][0] && usr_pass.text.toLowerCase() == usrA[i][1]) { submit.enabled = true; } } };
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. import mx.transitions.*; import mx.transitions.easing.*; import mx.managers.PopUpManager; import mx.containers.Window; _global.logged_usr = ""; _global.des_usr; _global.logged; usr_matt.onPress = function() { if(des_usr!=logged_usr){ //--Set desired user var _global.des_usr = "Matt"; // 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); }else{ //--cleanup-- my_win.deletePopUp(); unloadMovie(holder_mc); new Tween(usr_dad, "_alpha", Strong.easeOut, 0, 100, 3, true); new Tween(usr_mom, "_alpha", Strong.easeOut, 0, 100, 3, true); new Tween(usr_kat, "_alpha", Strong.easeOut, 0, 100, 3, true); new Tween(usr_ryan, "_alpha", Strong.easeOut, 0, 100, 3, true); new mx.transitions.Tween(usr_matt.logout, "_x", mx.transitions.easing.Strong.easeOut,140, 25, 2, true); new mx.transitions.Tween(usr_matt, "_y", mx.transitions.easing.Bounce.easeOut, 380, 48, 2, true); logged_usr = ""; } }; // in your desktop.fla function tweenF(usrName) { new Tween(usr_ryan, "_alpha", Strong.easeIn, 100, 0, 2, true); new Tween(usr_kat, "_alpha", Strong.easeIn, 100, 0, 2, true); new Tween(usr_mom, "_alpha", Strong.easeIn, 100, 0, 2, true); new Tween(usr_dad, "_alpha", Strong.easeIn, 100, 0, 2, true); var drop:Object = new mx.transitions.Tween(usr_matt, "_y", mx.transitions.easing.Bounce.easeOut, 48, 380, 2, true); drop.onMotionFinished = myMessage; } function myMessage() { var mcl_obj:Object = new Object(); mcl_obj.onLoadInit = function(target_mc:MovieClip) { new Tween(target_mc, "_alpha", Strong.easeIn, 0, 100, 2, true); TransitionManager.start(target_mc, {type:Fly, direction:Transition.IN, duration:2, easing:Back.easeInOut, startPoint:6}); }; var my_mcl:MovieClipLoader = new MovieClipLoader(); my_mcl.addListener(mcl_obj); my_mcl.loadClip("editlist.swf", holder_mc); new mx.transitions.Tween(usr_matt.logout, "_x", mx.transitions.easing.Bounce.easeOut,25, 140, 3, true); } //---------------RYAN------------------------// usr_ryan.onPress = function() { if(des_usr!=logged_usr){ //--Set desired user var _global.des_usr = "Ryan"; // 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); }else{ //--cleanup-- my_win.deletePopUp(); unloadMovie(holder_mc); new Tween(usr_matt, "_alpha", Strong.easeOut, 0, 100, 3, true); new Tween(usr_kat, "_alpha", Strong.easeOut, 0, 100, 3, true); new Tween(usr_mom, "_alpha", Strong.easeOut, 0, 100, 3, true); new Tween(usr_dad, "_alpha", Strong.easeOut, 0, 100, 3, true); new mx.transitions.Tween(usr_ryan.logout, "_x", mx.transitions.easing.Strong.easeOut,140, 25, 2, true); new mx.transitions.Tween(usr_ryan, "_y", mx.transitions.easing.Bounce.easeOut, 380, 130.4, 2, true); logged_usr = ""; } }; function tweenF(usrName) { new Tween(usr_matt, "_alpha", Strong.easeIn, 100, 0, 2, true); new Tween(usr_kat, "_alpha", Strong.easeIn, 100, 0, 2, true); new Tween(usr_mom, "_alpha", Strong.easeIn, 100, 0, 2, true); new Tween(usr_dad, "_alpha", Strong.easeIn, 100, 0, 2, true); var drop:Object = new mx.transitions.Tween(usr_ryan, "_y", mx.transitions.easing.Bounce.easeOut, 130.4, 380, 2, true); drop.onMotionFinished = myMessage; } function myMessage() { var mcl_obj:Object = new Object(); mcl_obj.onLoadInit = function(target_mc:MovieClip) { new Tween(target_mc, "_alpha", Strong.easeIn, 0, 100, 2, true); TransitionManager.start(target_mc, {type:Fly, direction:Transition.IN, duration:2, easing:Back.easeInOut, startPoint:6}); }; var my_mcl:MovieClipLoader = new MovieClipLoader(); my_mcl.addListener(mcl_obj); my_mcl.loadClip("editlist.swf", holder_mc); new mx.transitions.Tween(usr_ryan.logout, "_x", mx.transitions.easing.Bounce.easeOut,25, 140, 3, true); } -----------------------------login.fla----------------------------------- usr_name.text = des_usr; focusManager.setFocus(usr_pass); lo = new Object(); usrA = [["matt", "test"], ["ryan", "test2"], ["kat", "test3"], ["mom", "test3"], ["dad", "test4"]]; // <-- this is the only line that needs to be changed to allow more users. lo.change = function(eventObject:Object) { for (var i = 0; i<usrA.length; i++) { if (usr_name.text.toLowerCase() == usrA[i][0] && usr_pass.text.toLowerCase() == usrA[i][1]) { submit.enabled = true; } } }; usr_name.addEventListener("change", lo); usr_pass.addEventListener("change", lo); //--Button Action-- submit.onRelease = function() { _global.logged_usr = usr_name.text; _level0.tweenF(usr_name.text.toLowerCase()); _parent.deletePopUp(); }; submit.enabled = 0;
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! --][--
i removed usrA from login.fla. otherwise the following code includes all the coding needed no matter how many users you add to usrA. import mx.transitions.*; import mx.transitions.easing.*; import mx.managers.PopUpManager; import mx.containers.Window; tl = this; _global.logged_usr = ""; _global.des_usr; _global.logged; _global.usrA = [["matt", "test"], ["ryan", "test2"], ["kat", "test3"], ["mom", "test3"], ["dad", "test4"]]; for (var i = 0; i<usrA.length; i++) { tl["usr_"+usrA[i][0]].ivar = i; tl["usr_"+usrA[i][0]].onPress = function() { if (des_usr != logged_usr) { //--Set desired user var _global.des_usr = usrA[this.ivar][0]; // 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); } else { //--cleanup-- my_win.deletePopUp(); unloadMovie(holder_mc); for (var j = 0; j<usrA.length; j++) { if (j != this.ivar) { new Tween(tl["usr_"+usrA[j][0]], "_alpha", Strong.easeOut, 0, 100, 3, true); } else { new mx.transitions.Tween(tl["usr_"+usrA[j][0]].logout, "_x", mx.transitions.easing.Strong.easeOut, 140, 25, 2, true); new mx.transitions.Tween(tl["usr_"+usrA[j][0]], "_y", mx.transitions.easing.Bounce.easeOut, 380, 48, 2, true); logged_usr = ""; } } } }; } function tweenF(usrName) { new Tween(tl["usr_"+usrName], "_alpha", Strong.easeIn, 100, 0, 2, true); var drop:Object = new mx.transitions.Tween(usrName, "_y", mx.transitions.easing.Bounce.easeOut, 48, 380, 2, true); drop.onMotionFinished = myMessage; } function myMessage() { var mcl_obj:Object = new Object(); mcl_obj.onLoadInit = function(target_mc:MovieClip) { new Tween(target_mc, "_alpha", Strong.easeIn, 0, 100, 2, true); TransitionManager.start(target_mc, {type:Fly, direction:Transition.IN, duration:2, easing:Back.easeInOut, startPoint:6}); }; var my_mcl:MovieClipLoader = new MovieClipLoader(); my_mcl.addListener(mcl_obj); my_mcl.loadClip("editlist.swf", holder_mc); new mx.transitions.Tween(usr_matt.logout, "_x", mx.transitions.easing.Bounce.easeOut, 25, 140, 3, true); } function myMessage() { var mcl_obj:Object = new Object(); mcl_obj.onLoadInit = function(target_mc:MovieClip) { new Tween(target_mc, "_alpha", Strong.easeIn, 0, 100, 2, true); TransitionManager.start(target_mc, {type:Fly, direction:Transition.IN, duration:2, easing:Back.easeInOut, startPoint:6}); }; var my_mcl:MovieClipLoader = new MovieClipLoader(); my_mcl.addListener(mcl_obj); my_mcl.loadClip("editlist.swf", holder_mc); new mx.transitions.Tween(usr_ryan.logout, "_x", mx.transitions.easing.Bounce.easeOut, 25, 140, 3, true); }
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, --][--
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: import mx.transitions.*; import mx.transitions.easing.*; import mx.managers.PopUpManager; import mx.containers.Window; tl = this; _global.logged_usr = ""; _global.des_usr; _global.logged; _global.usrA = [["matt", "test"], ["ryan", "test2"], ["kat", "test3"], ["mom", "test3"], ["dad", "test4"]]; for (var i = 0; i<usrA.length; i++) { tl["usr_"+usrA[i][0]].ivar = i; tl["usr_"+usrA[i][0]].onPress = function() { if (des_usr != logged_usr) { //--Set desired user var _global.des_usr = usrA[this.ivar][0]; // 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); } else { //--cleanup-- my_win.deletePopUp(); unloadMovie(holder_mc); for (var j = 0; j<usrA.length; j++) { if (j != this.ivar) { new Tween(tl["usr_"+usrA[j][0]], "_alpha", Strong.easeOut, 0, 100, 3, true); } else { new mx.transitions.Tween(tl["usr_"+usrA[j][0]].logout, "_x", mx.transitions.easing.Strong.easeOut, 140, 25, 2, true); new mx.transitions.Tween(tl["usr_"+usrA[j][0]], "_y", mx.transitions.easing.Bounce.easeOut, 380, 48, 2, true); logged_usr = ""; } } } }; } function tweenF(usrName) { new Tween(tl["usr_"+usrName], "_alpha", Strong.easeIn, 100, 0, 2, true); var drop:Object = new mx.transitions.Tween(tl["usr_"+usrName], "_y", mx.transitions.easing.Bounce.easeOut, 48, 380, 2, true); drop.onMotionFinished = function() { myMessage(usrName); }; } function myMessage(usrName) { var mcl_obj:Object = new Object(); mcl_obj.onLoadInit = function(target_mc:MovieClip) { new Tween(target_mc, "_alpha", Strong.easeIn, 0, 100, 2, true); TransitionManager.start(target_mc, {type:Fly, direction:Transition.IN, duration:2, easing:Back.easeInOut, startPoint:6}); }; var my_mcl:MovieClipLoader = new MovieClipLoader(); my_mcl.addListener(mcl_obj); my_mcl.loadClip("editlist.swf", holder_mc); new mx.transitions.Tween(tl["usr_"+usrName].logout, "_x", mx.transitions.easing.Bounce.easeOut, 25, 140, 3, true); }
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? --][--
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.
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.
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.
you didn't use the code i supplied in my most recent posted code.
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! --][--
in the for-loop you can assign a variable to each usr that will store their initial _y property: for (var i = 0; i<usrA.length; i++) { tl["usr_"+usrA[i][0]].ivar = i; tl["usr_"+usrA[i][0]].startY = tl["usr_"+usrA[i][0]]._y;
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[j][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);
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?
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! --][--
your user's shouldn't be trying to log-in as someone else... . anyway, this is a fix: import mx.transitions.*; import mx.transitions.easing.*; import mx.managers.PopUpManager; import mx.containers.Window; tl = this; _global.logged_usr = ""; _global.des_usr; _global.logged; _global.usrA = [["matt", "test"], ["ryan", "test2"], ["kat", "test3"], ["mom", "test3"], ["dad", "test4"]]; maxY = 0; for (var i = 0; i<usrA.length; i++) { tl["usr_"+usrA[i][0]].ivar = i; tl["usr_"+usrA[i][0]].startY = tl["usr_"+usrA[i][0]]._y; maxY = Math.max(maxY, tl["usr_"+usrA[i][0]].startY); tl["usr_"+usrA[i][0]].onPress = function() { _global.des_usr = usrA[this.ivar][0]; if (des_usr != logged_usr) { //--Set desired user var // 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); } else { //--cleanup-- _global.des_usr = null; _global.logged_usr = ""; my_win.deletePopUp(); unloadMovie(holder_mc); for (var j = 0; j<usrA.length; j++) { if (j != this.ivar) { new Tween(tl["usr_"+usrA[j][0]], "_alpha", Strong.easeOut, 0, 100, 3, true); } else { new mx.transitions.Tween(tl["usr_"+usrA[j][0]].logout, "_x", mx.transitions.easing.Strong.easeOut, 140, 25, 2, true); new mx.transitions.Tween(tl["usr_"+usrA[j][0]], "_y", mx.transitions.easing.Bounce.easeOut, maxY+tl["usr_"+usrA[j][0]]._height+20, tl["usr_"+usrA[j][0]].startY, 2, true); } } } }; } function tweenF(usrName) { //new Tween(tl["usr_"+usrName], "_alpha", Strong.easeIn, 100, 0, 2, true); for (var j = 0; j<usrA.length; j++) { if (usrA[j][0] != usrName) { new Tween(tl["usr_"+usrA[j][0]], "_alpha", Strong.easeIn, 100, 0, 2, true); } } var drop:Object = new mx.transitions.Tween(tl["usr_"+usrName], "_y", mx.transitions.easing.Bounce.easeOut, tl["usr_"+usrName].startY, maxY+tl["usr_"+usrName]._height+20, 2, true); drop.onMotionFinished = function() { myMessage(usrName); }; } function myMessage(usrName) { var mcl_obj:Object = new Object(); mcl_obj.onLoadInit = function(target_mc:MovieClip) { new Tween(target_mc, "_alpha", Strong.easeIn, 0, 100, 2, true); TransitionManager.start(target_mc, {type:Fly, direction:Transition.IN, duration:2, easing:Back.easeInOut, startPoint:6}); }; var my_mcl:MovieClipLoader = new MovieClipLoader(); my_mcl.addListener(mcl_obj); my_mcl.loadClip("editlist.swf", holder_mc); new mx.transitions.Tween(tl["usr_"+usrName].logout, "_x", mx.transitions.easing.Bounce.easeOut, 25, 140, 3, true); }
try: import mx.transitions.*; import mx.transitions.easing.*; import mx.managers.PopUpManager; import mx.containers.Window; tl = this; _global.logged_usr = ""; _global.des_usr; _global.logged; _global.usrA = [["matt", "test"], ["ryan", "test2"], ["kat", "test3"], ["mom", "test3"], ["dad", "test4"]]; maxY = 0; for (var i = 0; i<usrA.length; i++) { tl["usr_"+usrA[i][0]].ivar = i; tl["usr_"+usrA[i][0]].startY = tl["usr_"+usrA[i][0]]._y; maxY = Math.max(maxY, tl["usr_"+usrA[i][0]].startY); tl["usr_"+usrA[i][0]].onPress = function() { if (des_usr != logged_usr) { //--Set desired user var _global.des_usr = usrA[this.ivar][0]; // 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); } else { //--cleanup-- my_win.deletePopUp(); unloadMovie(holder_mc); for (var j = 0; j<usrA.length; j++) { if (j != this.ivar) { new Tween(tl["usr_"+usrA[j][0]], "_alpha", Strong.easeOut, 0, 100, 3, true); } else { new mx.transitions.Tween(tl["usr_"+usrA[j][0]].logout, "_x", mx.transitions.easing.Strong.easeOut, 140, 25, 2, true); new mx.transitions.Tween(tl["usr_"+usrA[j][0]], "_y", mx.transitions.easing.Bounce.easeOut, maxY+tl["usr_"+usrA[j][0]]._height+20, tl["usr_"+usrA[j][0]].startY, 2, true); logged_usr = ""; } } } }; } function tweenF(usrName) { //new Tween(tl["usr_"+usrName], "_alpha", Strong.easeIn, 100, 0, 2, true); for (var j = 0; j<usrA.length; j++) { if (usrA[j][0] != usrName) { new Tween(tl["usr_"+usrA[j][0]], "_alpha", Strong.easeIn, 100, 0, 2, true); } } var drop:Object = new mx.transitions.Tween(tl["usr_"+usrName], "_y", mx.transitions.easing.Bounce.easeOut, tl["usr_"+usrName].startY, maxY+tl["usr_"+usrName]._height+20, 2, true); drop.onMotionFinished = function() { myMessage(usrName); }; } function myMessage(usrName) { var mcl_obj:Object = new Object(); mcl_obj.onLoadInit = function(target_mc:MovieClip) { new Tween(target_mc, "_alpha", Strong.easeIn, 0, 100, 2, true); TransitionManager.start(target_mc, {type:Fly, direction:Transition.IN, duration:2, easing:Back.easeInOut, startPoint:6}); }; var my_mcl:MovieClipLoader = new MovieClipLoader(); my_mcl.addListener(mcl_obj); my_mcl.loadClip("editlist.swf", holder_mc); new mx.transitions.Tween(tl["usr_"+usrName].logout, "_x", mx.transitions.easing.Bounce.easeOut, 25, 140, 3, true); }
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 --][-- usr_name.text = des_usr; focusManager.setFocus(usr_pass); lo = new Object(); lo.change = function(eventObject:Object) { for (var i = 0; i<usrA.length; i++) { if (usr_name.text.toLowerCase() == usrA[i][0] && usr_pass.text.toLowerCase() == usrA[i][1]) { submit.enabled = true; } } }; usr_name.addEventListener("change", lo); usr_pass.addEventListener("change", lo); //--Button Action-- submit.onRelease = function() { _global.logged_usr = usr_name.text; _level0.tweenF(usr_name.text.toLowerCase()); _parent.deletePopUp(); }; submit.enabled = 0;
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.
Don't see what you're looking for? Try a search.
|