Jump to content
Search Community

soundTransform question [updated]

timaging test
Moderator Tag

Recommended Posts

ok, so I have this internal sound in my timeline. I need to be able to stop it along with all my movie clips, just as you would see in a typically timeline based animation.

 

I'm trying to use this code for the sound:

 

import com.greensock.*;
import com.greensock.easing.*;
import com.greensock.plugins.*;
import com.greensock.OverwriteManager;
TweenPlugin.activate([MotionBlurPlugin, TintPlugin, BlurFilterPlugin, EndArrayPlugin, ColorMatrixFilterPlugin, SoundTransformPlugin]);


import flash.events.MouseEvent;
import flash.ui.Mouse;

stopShow.buttonMode = true;
stopShow.useHandCursor = true;

var mySound:Sound = new SoH(); 
mySound.play();

var navClips:Array = [bkgrd, lmLogo, stopShow, playShow, rewindShow, login, mlcHeader, sohHeader];
TweenMax.allTo(navClips, 0, {alpha:0});


TweenMax.to(bkgrd, 1, {alpha:1});

TweenMax.to(playShow, 1, {alpha:1});
TweenMax.to(stopShow, 1, {alpha:1, delay:.25});
TweenMax.to(rewindShow, 1, {alpha:1, delay:.5});

TweenMax.to(lmLogo, 1, {alpha:1, delay:2});
TweenMax.to(mlcHeader, 1, {alpha:1, delay:2.25});
TweenMax.to(sohHeader, 1, {alpha:1, delay:2.5});


//stopButton begin =========================================================================================================;
stopShow.addEventListener(MouseEvent.ROLL_OVER, fl_MouseOverHandler01);

function fl_MouseOverHandler01(event:MouseEvent):void
{
TweenMax.to(stopShow,  1, {alpha:0});
TweenMax.to(stopShow,  1, {alpha:1});
TweenMax.to(stopShow,  1, {tint:0xEFB100});
}


stopShow.addEventListener(MouseEvent.ROLL_OUT, fl_MouseOutHandler01);

function fl_MouseOutHandler01(event:MouseEvent):void
{
TweenMax.to(stopShow,  1, {alpha:1});
TweenMax.to(stopShow,  1, {alpha:0});
TweenMax.to(stopShow,  1, {tint:0x4E8ABE});
}


stopShow.addEventListener(MouseEvent.CLICK, fl_ClickToGoToWebPage01);

function fl_ClickToGoToWebPage01(event:MouseEvent):void
{
SoundMixer.stopAll();
TweenMax.pauseAll();
}
//stopButton end =========================================================================================================;


//stopButton begin =========================================================================================================;
playShow.addEventListener(MouseEvent.ROLL_OVER, fl_MouseOverHandler02);

function fl_MouseOverHandler02(event:MouseEvent):void
{
TweenMax.to(playShow,  1, {alpha:0});
TweenMax.to(playShow,  1, {alpha:1});
TweenMax.to(playShow,  1, {tint:0xEFB100});
}


playShow.addEventListener(MouseEvent.ROLL_OUT, fl_MouseOutHandler02);

function fl_MouseOutHandler02(event:MouseEvent):void
{
TweenMax.to(playShow,  1, {alpha:1});
TweenMax.to(playShow,  1, {alpha:0});
TweenMax.to(playShow,  1, {tint:0x4E8ABE});
}


playShow.addEventListener(MouseEvent.CLICK, fl_ClickToGoToWebPage02);

function fl_ClickToGoToWebPage02(event:MouseEvent):void
{
mySound.resume();
TweenMax.resumeAll();
}
//stopButton end =========================================================================================================;

 

first question is that it's asking for a movie clip, but it's not a movie clip-it's an internal event sound. I tried naming it under AS linkage, but it's still not recognized.

 

the TweenMax is definitely stopping the timeline which is perfect... I can't however seem to get the sound to stop and start because it's internal?

 

 

 

