A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: [RESOLVED] Change opacity based on hours and minutes?!!

  1. #1
    Junior Member
    Join Date
    Feb 2012
    Posts
    6

    resolved [RESOLVED] Change opacity based on hours and minutes?!!

    Hi guys, i have troubles. i can change the alpha opacity from images but onl by hour, when i try to add minutes doesn't works correctly.

    I have differents images, they must show at differents hours and minutes...like >= 16 :30 to <18 - hs

    heres the code:

    onClipEvent (enterFrame) {
    myDate = new Date();
    _root.Hour = myDate.getHours();
    _root.Minutes= myDate.getMinutes();
    switch( myDate ){
    break;
    default: trace( myDate );}
    }


    inside the object/images:

    onClipEvent (enterFrame) {
    if ((_root.Hour >= 16 ) && (_root.Hour <18)) {
    setProperty(this, _alpha, 100);
    }
    if ((_root.minutes >= 30 )) {
    setProperty(this, _alpha, 100);
    }
    else {
    setProperty(this, _alpha, 0);
    }
    }


    hope you can help me with this one, or show me another way to get it. Before i get crazy :P

    Thnks for advance.

  2. #2
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Actionscript Code:
    if ((_root.Hour >= 16 && _root.Minutes >= 30) && (_root.Hour <18 && _root.Minutes <30)) {
            setProperty(this, _alpha, 100);
        }

    this^ ?
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  3. #3
    Junior Member
    Join Date
    Feb 2012
    Posts
    6
    thnks for the reply,

    i was trying that way but doesn't works , i think i'm making something wrong with the "&" and the root minutes, i cannot fix it.

    just works in a simple way , but i need add another minute and hour time values:

    if ((_root.Hour >=12) && ( _root.Minutes <30)) {
    setProperty(this, _alpha, 100);
    }
    else {
    setProperty(this, _alpha, 0);
    }
    }

  4. #4
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    My code has a lot of errors, I just noticed :P

    btw, why are you using setProperty? I think that's deprecated, use the new version:

    Actionscript Code:
    _alpha = 100;

    _alpha = 0;
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  5. #5
    Junior Member
    Join Date
    Feb 2012
    Posts
    6
    right, old school rules . i just change the property.

    i should put some >=16 <18 and <30 and >30 for any half and hour in that period.
    Im trying figure out the way. Because in this way the image dissapears at 17 <30 hs

  6. #6
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Could you give me a detailed overview of what image you want to appear when, and how many images, and at what time they should appear?
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  7. #7
    Junior Member
    Join Date
    Feb 2012
    Posts
    6
    of course, the images are in 6 layers in ascendent order and a background image in the bottom.

    something like this:

    img 6 - 22 to 00 Hs
    img 5 - 19.30 to 21.30 Hs
    img 4 - 18.30 to 19.30 Hs
    img 3 - 16.30 to 18.30 Hs
    img 2 - 9 to 12 Hs
    img 1 - 7 to 9 Hs
    Background -

    looks simple but the troubles comes with the img 3,4 and 5 :S

  8. #8
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Actionscript Code:
    onClipEvent(enterFrame){
        date = new Date();
        hours = date.getHours();
        minutes = date.getMinutes();
        time = hours+int((minutes/60)*10)/10;
       
        if(time >= 22 && < 24){
            // img 6
        } else if(time >= 19.5 && time <= 21.5){
            // img 5
        } else if(time >= 18.5 && time < 19.5){
            // img 4
        } else if(time >= 16.5 && time < 18.5){
            // img 3
        } else if(time >= 9 && time <= 12){
            // img 2
        } else if(time >= 7 && time < 9){
            // img 1
        }
    }

    I simply convert the minutes into hours, and add the hours and minutes together. Now, 30 minutes is equals to a half, which is 0.5, that's why I am doing that, in case you're wondering!

    Hope this works
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  9. #9
    Junior Member
    Join Date
    Feb 2012
    Posts
    6
    Thanks for the clue, you are some kind of jedi master sorry for answer late, too many things to be done

    im trying right now. Btw its works in as2? because i can't change the images opacity, may be some issue or something missing with the first code.

    Did you make any test?

  10. #10
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    I suggest you put all the images inside a Movieclip, give it an instance name, and go to the frames with different images inside the commented code in my provided code
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  11. #11
    Junior Member
    Join Date
    Feb 2012
    Posts
    6
    yeah i did it in that way, calling directly the images and leaving that alpha crazy idea....

    THKS! for help me and find the way. u are the best my friend

    take care!

  12. #12
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    cool
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

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