SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    May 2003
    Location
    Toronto
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    if/then and setting properties....

    I apologize for posting what is probably a fairly simple questions for most of you.

    I'm trting to create a single button to mute and un-mute audio.

    My idea is to have a speaker icon on the stage, with a red circle and line through it over top. the volume would be set to 100 and the alpha of the circle-line (which is the button) set to 0.

    When the user clicks on the speaker (hitting the transparent button over top) the audio mutes and the button shows.

    I need to set the script on the button to check the alpha level and volume, and to set them from 0 to 100 or from 100 to 0 as appropriate.

    I've been pouring through the ActionScript reference and can't find anything that accomodates this, and I don't know nearly enough to get what I need from the examples offered. (I didn't find anything in the help files about "volume" at all!).

    I assume that the button would need appropriate script to handle something like the following:

    if alpha of button = 0
    then set alpha of button to 100

    if alpha of button = 100
    then set alpha of button to 0

    if volume = 0
    then set volume to 100

    if volume = 100
    then set volume to 0

    Can anyone point me to a resource, or offer any assistance?

    Thanks in advance.

    Jeff Kenney
    Toronto

  2. #2
    SitePoint Wizard aaron.martone's Avatar
    Join Date
    Feb 2003
    Location
    Florida, USA
    Posts
    2,322
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    You're looking for the ternary operator (?:)
    Code:
    myVolume = (_root.mySound.getVolume() == 0) ? 100 : 0;
    myAlpha = (_root.myButton._alpha == 0) ? 100 : 0;
    
    _root.myButton._alpha = myAlpha;
    _root.mySound.setVolume(myVolume);

  3. #3
    Im watching you... Solitary R@F's Avatar
    Join Date
    Mar 2003
    Location
    Right around the corner..
    Posts
    392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One other thing U can do is use the "tellTarget" option which'll make it all easier on U. U can get tutorials on tellTarget on any Flash site(like www.flashkit.com). The Search Keys should be something like..."tellTarget Music"...
    To really look at what it looks like after putting it in U'r Flash movie, U can check out my site... The "play music" button changes 2 "stop music"...Visit my site @ http://solitaryraf.tripod.com (Intro & Site) or http://solitaryraf.tripod.com/raf.html (Main Site: this is where the button is)
    Hope this helps!!
    Last edited by Solitary R@F; May 28, 2003 at 13:56.


Bookmarks

Posting Permissions

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