A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: architecture and methodology

  1. #1
    Senior Member
    Join Date
    Mar 2001
    Posts
    141

    architecture and methodology

    I have a question for anyone who would like to tackle it.

    A project in front of me involves a map with nearly 100 different buttons, irregular size. When the user rolls over a button, the area must fade in and out smoothly, and the tween must not be compromised by a premature roll-out. The tween must continue to run it's course.

    With a few buttons, this could be achieved by having a boolean flag in the button 'over' and 'out' states, and playing various states of a subordinate mc, that correspond to value of the flag.

    What do you think is the best way to go about building this for such a large number of buttons?
    Flash is Life...The rest is just tweens.
    .::T::.

  2. #2
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    the tween must not be compromised by a premature roll-out. The tween must continue to run it's course.
    what do you mean exactly? i rollOver, the image fades in. i rollOut and the image keeps fading in until the _alpha reaches 100% and fades out afterwards only if i'm not on the image anymore? or if i rollOut when the _alpha is at,say, 40% does it fade out back to 0 then?

    because i was more or less thinking in the line of clipEvents instead of button events, mixed with hitTest()

    gparis

  3. #3
    Senior Member
    Join Date
    Mar 2001
    Posts
    141

    thanks, g

    The issue is nearly identical to tonight's 'mouse over' post, but on a large scale.

    The requirements for this project ask for the fade in tween to complete before the routine evaluates whether or not to begin the fade-out. Very similar to your tree-menu, Gen!
    rollOut and the image keeps fading in until the _alpha reaches 100% and fades out afterwards only if i'm not on the image anymore
    I wholly agree that button events would be tedious, at best. It seems like I need to invoke the methods of the clips themselves, but i wonder what would be the best way to approach the scripting. Would it be appropriate to attempt to create a prototype, or would the effect be better achieved with a function, or ???

    I suppose I have done *some* OOP, but usually I timeline things. I don't want to do that here. I'm just kinda lost, you got any ideas?
    Last edited by orion215; 01-30-2003 at 12:52 AM.
    Flash is Life...The rest is just tweens.
    .::T::.

  4. #4
    Senior Member
    Join Date
    Mar 2001
    Posts
    141
    anybody?
    Flash is Life...The rest is just tweens.
    .::T::.

  5. #5
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    In your case (100 clips) a function would be appropriate. use a prototype if you want but it's not really important because all clips paths would be the same.
    I suggest clipEvents to call the function (for the loop - increment/decrement _alpha). Also, give to a variable the value of the _alpha (like all properties, its value can go between -4.789 to 103.876 - which is not very accurate when you want to check if 0 or 100) .
    gparis

  6. #6
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    Here's a very "hardcoded" and commented version. Something else you didn't state is, if the clip is fading out and i go back "on" it does it keep it's fading out routine or does it fades back in?
    In any case you may want to put all that into a function.
    I posted it in case it helps out get ideas on "how to"

    Code:
    onClipEvent (load) {
        _alpha=alp=0;
    }
    onClipEvent (enterFrame) {
        if (hit && alp<99) {
            // if i'm on the clip and your _alpha is smaller than max., start fading in.
            fadeIn =true;
            fadeOut=false;
        } else if (fadeIn ==true && !hit && alp< 99) {
            // if you started fading in and i'm off the clip, keep on fading in
            fadeIn =true;
            fadeOut=false;
        } else if (fadeIn ==true && hit && alp>=99) {
            // if you're fading in and i'm on the clip, and you're at max _alpha stop fading in
            fadeIn =false;
            fadeOut=false;
        } else if (fadeIn ==true && !hit && alp>=99) {
            // if you're fading in and i'm off the clip, and you're at max _alpha stop fading in
            fadeIn =false;
            fadeOut=false;
        } else if (fadeIn==false && fadeOut==false && !hit && alp>=99) {
            // if you're at max _alpha and i'm off the clip, start fading out
            fadeIn =false;
            fadeOut=true;
        } else if (fadeIn==false && fadeOut==true && !hit && alp==0) {
            // if you're fading out and i'm off the clip and your _alpha is at 0, stop fading out
            fadeIn =false;
            fadeOut=false;
        }
    }
    onClipEvent (enterFrame) {
        alp=Math.round(_alpha);
        if (fadeIn) {
            alp+=2;
        } else if (fadeOut) {
            alp-=2;
        }
        _alpha=alp;
    }
    onClipEvent (mouseMove) {
        if (!hitTest(_root._xmouse, _root._ymouse)) {
            hit=false;
        } else if (hitTest(_root._xmouse, _root._ymouse)) {
            hit=true;
        }
    }
    gparis

  7. #7
    Senior Member
    Join Date
    Mar 2001
    Posts
    141
    Gen-

    I can't believe you went to so much trouble to help. You really are too kind! If you ever need a vote for Team Macromedia, you've got mine!!!

    That was so much simpler than what I was trying to do. I'm still somewhat foggy on how to compile this into a function, but even then, I would have to go into every single clip. The real obvious benefit to using a function would be in the event I needed to tweak the fade rate.

    5000 posts, that's amazing! Thank you again, you have really resurrected this project!
    Flash is Life...The rest is just tweens.
    .::T::.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center