thanks,

Dave

Link to comment
Share on other sites

Hi Carl,

 

yeah, that's my old thread actually, but now I'm trying to pause and resume?

 

I'll see if I can use this somehow to call it, but right now I just have this starting my sound from the library:

 

var mySound:Sound = new SoH(); 
mySound.play();

 

then, I need to pause and resume that, OR ideally get mp3Loader to call my file in my library, because that appears to have the pause and resume functionality that I'm looking for.

 

thanks,

Dave

Link to comment
Share on other sites

and a touch more on that issue. I have this right now that works perfectly to pause everything"

 

function fl_ClickToGoToWebPage01(event:MouseEvent):void
{
SoundMixer.stopAll();
TweenMax.pauseAll();
}

 

BUT I can't see to get the sound to resume from where I stopped. What I was hoping to do was to get the mp3 loader to do that?

Link to comment
Share on other sites

ok, so I did try this just to see if it would affect the sound and nothing happened. Here's what I have in the head:

 

import com.greensock.*;

import com.greensock.easing.*;

import com.greensock.plugins.*;

import com.greensock.OverwriteManager;

TweenPlugin.activate([MotionBlurPlugin, TintPlugin, BlurFilterPlugin, EndArrayPlugin, ColorMatrixFilterPlugin, SoundTransformPlugin]);

 

and here's what I have in my button to click:

 

function fl_ClickToGoToWebPage01(event:MouseEvent):void

{

TweenMax.to(this, 1, {soundTransform:{volume:0, pan:1}});

// SoundMixer.stopAll();

TweenMax.pauseAll();

}

 

now, I don't know if this will pause/resume, but this also doesn't seem to be doing anything to the sound. I was assuming by the numbers that it would fade down?

 

does the fact that it's an event sound make a difference?

 

thanks-

Dave

Link to comment
Share on other sites

ok, so I just tried this as well at the top:

 

var sound:MP3Loader = new MP3Loader(this, {name:"SoH", autoPlay:true, repeat:0});

//begin loading
sound.load();

 

then added this to the button, but I got a bunch of errors:

 

 

function fl_ClickToGoToWebPage01(event:MouseEvent):void
{
TweenMax.pauseSound(this);
//TweenMax.to(this, 0, {soundTransform:{volume:0, pan:1}});
//	SoundMixer.stopAll();
TweenMax.pauseAll();
}

Link to comment
Share on other sites

i'm having trouble following this. it seems like you are mixing up a few different techniques.

 

MP3Loader needs to load an external sound. you can't pass in this to the constructor

 

BAD

var sound:MP3Loader = new MP3Loader(this, {name:"SoH", autoPlay:true, repeat:0});

 

GOOD

var sound:MP3Loader = new MP3Loader("mySoundFile.mp3", {name:"SoH", autoPlay:true, repeat:0});

 

...

also tweening the volume of a sound to 0 does not stop it from playing.

stoppring all the tweens in your movie isn't going to stop the sound from playing.

 

once you settle on a way of using your sound:

 

-loaded with MP3Loader

-placed on a timeline frame

-instantiated from the library

 

it will be much easier to offer a solution.

 

the MP3Loader route will probably give you the easiest route with the most versatility

Link to comment
Share on other sites

sorry about that. I did go off on a bit of a tangent.

 

what I need to be able to do is have a button that pauses my sound and one that resumes it. Ideally, I would want to call the sound that I have in my timeline. It's certainly not necessary, but it just seemed easier in my head to stop and start that way... you may however disagree.

 

this would be an event sound because streaming doesn't stream if you only animate using code and one frame (or at least that's what I'm experiencing)

 

so, mp3Loader is out.

 

super duper easy to do with as2, but then I have to animate using Flash's timeline tools and I have become quite jaded using Greensock stuff :-)

 

I did sort of try a few things and it's in this new thread that I started... may be easier?

 

viewtopic.php?f=1&t=6133

 

