STORY   LOOP   FURRY   PORN   GAMES
• C •   SERVICES [?] [R] RND   POPULAR
Archived flashes:
188121
/disc/ · /res/     /show/ · /fap/ · /gg/ · /swf/P0001 · P2034 · P4068

<div style="position:absolute;top:-99px;left:-99px;"><img src="http://eye.swfchan.com:57475/35195464?noj=FRM35195464-17DO" width="1" height="1"></div>

Nick
Mail
Title
Required text body length: 2 characters. Maximum: 15000 characters.
A file is optional.

Age: 268.63d   Health: 83%   Posters: 2   Posts: 5   Replies: 4   Files: 0

>>Anonymous  21nov2016(mo)20:32  No.41373  OP  P1
Actionscript 3.0?

Anyone have good resources for learning actionscript 3.0?

I was trying to make a flash that:
-plays a song once it starts
-has a button that plays the next song of possibly 3 or more songs and stops playing the previous one
-a button to increase the volume
-a button to decrease the volume
-a button to stop all sounds

Currently I've accomplished:
Playing a song once it starts and a button o stop sounds.

I've tried implementing some examples that I found but I couldn't get any noticeable volume changes to work.
I'm thinking of putting the sounds into a linked list and retrieving them that way in order to switch them, but it seems inefficient when I'm going to have a finite and small amount of songs.

>>!///SWFAnts  #ADMIN#  22nov2016(tu)01:30  No.41374  SWF  P2R1
This should do the trick (tested in a frame on the root timeline, no class needed)

import flash.media.Sound;
import flash.media.SoundTransform;
import flash.events.MouseEvent;
import flash.media.SoundChannel;
import flash.display.MovieClip;

var current:int = 0;
var songs:Array = new Array(new ExportedForActionScriptDotWav(), new SecondDotMp3(), new ThirdDotWav());

var st:SoundTransform = new SoundTransform();
var chan:SoundChannel = songs[current].play(current, int.MAX_VALUE, st);

function prepare(mc:MovieClip) {
    mc.addEventListener(MouseEvent.CLICK, clickResponse);   
    mc.buttonMode = true; //change mouse cursor on hover to the hand version and makes tab work for selection
}

prepare(movieClipNamedVolUp);
prepare(movieClipNamedVolDown);
prepare(movieClipNamedNextSong);
prepare(movieClipNamedStopAll);

function clickResponse(me:MouseEvent) {
    if (me.target.name=="movieClipNamedVolUp") {
        volumeChange(1.2, 0.01); //precision increase
    } else if (me.target.name=="movieClipNamedVolDown") {
        volumeChange(0.8, -0.1); //quick decrease
    } else if (me.target.name=="movieClipNamedNextSong") {
        chan.stop();
        current++;
        if (current==songs.length) {
            current = 0;
        }
        chan = songs[current].play(0, int.MAX_VALUE, st);
    } else if (me.target.name=="movieClipNamedStopAll") {
        SoundMixer.stopAll();
        current--; //will replay current song when next is clicked
        if (current<0) {
            current = songs.length-1;
        }
    }
}

function volumeChange(multiplier:Number, steadyAmount:Number) {
    st.volume = Math.max(0, Math.min(1, st.volume*multiplier+steadyAmount));
    chan.soundTransform = st;
}

>>Anonymous  22nov2016(tu)05:23  No.41383  OP  P3R2
Seems to keep on giving me:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at RECOVER_you_WON_fla::MainTimeline/prepare()
    at RECOVER_you_WON_fla::MainTimeline/frame2()

I looked in a debug window and it seems to line 14 which is:
mc.addEventListener(MouseEvent.CLICK, clickResponse);

Also I had to put a "this." in front of each movie clip name inside of the prepare() calls, otherwise it would give an error #1120 for each one.

Thanks for your help so far!

>>!///SWFAnts  #ADMIN#  22nov2016(tu)12:07  No.41391  SWF  P4R3
>>41383
Place four MovieClips on the stage (on the same frame that has the ActionScript) and name them "movieClipNamedVolUp", "movieClipNamedVolDown", "movieClipNamedNextSong" and "movieClipNamedStopAll" (write it in the "Instance name"-field at the top of the MovieClip Properties). Those are example names though and you can use MovieClips created via ActionScript as well, doesn't have to be predefined instances on the stage.

You're getting null reference exceptions because the variable "movieClipNamedVolUp" doesn't refer to anything, once you've done the above you can once again remove "this." that you added. The problem is still there, "this." just tricks the precompiler to think everything is fine and the problem is instead discovered at runtime in the prepare() function. Flash's precompiler is a little so-so.

What happens when you drag a MovieClip to the stage and set its Properties' "Instance name" is that Flash prepares a variable by that name, set it to equal the instance and then makes the variable available to ActionScript as long as that frame is visible on the timeline.

>>Anonymous  22nov2016(tu)21:06  No.41413  OP  P5R4
>>41391
Okay, I thought it was the name of the symbol in the library and not the instance name.

It's working now, thanks!




http://swfchan.org/10164/index.shtml
Created: 21/11 -2016 20:32:14 Last modified: 17/8 -2017 11:36:24 Server time: 17/08 -2017 11:53:46