Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6678695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:16:23+00:00 2026-05-26T04:16:23+00:00

I’m making a flash payer. I already finished the volume part, and I also

  • 0

I’m making a flash payer.
I already finished the volume part, and I also want to add two functions.
One is when user click “add button”, it will increase the current volume and change the volume display color.
Another is when user click “minus button”, it will decrease the current volume and change the volume display color.

How do I write these two function?
I’ve been tried for loop but I’m so new to program so it’s totally mess up…

My current actionscript code is

import flash.net.URLRequest;
import flash.media.Sound;
import flash.events.Event;
import flash.media.SoundChannel;
import flash.events.MouseEvent;
import flash.events.ProgressEvent;
import flash.media.SoundTransform;

var audiofile:URLRequest=new URLRequest("mvl_player_test.mp3");
var song:Sound=new Sound();
var songcontro:SoundChannel;
var resumetime:Number = 0;

song.addEventListener(Event.COMPLETE, songLoaded);
song.addEventListener(ProgressEvent.PROGRESS, trackLoad);
song.load(audiofile);

function songLoaded(evt:Event):void{//play songs
play_btn.addEventListener(MouseEvent.CLICK, clickedplay);
pause_btn.addEventListener(MouseEvent.CLICK, clickedpause);
volume_1.addEventListener(MouseEvent.CLICK, clickedVol_1);
volume_2.addEventListener(MouseEvent.CLICK, clickedVol_2);
volume_3.addEventListener(MouseEvent.CLICK, clickedVol_3);
volume_4.addEventListener(MouseEvent.CLICK, clickedVol_4);
volume_5.addEventListener(MouseEvent.CLICK, clickedVol_5);
volume_6.addEventListener(MouseEvent.CLICK, clickedVol_6);
volume_7.addEventListener(MouseEvent.CLICK, clickedVol_7);
}

function clickedplay(evt:MouseEvent):void{
play_btn.visible = false;
pause_btn.visible = true;
songcontro=song.play(resumetime);
addEventListener(Event.ENTER_FRAME, trackPlayback);
}

function clickedpause(evt:MouseEvent):void{
play_btn.visible = true;
pause_btn.visible = false;
resumetime = songcontro.position;
songcontro.stop();
removeEventListener(Event.ENTER_FRAME, trackPlayback);
}


function trackLoad(evt:ProgressEvent):void
{
load_progress.scaleX = evt.bytesLoaded / evt.bytesTotal;
}

function trackPlayback(evt:Event):void
{
var perPlayed:Number = songcontro.position / song.length;
played_progress.scaleX = perPlayed * (song_row.width) + song_row.scaleX;
}

Here is the code refer to volume display area

function clickedVol_1(evt:MouseEvent):void
{
var volControl:SoundTransform = songcontro.soundTransform;
volControl.volume = 0.1;
songcontro.soundTransform = volControl;
volume_1.visible = false;
volume_1_2.visible = true;
volume_2_2.visible = false;
volume_3_2.visible = false;
volume_4_2.visible = false;
volume_5_2.visible = false;
volume_6_2.visible = false;
volume_7_2.visible = false;
}


function clickedVol_2(evt:MouseEvent):void
{
var volControl:SoundTransform = songcontro.soundTransform;
volControl.volume = 0.3;
songcontro.soundTransform = volControl;
volume_1.visible = false;
volume_2.visible = false;
volume_1_2.visible = true;
volume_2_2.visible = true;
volume_3_2.visible = false;
volume_4_2.visible = false;
volume_5_2.visible = false;
volume_6_2.visible = false;
volume_7_2.visible = false;
}

function clickedVol_3(evt:MouseEvent):void
{
var volControl:SoundTransform = songcontro.soundTransform;
volControl.volume = 0.4;

songcontro.soundTransform = volControl;
volume_1.visible = false;
volume_2.visible = false;
volume_3.visible = false;
volume_1_2.visible = true;
volume_2_2.visible = true;
volume_3_2.visible = true;
volume_4_2.visible = false;
volume_5_2.visible = false;
volume_6_2.visible = false;
volume_7_2.visible = false;
}