and now I'm wondering if there's a way to put it in some timelineMax setup? I just can't seem to get anything working internally... everything seems to need to call an external file, and the client's server won't allow it.

 

thanks!!

Dave

Link to comment
Share on other sites

here is how you can pause and play a sound from the library:

 


import flash.media.Sound;
import flash.media.SoundChannel;


var sound:SampleSound = new SampleSound();
var soundChannel:SoundChannel = new SoundChannel();



var lastPos:Number = 0;

play_btn.addEventListener(MouseEvent.CLICK, playSound)

function playSound(e:MouseEvent):void{
soundChannel  = sound.play(lastPos);
}

pause_btn.addEventListener(MouseEvent.CLICK, pauseSound)

function pauseSound(e:MouseEvent):void{
trace(soundChannel.position);
lastPos = soundChannel.position;
soundChannel.stop();
}

 

file attached

 

I used this tutorial which I recommend:

http://www.republicofcode.com/tutorials/flash/as3sound/

 

yes, sound in AS3 is kind of a hassle. that's why I greatly prefer letting the MP3Loader handle it all.

Link to comment
Share on other sites

ok, so check this out. I think maybe I'm close?

 

Here is what I have up top:

 

import flash.media.Sound;
import flash.media.SoundChannel;

var sound:SampleSound = new SampleSound();
var soundChannel:SoundChannel = new SoundChannel();
//var soundChannel:SoundChannel = sound.play();

var mySound:Sound = new SampleSound(); 
mySound.play();

var lastPos:Number = 0;

 

this is playing, but not stopping. I have this for my button:

 

//stopButton begin =========================================================================================================;
stopShow.addEventListener(MouseEvent.ROLL_OVER, fl_MouseOverHandler01);

function fl_MouseOverHandler01(event:MouseEvent):void
{
TweenMax.to(stopShow,  1, {alpha:0});
TweenMax.to(stopShow,  1, {alpha:1});
TweenMax.to(stopShow,  1, {tint:0xEFB100});
}


stopShow.addEventListener(MouseEvent.ROLL_OUT, fl_MouseOutHandler01);

function fl_MouseOutHandler01(event:MouseEvent):void
{
TweenMax.to(stopShow,  1, {alpha:1});
TweenMax.to(stopShow,  1, {alpha:0});
TweenMax.to(stopShow,  1, {tint:0x4E8ABE});
}

stopShow.addEventListener(MouseEvent.CLICK, pauseSound)

function pauseSound(e:MouseEvent):void{
trace(soundChannel.position);
lastPos = soundChannel.position;
soundChannel.stop();
TweenMax.pauseAll();
}

 

then, I just need it to resume playing.

 

THANKS!!!

Link to comment
Share on other sites

try this in the previous file i sent

 

 

import flash.media.Sound;
import flash.media.SoundChannel;


var sound:SampleSound = new SampleSound();
var soundChannel:SoundChannel = new SoundChannel();



var lastPos:Number = 0;

// ***************** BEGIN NEW STUFF **************

// START PLAYING THE SOUND IMMEDIATELY


soundChannel  = sound.play(lastPos);

// ***************** END NEW STUFF **************

play_btn.addEventListener(MouseEvent.CLICK, playSound)

function playSound(e:MouseEvent):void{
soundChannel  = sound.play(lastPos);
}

pause_btn.addEventListener(MouseEvent.CLICK, pauseSound)

function pauseSound(e:MouseEvent):void{
trace(soundChannel.position);
lastPos = soundChannel.position;
soundChannel.stop();
}

Link to comment
Share on other sites

ok spoke too soon. Check it out... if I hit the play button twice or after the fact, then it runs over itself.

 

http://www.taylorimaging.com/clientArea ... dexnl.html

 

this is one without the loader because that's not working any more for some reason.

 

BUT I don't think this is a greensock issue, so I'm SOL.

 

thanks for your time though. i do appreciate it!

 

Dave

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...