14 Replies Latest reply on Dec 19, 2007 1:46 PM by pow_haaweeese

    visited button state..._stumped

    pow_haaweeese
      hi all,
      I've traditional buttons (up, over, down, hit) that are being used to send users to my individual portfolio images alone the timeline with the gotoAndPlay - label behavior. pretty standard stuff.

      But since I've this block of numbers that represent my individual files...after a user goes to one, and then they click on a different one, I'd like for the one(s) they've already viewed to reflect that..to dim or be visibly different in some way so they know what they've seen, and what they've not seen.

      I don't think that's doable with the regular button characteristics...and am hoping, as I've seen this a lot on portfolio sites, someone would be kind enough to help me understand what I need to do to make those buttons "smart enough" to realize they've been visited.

      Thanks,
      J
        • 1. Re: visited button state..._stumped
          kglad Adobe Community Professional & MVP
          you can change the _alpha property of your buttons after they've been used.
          • 2. Re: visited button state..._stumped
            pow_haaweeese Level 1
            hi Kglad,
            I appreciate your reply, but I'm afraid I don't quite follow..

            is this something I'd do in the button itself? or talk to the buttons as a group in AS?

            If you could break your comment down abit for me, I'd appreciate it. I understand the meaning of alpha, and that it can be applied, but not sure where to do that.

            • 3. Re: visited button state..._stumped
              BSpero Level 1
              Pow,
              You must have actionscript somewhere that tells the buttons what to do when they are clicked. In this actionscript, add a line that sets the _alpha property to 80 or something. This will cause them to dim out a bit when clicked until the flash movie is reloaded. I am not sure of the code that you have used on your buttons, so I am hesitant to give you the whole thing, but if you have an onRelease handler, then add the line:

              _alpha = 80;

              Depending on how you call the functions, this might not work right, so if you can't figure it out still, post the code that controls your buttons, and someone can tell you where to put it.

              - B
              • 4. Re: visited button state..._stumped
                pow_haaweeese Level 1
                hi B,
                I'm just using a behavior on the button:

                on (release) {
                //Movieclip GotoAndPlay Behavior
                this.gotoAndPlay("fortStart");
                //End Behavior

                }

                which I'm using to send the user to different places on my timeline with labels.

                I know putting it (_alpha 80;) in the above code is not right (cause I tried it) it made the whole fla _alpha. (which is what I guess I told it to do)

                This tells me I need to to is to talk directly to the button itself. I just am having a tough time figuring out how to do that.

                • 5. Re: visited button state..._stumped
                  Damon Edwards Level 3
                  this._alpha = 80;
                  • 6. Re: visited button state..._stumped
                    BSpero Level 1
                    DZ,
                    That won't work with a script attached directly to a button. Pow, the biggest problem here is that you are putting your code directly on the buttons, instead of in the timeline. Rather than using your code, it should be in a move frame and read:

                    myButtonName.onRelease = function (){
                    gotoAndPlay("fortStart")
                    this._alpha = 80
                    }

                    At this point, since you are hard coding all the labels into the buttons themselves, you might as well just hard code your script and add:

                    myButtonName._alpha = 80

                    If this were in frame, then it would be easier to customize how each button acts, etc. With your method, if you wanted a bit more control, you could set a global variable to a value and then set the _alpha of each button to that variable, that way you could easily change the transparency. At any rate, I would recommend that you look into coding on the timeline, rather than on the buttons themselves.

                    - B
                    • 7. Re: visited button state..._stumped
                      Damon Edwards Level 3
                      "That won't work with a script attached directly to a button."

                      Yes, it does work, however, I just noticed it alphas everything. I've never coded on an object so that is definitely not my strong point :)

                      "I would recommend that you look into coding on the timeline, rather than on the buttons themselves."

                      I second that to fullest degree.
                      • 8. Re: visited button state..._stumped
                        pow_haaweeese Level 1
                        hi Dzedward,

                        when I put (this_alpha = 80;) inside the event handler (the behavior I used, "gotoAndPlay Label) of say my first button:

                        on (release) {
                        this._alpha = 80;
                        //Movieclip GotoAndPlay Behavior
                        this.gotoAndPlay("fortStart");
                        //End Behavior

                        }

                        this turns my whole fla file and everything in it (80%) alpha....instead of just the button, upon release.

                        This doesn't make sense, as I am selecting only the button, and applying the above code to just that button. ....But...the button is sending the user to different places on the timeline...("fortStart" is just a label name") maybe that's part of the problem. I don't think there's anything mysterious that I've done that could be effecting this...but you may see something, in just how I've applied it.

                        _ p.s. This goes without saying, except that it should be said, I very much appreciate the help you've given, and overall, the flash community gives. Actionscript is so tough for designers like me..my frikin brain just doesn't grasp this without my beating myself over the head, over and over again...it's so frustrating..but to do the kinds of designs that I see in my head...alas Actionscript is the only solution. So know I'm trying.
                        I just wanted to say thanks.

                        - on my other post too...the scrollbar haloTheme issue..it sounds so simple when you say it...I'll work on that now.

                        flashgods.org/forums looks great btw
                        • 9. Re: visited button state..._stumped
                          pow_haaweeese Level 1
                          BSpero and dzedward,
                          thanks to you both so very much for your help on this. Such a simple thing yet I just had such a hard time figuring it out. It's just a way of thinking I guess.

                          >>>>>>
                          WHAT WORKED:
                          Here I was trying to "talk" to the button, and had failed to do the most basic thing. Give it an instance name.

                          I gave it "btn_01" and added your code BSpero:

                          on (release) {
                          //Movieclip GotoAndPlay Behavior
                          this.gotoAndPlay("fortStart");
                          //End Behavior

                          btn_01._alpha = 20

                          }


                          (bumped it down to 20 to be sure I could see it, as it's already a mid-range color on a black background) and it worked fine...just like it should have.

                          Actionscript is SO logical...I think that's why I don't understand it...but I respect it.

                          Thanks again....
                          (now I'm off to alpha-tize my ScrollBar Assets in the hopes of re-skining my UIScrollBar Component so it's transparent insteada bright white.

                          best,
                          Pow
                          • 10. Re: visited button state..._stumped
                            Level 7
                            >> on (release) {
                            //Movieclip GotoAndPlay Behavior
                            this.gotoAndPlay("fortStart");
                            //End Behavior

                            btn_01._alpha = 20

                            }

                            Giving the button an instance name is a good start, but you're still not
                            doing it correctly, because you're attaching the code to the button. It
                            should be in the timeline, and you reference the instance as others have
                            said. That way 'this' will refer to the button and not the timeline. The way
                            you have it here is not very logical - you have 'this' referencing something
                            other than what the code is on, and you have to reference btn_01 - which the
                            code is attached to... not too logical to me.

                            Instead - keep your instance name, remove the code from the button and
                            replace with this in the main timeline:

                            btn_01.onRelease = function(){
                            this._parent.gotoAndPlay("fortStart");
                            this._alpha = 20;
                            }

                            Now, inside the function - this refences btn_01, and this._parent refers to
                            the timeline the button is placed on - probably root. Makes much more sense,
                            IMO. And it also makes your code a lot easier to manage since you don't have
                            to click on various objects to find it, it should all be on a frame in the
                            _root.

                            And I'd also recommend not using 'buttons' but using MovieClips, they are
                            much more flexible.

                            --
                            Dave -
                            Head Developer
                            http://www.blurredistinction.com
                            Adobe Community Expert
                            http://www.adobe.com/communities/experts/


                            • 11. Re: visited button state..._stumped
                              pow_haaweeese Level 1
                              Dave,
                              Thank you very much for this, I'll move that code.

                              It did not occur to me to put all this on top "actions" layer in this particular case, for some reason...I'd been taught that, and always have done it that way, on my small projects..till I got to this, my own portfolio site...(it's first time I'm building a complex flash site, combining different swf's etc...)

                              Part of my problem was not "thinking in ActionScript" it IS a certain way of thinking...(and the other part, I'll have to chalk up to lack of experience)

                              But this forum is slowly changing that-second time today I've learned something very helpful about ActionScript.

                              re: buttons, I think I just didn't know how to do those four chores in ActionScript (up, over, down, and hit) - I did make some elaborate buttons with movie clips inside..but yes..I agree, I should use MC's for buttons, I'll find the code to do that via ActionScript, as that'd help my learning curve anyway.

                              So thank you, and know I very much appreciate your time and advice.

                              best,
                              Jim
                              • 12. Re: visited button state..._stumped
                                pow_haaweeese Level 1
                                Dave,
                                Just a note to say I just tried the code you gave me, and it worked perfect on the main timeline.

                                Thanks again.
                                Jim
                                • 13. Re: visited button state..._stumped
                                  Level 7
                                  Great, glad it worked. As for using MovieClips as buttons. Hit area is not
                                  an issue, unless you need transparency. For things like showing state, I
                                  either do the simple thing and make another frame in the clip, or use
                                  something like Tweener to animate a color, or alpha change. For instance,
                                  say you have your btn_01 as a MovieClip, and within it you have a clip with
                                  an instance name of bg, for your background color. You can animate the color
                                  change on RollOver / Out with something like this:

                                  import com.caurina.transitions.Tweener;

                                  btn_01.onRollOver = function(){
                                  Tweener.addTween(this.bg, {_color:0xFF0000, time:1.5});
                                  }
                                  btn_01.onRollOut = btn_01.onReleaseOutside = function(){
                                  Tweener.addTween(this.bg, {_color:0x666666, time:1.5});
                                  }

                                  --
                                  Dave -
                                  Head Developer
                                  http://www.blurredistinction.com
                                  Adobe Community Expert
                                  http://www.adobe.com/communities/experts/


                                  • 14. Re: visited button state..._stumped
                                    pow_haaweeese Level 1
                                    hi Dave,

                                    Thanks for this....the only thing I do not get of what you wrote...is the first line.

                                    "import com.caurina.transitions.Tweener:"

                                    didn't understand it, and had not seen it...so...found this:

                                    http://proto.layer51.com/d.aspx?f=804

                                    i see.>smile.

                                    Thanks very much for your help...I'll look into doing it that way, as I agree, Movie clips are the way to go.

                                    best,
                                    Jim