function clickedVol_4(evt:MouseEvent):void
{
var volControl:SoundTransform = songcontro.soundTransform;
volControl.volume = 0.5;
songcontro.soundTransform = volControl;
volume_1.visible = false;
volume_2.visible = false;
volume_3.visible = false;
volume_4.visible = false;
volume_1_2.visible = true;
volume_2_2.visible = true;
volume_3_2.visible = true;
volume_4_2.visible = true;
volume_5_2.visible = false;
volume_6_2.visible = false;
volume_7_2.visible = false;
}

function clickedVol_5(evt:MouseEvent):void
{
var volControl:SoundTransform = songcontro.soundTransform;
volControl.volume = 0.6;
songcontro.soundTransform = volControl;
volume_1.visible = false;
volume_2.visible = false;
volume_3.visible = false;
volume_4.visible = false;
volume_5.visible = false;
volume_1_2.visible = true;
volume_2_2.visible = true;
volume_3_2.visible = true;
volume_4_2.visible = true;
volume_5_2.visible = true;
volume_6_2.visible = false;
volume_7_2.visible = false;
}

function clickedVol_6(evt:MouseEvent):void
{
var volControl:SoundTransform = songcontro.soundTransform;
volControl.volume = 0.7;
songcontro.soundTransform = volControl;
volume_1.visible = false;
volume_2.visible = false;
volume_3.visible = false;
volume_4.visible = false;
volume_5.visible = false;
volume_6.visible = false;
volume_1_2.visible = true;
volume_2_2.visible = true;
volume_3_2.visible = true;
volume_4_2.visible = true;
volume_5_2.visible = true;
volume_6_2.visible = true;
volume_7_2.visible = false;
}

function clickedVol_7(evt:MouseEvent):void
{
var volControl:SoundTransform = songcontro.soundTransform;
volControl.volume = 1;
songcontro.soundTransform = volControl;
volume_1.visible = false;
volume_2.visible = false;
volume_3.visible = false;
volume_4.visible = false;
volume_5.visible = false;
volume_6.visible = false;
volume_7.visible = false;
volume_1_2.visible = true;
volume_2_2.visible = true;
volume_3_2.visible = true;
volume_4_2.visible = true;
volume_5_2.visible = true;
volume_6_2.visible = true;
volume_7_2.visible = true;
}

Thanks for any answer

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:16:24+00:00Added an answer on May 26, 2026 at 4:16 am

    I think your problem here is the fact that you have several volume buttons. I would have one bar and two buttons, plus and minus. When you click the plusButton, you run a function setVolume(volume) that sets the new volume to a variable, making sure it is between 0 and 1. At the end of the function you update the bar graphics depending on the volume percentage. I dont like the idéa that you have that many buttons. Make one button with multiple frames. Each frame lights up a new volume button. When you click the whole clip you calculate the percentage of the mousePositionX and the with of the volumeBar to get the new volume. In the updateBArGraphics function you just compare the percentage to the amount of frames you have and use goToAndStop(volumeFrame).

    This is written out of my head, so there will be errors:

    private function setVolume(newVolume : Number) : void
    {
        if(newVolume > 1)
            newVolume = 1;
    
        if(newVolume < 0)
            newVolume = 0;
    
        volControl.volume = newVolume;
        songcontrol.soundTransform = volControl;
    
        updateVolumeBarGraphics();
    }
    
    private function onVolumeBarClickHandler(event : MouseEvent) : void
    {
        // calculate where on the bar you clicked using MouseX and bar.width
        var calculatedPercentage : Number = 
        // set new volume
        setVolume(caculatedPercentage);
    }
    
    private function onVolumeMinusClickHandler(event : MouseEvent) : void
    {
        setVolume(volControl.volume - 0.2);
    }
    
    private function onVolumeMinusClickHandler(event : MouseEvent) : void
    {
        setVolume(volControl.volume + 0.2);
    }
    
    private function updateVolumeBarGraphics(newVolume : Number) : void
    {
        var volumeFrame : int = Math.floor(newVolume * volumeBar.totalFrames) + 1;
        volumeBar.gotoAndStop(volumeFrame);
    }
    

    Something like that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
i want to parse a xhtml file and display in UITableView. what is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.