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

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

Nick
Mail
Title

Age: 3053.2d   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  >>41391
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  >>41413
>>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!



 GifShooter 
Create .gif animations of
flashes here on swfchan.
 SWF loop maker 
Create a flash loop from
image(s) and music.
 FLV Maker 
Encode high quality On2VP6 FLVs and
embed them into SWF containers.
 SWF to APK 
Make flashes run as AIR
apps on Android.
 SwfH264 
Embed H.264/AAC videos
into SWF containers.
 imgtxt 
Put text into images.
 swfchan.net 
Flash imageboard
and recommendations.
 [.com search] 
Search for file name/size
and/or categories.
 swfchan 
Flash archive front page.
 The Swiff Army Knife 
Destined to replace the FLV Maker
and SwfH264 (can make WEBM).
 * swfloops * 
Mixed flash loops.
 END++ 
Fixed versions of the
flash plugins (Win/Linux).
 Video Collection Template 
A .fla template for embedding
several videos into one flash.
 [.net search] 
Search for words in threads.
 /mystuff/ 
Swfs I've made.
 /r/swfchan 
We reddit now.
 ANON PARTY HARD 
349 reasons to dance.
 - Collections - 
See what flashes other
users are collecting.
 How2 simple flash loop 
Using Adobe Flash Pro.
 Music Loops 
Wavs I've made.
 * images * 
Mixed images.
 Send Bitcoin (BCH): hide
 Send Bitcoin (BTC): discuss

http://boards.swfchan.net/10164/index.shtml
Created: 21/11 -2016 20:32:14 Last modified: 2/4 -2025 01:23:44 Server time: 02/04 -2025 01:37:37