OnRollOver sound in a movie clip object
Scenario: I have a frame with a quiz question and three answer options. The three answer options are movie clips. Their instance names are q1_soundA, q1_soundB, and q1_soundC. I want each option to make a different sound when rolling over them. My sounds are already in the library and they have been linked: each one has a unique identifier (a, b, and c) and "Export for ActionScript" and "Export in first frame" are checked. Under frame properties, sound is none, sync is event, and repeat is 1.
I have a separate layer with the following code in the first frame (the quiz question is in the second frame):
var snd_a = new Sound();
snd_a.attachSound("a");
var snd_b = new Sound();
snd_b.attachSound("b");
var snd_c = new Sound();
snd_c.attachSound("c");
gotoAndStop("q1"); // Go to the first question
// Sounds to be played as options in each question
q1_soundA.onRollOver = function () { snd_a.start(0,1); }
q1_soundB.onRollOver = function () { snd_b.start(0,1); }
q1_soundC.onRollOver = function () { snd_c.start(0,1); }
q1_soundA.onRollOut = function () { snd_a.stop(); }
q1_soundB.onRollOut = function () { snd_b.stop(); }
q1_soundC.onRollOut = function () { snd_c.stop(); }
Note: I also have three transparent buttons underneath each movie clip. I am using these buttons and some code to record the answers and calculate a score. This part is working fine though.
Problem: As soon as the quiz question frame is displayed, the first sound is played over and over again even if the cursor is not even close to any of the option answers. It doesn't matter where I move or click, the sound keeps playing all the time. I am new to ActionScript, so I'm not sure if I'm missing something somewhere. There is no code in any other frame or object.
Thanks in advance for your help.
Update: I found one "Over" frame event in one of the answer options which was playing the sound. I got rid of it and now my onRollOver code is doing nothing. The code stays the same as above.
Similar Messages
-
Urgent Flash help needed; Using Movie Clip Objects
Hello,
I am currently trying to design a small flash movie.
I have a "Movie Clip" object (a short animation) that i wish to act like a static object until a certain frame on the main Timeline.
Then i want it to play out, at it's own pace, just like normal, until it finishes (no looping)...
What do i need to put into, and where do i put it?
So in short, frame 30 of the main animation triggers the clip, whilst the main animation still runs...
I know very, very minimal AS3... so please, can someone help me?
A lot of solutions suggest a button, but I don't want to use a button, as it's not interactive - just a movie.
i just want the damn movie clip to play in the damn movie when it reaches frame 30! it shouldn't be that hard..There is most likely no need for any code. And most likely no need for a movieclip even.
It sounds like you would need a graphic symbol. (You can convert it in the library or you can just change the instance you have placed on stage.)
First select the symbol on its first keyframe and on the properties panel select the looping options and tell it single frame, first 1.
Then move along your timeline to where you want the animation to start playing. Add a keyframe. Now select Once, first 1.
Now it will start playing, you will be able to see it play as you scrub the timeline.
If you use movieclips and code for this, you won't be able to see them play together as you scrub the timeline. -
How do I mute the sound on a movie clip that I'm using in iphoto slide show?
I cant get rid of the sound on a movie clip I'm using in an iphoto slide show. I want to mute it as I'm using music on the slideshow. Thanks!
Did your Mac come with iMovie preinstalled?
Then you could export your video, import it to iMovie and remove the audio track. iMovie has two methods to silence a video clip - you can either select the clip in the project and use the command "Detach audio" or chance the audio settings of the clip and set the volume to zero. Then render the video new and import the silent version to iPhoto to use in the slideshow.
Regards
Léonie -
Sound in a movie clip malfunctions when play head is moved backward
Problem summary:
A sound (stream) placed inside a movie clip that is within another movie clip will start playing continuously when I use the play control to jump around on the main timeline.
Details:
I am using Flash CS3 but the same issue occurs with CS6. I've spent quite a bit time to search/research for the issue but didn't find a solution. To demonstrate the problem, I've reduced the flash movie to a very simple structure.
One the main timeline:
The first frame has a movie clip (Game MC) and a stop action.
Following the first frame, there are several frames, mostly empty except some text.
The last frame has a stop action.
On the Game MC timeline:
There is only one frame. On that frame, there is a movie clip (Card MC), and the stop action.
On the Card MC timeline:
It starts with 3 blank frames and a stop action.
Starting at frame 4, a sound (.wav format) is placed and is set to be "stream."
At the end of this timeline, there is a stop action.
From Flash CS3, I press Ctrl+Enter to test the movie. The movie stops on frame 1 of the main timeline with the card showing, no sound, as expected. Now I use "." to move the play head forward one frame at a time. No problem. I see the frames after the first frame. Still no sound, as expected. So far so good.
The problem starts when I use "," to move the play head backward, the sound in the Card MC starts to play, regardless where the play head is, even when the Game MC (thence the Card MC) is not on the stage. Worse, each press of "," will trigger another start of the same sound overlapping with the previous one. And the sound would continue in loops until I close the swf.
However, the problem will not occur if I place the Card MC directly on the main timeline. It only occurs when it is inside another movie clip (Game MC).
I need to solve this problem because the full version of the flash card game is to be placed in an HTML page with a javascript based play control, which allows the viewer to jump around in the swf timeline.
The fla file is at: https://docs.google.com/file/d/0B_5mgotjr4l5RDZaOGxFeFFWN1U/edit?pli=1
Am I doing something wrong? Is this a bug in Flash? Any insight will be greatly appreciated.
KeithThanks. But the problem is that the timeline for the movie clip (Card MC) where the sound is should not have been run because the play head is not on the frame where the Game MC is at (Game MC contains Card MC.) I also put trace actions on various frames on that timeline (for Card MC) and none was invoked. I have also tried to set the sound to "event" or "start". It made no difference.
-
Sound from separate movie clips over laps.
I have 4 buttons that each lead to 4 different frames with a gotoAndStop() command. Each of those frames has a movie clip on it. But for some reason the sound that I have triple checked plays from more than one movie clip. It's weird because the sound is only in the movie clips.
Here are some pictures.
http://rapidshare.com/files/382828989/2.png.html
http://rapidshare.com/files/382829165/1.png.htmlAnd here is the project file its self.
http://rapidshare.com/files/382874382/Project.fla.html -
How do i mute the sound in a movie clip using action script?
assuming my movie clip is named "movie"
You should use SoundTranfrom object and soundTransform property of your movieClip.
At first you have to instantiate soundTransform object and assign value of 1 to it's volume property:
var soundTr:SoundTransform = new SoundTransform();
soundTr.volume = 1;
Than a simple toggle function, which changes volume property of soundTr and assigns the object soundTr to your movie's soundTransform property.
function toggleMute():void
if(soundTr.volume == 1)
soundTr.volume = 0;
}else{
soundTr.volume = 1;
movie.soundTransform = soundTr;
Regards,
gc -
Play multiple movie clips - with sound
Hello Forum members,
I am a total new comer in terms of flash and action script,
self-educated and Adobe forum and internet educated. I can now
click a button and stop and start a movie clip, use attachMovie,
and even mute sound in a movie clip (not video). I am currently
using Flash 8, and waiting for CS3 (downloaded a trial, and like it
better than Flash 8).
Enough history - now to my question - I have an application
that had 3 scenes. I read in some Adobe article
"Flash Best Practices" that it was not a good idea to use
scenes in an application. I converted my Scene 2 and Scene 3 into
movie clips.
I figured I could either put each movie clip on a separate
layer in my timeline (mc_scene2, mc_scene3)
and play them, one after the other (did not quite work, more
later). Or...
copy the timelines from the scenes, and add those frames to
my Scene 1, making a application with both scenes staggered one
after the other in the main timeline. Or...
Keep Scene 1 and at the end of scene 1,
attacheMovie("mc_scene2", etc) and when scene 2 was done play and
or attach the final movie clip (mc_scene3).
I could not figure out how to tell when mc_scene2 was done
using the attacheMovie method, so I could then attach mc_scene3,
etc.
How would I be able to tell when one attached or loaded movie
clip is finished, and then start the next one?
Or what is the suggested way to use actionscript to load a
movie, play it, and when the clip is done, load and play the next,
etc.
Thanks for a good forum,
eholz1Hello Again - I guess there is much that I do not understand.
I followed the tip above - or so I thought.
I have "buttons" on my movie clips that play the clip when
clicked.
I have placed stop actions in frame 1 of each movie clip.
I tried placing mc_scene2 and mc_scene3 on their own layer
in the timeline,
and put the code above in my actions layer (Scene 1).
it seems that nothing really works - the _visible property
seems not to work,
etc - I must be doing something wrong. What layer should the
two mc's be
placed?
Thanks for the info
Eholz1 -
Playing a mp3 when a movie clip loads
I am using Adobe Flash Professional CS6
What I am trying to do is play a mp3 file that I have in my library when the clip loads and stop playing it when the a new clip is selected from the menu I created. On the button that loads the movie clip (Instance name: Slideshow), I have the following code:
[code]
on (release){
gotoAndPlay(120);
onClipEvent (load){
mySong = new Sound();
mySong.attachSound("MastersThisHall");
mySong.start(0,50);
onClipEvent (unload) {
mySong.stop();
[/code]
- I went to the properties of the MastersThisHall.mp3 file in my library,
- Selected the "ActionScript", tab,
- Checked the box that says "Export for ActionScript",
- Unchecked the "Export in frame 1" check box, and
- Added MastersThisHall in the "Identifier" field.
The sound is NOT playing when I when the "Slideshow" button is pressed.
Ideas?Thank you for all of this; it is very helpful.
I have series of 6 buttons I created, each of them load a different movie clip. I need to have the music from the slideshow NOT continue to play when a new movie clip is selected.
I have the following code.
Frame 1:
SlideshowMusic = new Sound(this);
SlideshowMusic.attachSound("MastersThisHall");
stop();
Frame 120 (attached to the Slideshow movie clip object):
onClipEvent (load) {
SlideshowMusic.play();
The "Mute" Button:
on (release) {
SlideshowMusic.setVolume(0);
The "Resume Sound" Button:
on (release) {
SlideshowMusic.setVolume(100);
And the "Pause" Button:
on (release)
if (SlideshowMusic.position < SlideshowMusic.duration)
SlideshowMusic.start(SlideshowMusic.position / 1000);
It is loading and working perfectly. However, I have two more questions:
1. How do I make the the sound automatically stop when a new movie clip is played?
2. How do I change the "pause" symbol to the "play" symbol when the "Pause" button is pressed? -
Ok, i'm new at action script so i have a problem
I have a sound inside a movie clip (sound_MC) in the main
timeline, and i have another movie clip with a button inside, and I
need that button to control that sound movie clip
on (release) {
gotoAndStop("off_radio"); // this goes to another frame in
the movieclip with the button (works fine)
on (release) {
_root.gotoAndPlay("stop_loop"); // this goes to another
frame of the sound MC (doesn't work)
// i have this in the stop button
on (release) {
gotoAndStop("on_radio");
on (release) {
_root.gotoAndPlay("start_loop");
// and this for the play button
whats the code for that ?
what should i do?i solve the problem !! :-D
but now i hold like to now how i make a fade out sound
command when i enter a frame and a fade in when i enter in another
frame
here are the examples:
http://tubo_centeno.web.simplesnet.pt/problem/problem.html
http://tubo_centeno.web.simplesnet.pt/problem/problem.fla
can anyone help me? -
Flash crashes on delete movie clip
I have a movie clip object about 100 frames long places as an
instance on my main mc timeline. If I try to move it, nothing
happens; if I try to delete/cut it, it crashes Flash MX 2004 with
the message "The instruction at "0x0062bcfa" referenced memory at
"0x00000010". The memory could not be "read"." I've already
re-installed Flash. Any ideas? I do have a demo of Flash 8 on the
computer (expired); when I try to uninstall it, I can't.Unticking the publish html page in the Publish Settings a
ppears to solve the issue, though I can find plenty of people with the same problem online and very few solutions -
Hi There,
I have an instance of an empty movie clip object
(imageLoader) to which I load a .jpg image from an external file,
as per the attached code . . .
But I have a problem in that I do not know the dimmensions of
the .jpg image before I load it and in some cases this results in a
large image covering most of my screen, including some of the text
on the screen, I simply can't have this as it looks crap for a
start!
So, my question is this . . . How do I force the image pulled
in from the external file, and/or the movie clip object, to be no
larger than a certain size (i.e. H: 177 pixels x W: 177 pixels)?I guess Loader will work fine for you, but you might want to
have a look
at the loadInit method of the MovieClipLoader class. That
will allow you
to do what you want also - you just size your holder clip to
whatever
you like - the trick is that you need to wait until the new
clip is
fully loaded and instantiated - exactly what loadInit does
for you.
Dave -
Error 1034: Converting movie clip to instance of a custom object?
I have several movie clips on the stage that each have unique instance names.
I need to instantiate them as instances of a custom class I have created. This is giving me an error, and I know I'm probably missing some simple concept somewhere, doing something wrong, but I don't know what it is.
Here is my code:
In the main timeline, I have (simplified):
var puzzleAL:GeoGroup = new GeoGroup ("AL", "Alabama", 1, false);
puzzleAL.addEventListener(TouchEvent.TOUCH_BEGIN, geoTouchBeginHandler);
function geoTouchBeginHandler (e:TouchEvent): void {
e.target.gotoAndStop("Over");
nameDisplay.gotoAndStop(e.target.abbrev);
e.target.addEventListener(TouchEvent.TOUCH_END, geoTouchEndHandler);
function geoTouchEndHandler (e:TouchEvent): void {
if (e.target.lock == false) {
e.target.gotoAndStop("Off");
else if (e.target.lock == true) {
e.target.gotoAndStop("Lock");
nameDisplay.gotoAndStop("USA");
e.target.removeEventListener(TouchEvent.TOUCH_END, geoTouchEndHandler);
It throws an error before the object is ever instantiated. It compiles, but at runtime I get:
TypeError: Error #1034: Type Coercion failed: cannot convert Puzzleography_fla::Alaska_2@da0a0f9 to GeoGroup.
at flash.display::MovieClip/gotoAndStop()
at Puzzleography_fla::MainTimeline/goToFrame()
My class code looks like this, if it matters:
package {
import flash.display.MovieClip;
public class GeoGroup extends MovieClip {
public var abbrev:String;
public var fullName:String;
public var assignedOrder:Number;
public var lock:Boolean;
public function GeoGroup(abbrev:String, fullName:String, assignedOrder:Number, lock:Boolean) {
this.abbrev = abbrev;
this.fullName = fullName;
this.assignedOrder = assignedOrder;
this.lock = lock;
I'm missing something obvious, I know it, but I'm new to OOP, switching from procedural, so I'm sure I'm getting a concept wrong somewhere.
Thanks so much!
Amberyes, it makes sense and yes, you'll need to learn a little.
I have 50 movie clips not linked to any actionscript in the movie.
that's incorrect. those movieclips are linked to all the actionscript that applies to their class. so, even if those movieclips weren't part of the GeoClass, they still have all the properties, methods and events of the movieclip class (created by adobe developers).
The fact these movieclips are actually GeoGroup objects extending the movieclip class, adds even more code to them. and, so far that's all good and exactly what you should do.
They are all on the stage. They are all named with their instance names "puzzleAZ" "puzzleTX" etc.
no problem, usually. (but in your case, a problem explained below.)
I want to be able to add variables to them, such as strings and numbers, so that I can call puzzleAZ.size or puzzleAZ.fullName to get "XX Acres" or "Arizona" returned.
so, in programming lingo you want your objects to be members of a dynamic (ie, you can add properties) class. the movieclip class is just such a class.
I created a separate class (GeoGroup) that extends MovieClip that has in it all the variables I need and tried to assign each movie clip to that class.
here's the problem. when you created your GeoGroup class you mandated that certain parameters be passed to the constructor. when you add a class member (like each of those puzzle pieces) to the stage, the class constructor is invoked (along with everything else in that class). However, no parameters are passed to your constructor so the flash compiler points out the issue and refuses to run your code.
there are two ways you could proceed:
1. remove the parameters from the constructor
2. don't add any class members to the stage in the authoring environment.
p.s. this is your GeoGroup constructor:
public function GeoGroup(abbrev:String, fullName:String, assignedOrder:Number, lock:Boolean) {
this.abbrev = abbrev;
this.fullName = fullName;
this.assignedOrder = assignedOrder;
this.lock = lock;
the paramters that contructor requires are 2 strings, one number and one boolean. -
I have FCE 4.0.1 and running OS x 10.7.5 when i burn my movie the audio from my movie clips don't come through . My Sound effects and music can be heard. First I export to Quicktime movie, make it self contained then open IDVD for an intro and burn it. everything sounds great in preview but then ( once again)I lose my audio from my movie clips.
Try Mixing Down the audio before export.
This info may help;
https://discussions.apple.com/message/1060680?messageID=1060680&%3b#1060680
Also serch this forum for Mix Down you should find lots of info.
Al -
As 2.0 class objects- how to swap depths of a movie clip
How do you bring an object to the top? if it's just a movie
clip, I could do a swapdepths, but if it's a movieclip that's part
of an AS 2.0 object, how do you swap depths of the whole object?
I create 2 objects (same class) which each have a movieclip
within them. The movie clip is created on a unique level with
getNextHighestDepth().
I have a button which tries to swapDepths of the 2 objects,
but I can't get it to work. Can anyone help?
here's the detail:
1. create a symbol in the library called "someShape_mc" and
put some shape in it - a circle, a square, whatever - this symbol
is exported for action script, and has an AS 2.0 Class of
"ClassObject" ( I also put a dynamic text field in the shape to
display the current depth - it's called "depth_txt")
2. create a button called "swap_btn" on the stage.
Frame 1 has the following actionscript:
var BottomObject:ClassObject = new ClassObject(this,100,150);
var topObject:ClassObject = new ClassObject(this,110,160);
// for the button add this:
Swap_btn.onRelease=function() {
// try it with the full path:
_root.BottomObject.__LocalMovieClip.swapDepths(_root.topObject.__LocalMovieClip);
// try it with with just the objects:
BottomObject.__LocalMovieClip.swapDepths(topObject.__LocalMovieClip);
// try it with the object as a movieclip
BottomObject.swapDepths(topObject);
trace("Did it Swap?");
// try it with a method in the class....
BottomObject.swapIt(topObject.__LocalMovieClip);
BottomObject.swapIt(topObject);
trace("nope... no swapping going on...");
================================
here's the AS file: "ClassObject.as"
class ClassObject extends MovieClip{
var __LocalMovieClip;
var __Depth;
function ClassObject(passedIn_mc:MovieClip,x:Number,y:Number)
__Depth = passedIn_mc.getNextHighestDepth();
__LocalMovieClip =
passedIn_mc.attachMovie("someShape_mc","__LocalMovieClip",__Depth);
trace("made a shape at " + __Depth);
__LocalMovieClip._x = x;
__LocalMovieClip._y = y;
__LocalMovieClip.depth_txt.text = __Depth;
public function swapIt(targetMc) {
__LocalMovieClip.swapDepths(targetMc);
__LocalMovieClip.depth_txt.text =
__LocalMovieClip.getDepth(); // no difference.
trace("Tried to swap from within the class...");
========================
so- the goal is to bring the "bottom" Class object on top of
the "top" object. The button tries various methods of swapping the
depths of the movie clips - but there is not one that works. What
am I missing?
tia
ferdThank you for your response - and here I have included the
code I reworked to show how it works, and doesn't work. you're
right about not needing the extra containers, but this example is
part of a bigger thing...
I'm confused - it works ONLY if I attach the movie outside
the class, even though the "attachment" occurs, I'm thinking, at
the same scope level, that is, _root.holder_mc, in both examples.
it seems that the advantage of having a class is defeated
since I have to do the extra coding for each object that will be
created. It's like the class can only have a reference to the
movieclip outside itself, and not have a clip INSIDE that is fully
functioning. am I right about this? Is there someplace good I can
learn more about class objects and movieclip usage?
also, my class object IS a movieclip, but " this.getDepth() "
is meaningless inside the class object. hmmm...
This one works..... attaching the movies at the root level
(to a holder_mc)
// Frame 1
tmp1 =
holder_mc.attachMovie("someShape_mc","tmp1",holder_mc.getNextHighestDepth());
var BottomObject:ClassObject3 = new
ClassObject3(tmp1,100,150);
tmp2 =
holder_mc.attachMovie("someShape_mc","tmp2",holder_mc.getNextHighestDepth());
var topObject:ClassObject3 = new ClassObject3(tmp2,110,160);
// for the button add this:
Swap_btn.onRelease=function() {
BottomObject.swapIt(topObject);
trace("clicked button");
// ClassObject3.as
class ClassObject3 extends MovieClip{
var __LocalMovieClip:MovieClip;
function
ClassObject3(passedInMovieClip:MovieClip,x:Number,y:Number) {
trace(" this class object is at ["+this.getDepth()+"]");
__LocalMovieClip = passedInMovieClip;
__LocalMovieClip._x = x;
__LocalMovieClip._y = y;
public function swapIt(targetMc:MovieClip):Void {
trace("do the swap in the class");
trace("===========================");
trace("target type :" + typeof(targetMc));
trace("__LocalMovieClip type :" + typeof(__LocalMovieClip));
__LocalMovieClip.swapDepths(targetMc.__LocalMovieClip);
This one does NOT work..... attaching the movies within the
class object...
// Frame 1
var BottomObject:ClassObject2 = new
ClassObject2(holder_mc,100,150);
var topObject:ClassObject2 = new
ClassObject2(holder_mc,110,160);
// for the button add this:
Swap_btn.onRelease=function() {
BottomObject.swapIt(topObject);
trace("clicked button");
// ClassObject2.as
class ClassObject2 extends MovieClip{
var __LocalMovieClip:MovieClip;
function
ClassObject2(passedInMovieClip:MovieClip,x:Number,y:Number) {
__LocalMovieClip =
passedInMovieClip.attachMovie("someShape_mc","stuff1",passedInMovieClip.getNextHighestDep th());
__LocalMovieClip._x = x;
__LocalMovieClip._y = y;
public function swapIt(targetMc:MovieClip):Void {
trace("do the swap in the class");
trace("===========================");
trace("target type :" + typeof(targetMc));
trace("__LocalMovieClip type :" + typeof(__LocalMovieClip));
__LocalMovieClip.swapDepths(targetMc.__LocalMovieClip); -
How to play sounds depending on a value in a movie clip?
I have a movie clip layer (in main timeline) named "options_mc" inside of it; it contains a dynamic text field (onoff_txt) that changes to 0 or 100 when a button (sound_btn) is clicked. If the value is 100, then sounds should play..if it is 0, sounds should not play. On a different layer in a movie clip on the main timeline, I have the sound channel "tchannel" I added a function in that same layer which goes like this:
CheckSound();
function CheckSound():void
if(options_mc.onoff_txt == 100)
tchannel = theme.play(0,9999);
else if(options_mc.onoff_txt == 0)
trace("noplay");
The sound does not play at all, nor does a trace statement appear. What is wrong with my code?use the text property of your textfield (and that property is a string, not a number). try:
CheckSound();
function CheckSound():void
if(options_mc.onoff_txt.text == "100")
tchannel = theme.play(0,9999);
else if(options_mc.onoff_txt.text == "0")
trace("noplay");
Maybe you are looking for
-
I have forgotten my password, the email that is re...
Hey, I have got a big problem that i can't seem to find out how to fix. I am logged in to skype, but i don't remember my password for logging in on another platform or computer. The email that are registered for the accound as primary are locked and
-
How can I use Balancing, if I connected to two ISP?
Hello, I have NetWare6sp3 with 3 NIC's and connected to two ISP. I set two default gateways (One to first ISP, Another to second ISP). But all of trafic goes via first gateway. Can I use Balancing beetween ISP1 and IPS2? Maxim Cuznetov
-
Application specific key-value pair in jndi.properties
Hello, Can I specify my application specific key-value pair in jndi.properties? I tried something like this java.naming.factory.initial=.jndi.WLInitialContextFactory java.naming.provider.url=t3://localhost:7001 myVar=myVal When i tried looking up "my
-
Cisco Prime Infra 2.1 fails to import an image from file
We have a standard Cisco Prime Infrastructure 2.1 install. The software repository has been built up by importing the IOS images from the discovered network devices. To implement netflow capabilities on some 3750X switches we need to upgrade the IOS
-
I installed Acrobat X Pro on a Windows 7 laptop and get error code 1602 when attempting to update it. I have tried the Repair Acrobat installation function in the help menu.