Stop FLV From Playing When Clicking Away
I got this flv clip which plays on page load and have put the below code in on the keyframe where I have the flv clip. I've done it before (a while ago) where it worked just fine, now it doesn't. Can anyone see what I'm missing?
PHP Code:
this.addEventListener(MouseEvent.CLICK, clickAway); function clickAway(event:MouseEvent):void { instanceName.stop(); }
This is the error I get:
PHP Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference. at videoclip_fla::MainTimeline/clickAway()
ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0
Posted on: 02-02-2008, 02:05 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Playing A Sound When Clicking
I want to make a cursor that replaces the original mouse cursor when the flashmovie starts. That part is still easy, but how can i make a sound file to play everytime i click the mouse button.
Need To Stop Buttons From Double-clicking
Hi all;
I am writing a kiosk application with a Flash interface. I use a number of on-screen keyboards for user input. On most hardware, this works fine but on some touchscreens, the sensitivity is high and users encounter a double (and sometimes triple) entry error when they press a button on the on-screen keyboard. What I need to figure out, is how to ensure that the button output only registers once, thus programmatically working around this hardware issue.
This is the VERY simple sample code I have behind the button "1" on my on-screen keyboard:
on (release) {
myName.text += "1";
}
...it simply adds the number "1" to the display area. Is there a way that anyone can think of that would ensure that the text is not added twice in rapid succession ? Maybe a timer of some sort, or a way to make the button RELEASE function last a little longer before it returns control to the user?
Any ideas are greatly appreciated -- this is causing us a LOT of headaches.
Clicking Noise With Sound.stop()
I've got some buttons that start playing a sound onRollOver and the sound stops onRollOut. It's working fine, but when the sound stops, there's a clicking noise. Has anyone ever heard of this? I don't think it's in my sound file, or if it is, it doesn't show up when I play it or when I look at the wav file in Sound Forge. Also, it happens no matter where in the file I stop it. I guess the main issue is how to fix it. I thought maybe I could try a quick fade out instead of a stop? Any other ideas? How would I write that? Here's a sample of the code I'm using:
Code:
_global.sndChap2btn = new Sound(this);
_global.sndChap2btn.attachSound("windHowling");
gamesNav_mc.chap2_btn.onRollOver = function() {
_global.sndChap2btn.start(0,0);
};
gamesNav_mc.chap2_btn.onRollOut = function() {
_global.sndChap2btn.stop();
};
Playing Inside The Movie Clip When Clicking A Button
I'm going to have a button to push and It would have an actionscript that I can use to "play" inside the movie clip (I have a stop on every frame in my movie clip)
To clarify what I'm doing, I'm making an Avatar simulator. when you click on an arrow (the button) it will play inside the movie clip and go to the next selection. My problem is, I don't know how to play inside the movieclip.
The movie clip is called "hair"
[F8] Playing A Random Movie Clip When Clicking On Another MC (like A Match Game).
Is anyone familiar with the book Macromedia Flash Professional 8 Game Development by Glen Rhodes? I bought this book thinking it'd teach me how to make a matching game. Indeed, it has a tutorial on how to make one, but there's one problem: it's a matching game for sounds, not images. :
I'm an idiot and only know basic ActionScript. I have some idea as to how it works, but I can't figure out how to display movie clips instead of sounds.
This is the code I'm using, taking the code from the book and altering some names for my own use.
code: numitems = 3;
selone = -1;
function build ()
{
for (var i = 0; i < (numitems * 2); i++)
{
nm = "crd" + i;
_root.attachMovie("card", nm, i);
_root[nm]._x = (i % 3) * 150 + 50;
_root[nm]._y = Math.floor(i / 3) * 150 + 50;
// Part that generates the random images
item = "s" + (i % numitems);
_root[nm].s = new MovieClip(_root[nm]);
_root[nm].s.attachMovie(item);
_root[nm].myid = (i % numitems);
// end
_root[nm].inbut.onRelease = function()
{
this._parent.s.start(0,0);
if (this._parent._xscale == 100)
{
if (selone == -1)
{
selone = this._parent;
this._parent._xscale = this._parent._yscale = 0;
}
else
{
if (this._parent.myid == selone.myid)
{
selone._visible = false;
this._parent._visible = false;
selone = -1;
}
else
{
selone._xscale = selone._yscale = 100;
selone = -1;
}
}
}
}
}
}
shuffle = function()
{
for (var i = 0; i < 200; i++)
{
var c1 = Math.floor(Math.random() * numitems * 2);
var c2 = Math.floor(Math.random() * numitems * 2);
var tx = _root["crd" + c1]._x;
var ty = _root["crd" + c1]._y;
_root["crd" + c1]._x = _root["crd" + c2]._x;
_root["crd" + c1]._y = _root["crd" + c2]._y;
_root["crd" + c2]._x = tx;
_root["crd" + c2]._y = ty;
}
}
build();
shuffle();
So the part that's troubling me is this:
code: item = "s" + (i % numitems);
_root[nm].s = new MovieClip(_root[nm]);
_root[nm].s.attachMovie(item);
_root[nm].myid = (i % numitems);
The original code in the book was:
code: snd = "s" + (i % numsounds);
_root[nm].s = new Sound(_root[nm]);
_root[nm].s.attachSound(item);
_root[nm].myid = (i % numsounds);
How would I change that code so that it displays movie clips instead of playing sounds?
Playing An Audio Clip From Local Library, When Clicking On An External SWF Button
Hi there..
I'm currently getting stuck on a project i'm working on. So far this place has been a tremendous help and taught me a lot in a short amount of time..
Here is my situation: Hope you can help
I currently have random external swfs of "Buttons" loading and unloading into mc_containers into my main movie. These load and unload every couple of seconds.
What I would like to do is have sounds associated with these.. So if you was to click on one of the buttons, it would play a sound.
I have tried this by placing the sound in the button "down" section. However, it starts to play the audio and then as soon as the SWF unloads to load the next, the audio stops.
My question is: Is there a way that when you click on the external SWF loaded button - that it would then link to an audio file in the "main" timeline/library ? This way the audio would continue playing even though the SWF has unloaded.
Any questions - please feel free reply on the post or PM me..
Thanks so much
Johnnybaby
Stop All Sounds And Start Another Sound By Clicking A Button
I am working with Flash 5 and I have a problem like this:
I have several buttons in one page, when clicking each button you get a sound (long), I set the sound on the down phase of the button and set it to "start".
The problem is that when I click one button, and then immediately another button, I hear the sounds of both buttons together.
How can I make it, so that when clicking on the button, the sound that is playing will stop, and the new sounds will start.
Thanks you very much, Efrat.
Drag Drop & Make The Mouse Stop Clicking
I have created a Drag and Drop with 3 hit states for each of the drag and drop's..... Its counting +1 when it locks into the hit state... However, I need to add a line of code so that when it does lock you can NOT click on the movie clip symbol (the mousedown option..) does anyone know how I can add to this code? Because if you keep clicking it add's +1 to the variable if It can be clicked again....... Please I have been busting my a** trying to get this to work...
Here is my code for the drag and drops....
onClipEvent (load) {
origX = this._x;
origY = this._y;
this.drag=true;
}
onClipEvent (mouseDown) {
if ((this.hitTest(_root._xmouse, _root._ymouse))&&(this.drag)) {
this.startDrag();
}
}
onClipEvent (mouseUp) {
if (this.hitTest(_root._xmouse, _root._ymouse)) {
this.stopDrag();
// see if the dropZone conatins the center of this mc
if (_parent.dropperb4.hitTest(this)) {
_parent.myCount4+=1;
this.gotoAndPlay(2);
this.drag=false;
// center it on the drop zone
this._x = _parent.dropperb4._x;
this._y = _parent.dropperb4._y;
} else {
// return it to its original location
this._x = origX;
this._y = origY;
}
}
}
AS3 Script To Stop Looping Movieclip When Clicking On Button
Hi, I was wondering if anyone can help me out to this. I'm just beginning to get familiar with AS3 and would like some input on a scripting issue I've been having. It's fairly simple and I have a movieclip that's nested in my Flash file that automatically plays and is like an intro to a website. The nested movieclip loops as the menu bar appears on the screen. I would like the movieclip to still keep looping and then stop once the user clicks on one of the buttons on the menu bar. Right now when you click on one of the buttons it goes to another frame, which I've told it to do in the script, but it still plays the movieclip, which I don't want it to do. Can anyone help with this?
thanks!
Drag Drop & Make The Mouse Stop Clicking
I have created a Drag and Drop with 3 hit states for each of the drag and drop's..... Its counting +1 when it locks into the hit state... However, I need to add a line of code so that when it does lock you can NOT click on the movie clip symbol (the mousedown option..) does anyone know how I can add to this code? Because if you keep clicking it add's +1 to the variable if It can be clicked again....... Please I have been busting my a** trying to get this to work...
Here is my code for the drag and drops....
onClipEvent (load) {
origX = this._x;
origY = this._y;
this.drag=true;
}
onClipEvent (mouseDown) {
if ((this.hitTest(_root._xmouse, _root._ymouse))&&(this.drag)) {
this.startDrag();
}
}
onClipEvent (mouseUp) {
if (this.hitTest(_root._xmouse, _root._ymouse)) {
this.stopDrag();
// see if the dropZone conatins the center of this mc
if (_parent.dropperb4.hitTest(this)) {
_parent.myCount4+=1;
this.gotoAndPlay(2);
this.drag=false;
// center it on the drop zone
this._x = _parent.dropperb4._x;
this._y = _parent.dropperb4._y;
} else {
// return it to its original location
this._x = origX;
this._y = origY;
}
}
}
How Can I Stop Picture From Blinking After Double-clicking Gallery Arrow?
I have an XML gallery (designed by Scotty!) that has a problem. If you double-click (or quickly click) on the forward or backward arrow to cycle through each picture, the picture starts to blink and the gallery can't be used anymore.
Is there a way that can be mentioned in the code that the arrow can only be clicked once and then becomes disabled until after the pic loads?
This is the code right now for the forward and backward buttons:
ActionScript Code:
function setPortfolioNr(t) { back_btn.onRelease = function() { index>0 ? index-- : index=t-1; choosePortfolio(index); }; fwd_btn.onRelease = function() { index<t-1 ? index++ : index=0; choosePortfolio(index); };}
If there is something else that I'm missing, I'll attach the gallery to this post! Thanks!!
Clicking Lingage Inside Library. I Think Im Braking A Clicking Record ..
I´m going crazy I have to export 773 files inside my library. All files are small sound clips. So I have to right click 773 times and choose export for actionscript. However the filenames are just as I want the identifier to be so if there would only be a command like
"Export selected items for actionscript using the current filename "
it would save my day.
If anyone know how to do this in a quicker way please let me know.
Thanks
Stop Playing
Hi,
What code can I used to tell a mc to stop playing once the button is clicked. My problem is that the mc is still playing once the button is pressed...I need to have it stop on command.
Thanks for your help!
Swf Won't Stop Playing
Hello I have an external movie that I am player in another swf.
I would like to stop the swf when its sequence finishes but it just seems to stick around and not finish. I.e when the movie is done it dosn't dissapear in the other movie clip. I know this should work because my other swfs work fine. The difference with this one is that it has a control bar inside it that is used to rewind, fast forward, ect.
I am not sure how to unload this clip inside the file itself. I cannot change the script in the main swf though this needs be done from the external file (the one with the control bar that is being loaded into the main movie).
Here is the script from the external swf with the control bar that is being loaded in. Any ideas?
Frame Actions:
_parent.stop();
faderbackground._width = width;
looping = false;
playing = false;
top = knob._y;
bottom = knob._y;
left = knob._x;
faderWidth = faderbackground._width-knob._width;
segmentWidth = faderWidth/_parent._totalframes;
right = knob._x+faderWidth-segmentWidth+1;
faderbackground._width -= (segmentWidth-1);
with (backing) {
_width = Math.abs(_x)+faderbackground._width+((_height-faderbackground._height)/2);
shadow._width = _width;
}
_parent.onEnterFrame = function() {
if (_parent._currentframe == _parent._totalframes && !looping) {
playing = false;
_parent.stop();
}
if (dragging) {
playing = false;
_parent.gotoAndStop(Math.ceil(knob._x/segmentWidth));
} else {
knob._x = (_parent._currentframe*segmentWidth)-segmentWidth;
}
//
playhilite._visible = playing;
loophilite._visible = looping;
//
};
//
// playback controls
loop.onRelease = function() {
loophilite._alpha = 100;
};
loop.onPress = function() {
looping = !looping;
loophilite._alpha = 0;
};
playButton.onPress = function() {
playhilite._alpha = 0;
};
playButton.onRelease = function() {
playhilite._alpha = 100;
playing = true;
_parent.play();
};
playButton.onDragOut = function() {
playhilite._alpha = 100;
};
playButton.onDragOver = function() {
playhilite._alpha = 0;
};
stopButton.onRelease = function() {
playing = false;
_parent.stop();
};
rewind.onRelease = function() {
playing = false;
_parent.gotoAndStop(1);
};
stepBack.onRelease = function() {
playing = false;
_parent.prevFrame();
};
stepForward.onRelease = function() {
playing = false;
_parent.nextFrame();
};
goToEnd.onRelease = function() {
playing = false;
_parent.gotoAndStop(_parent._totalframes);
};
knob.onPress = function() {
_parent.stop();
startDrag(knob, false, left, top, right, bottom);
dragging = true;
};
knob.onRelease = function() {
stopDrag();
dragging = false;
};
Please STOP Playing
It just keeps on looping.
I even tried an action script in the last frame.
Please help me make it stop. I was hoping something in properties or export values, but cant locate it.
Newbie here...I apologize.
~W
[mx + Flash8] Different Mouse Events For Clicking Or Clicking And Dragging
Hi there,
there's something that nearly makes my head explode ...i'm in desperate need for your help
what i want to achieve is an online magazine where you can:
- flip the pages by clicken on the corners
- click on the pages to zoom in
- if zoomed in, click to drag the page around
- click again on the page to zoom out.
like in this example: http://www1.visions-weekly.de/epaper/epaper.html
what i have so far is:
as i'd never ever be able to program the pageflip thingy myself,
i bought a pageflip component from the lovely guys at flashloaded.com, so the magazine itself is set up, all the pages are in and i can flip them by clicking on the corners ...sweeet
now comes the tricky part (at least for me)
i put an invisible button on top of the book. i started with the zoom function and used the onClipEvent(mouseDown) and (mouseUp) functions. if clicked for the first time i scale (xscale, yscale) the book to 120%. on the next click i zoom back to 100%. That worked out of the box
Now i wanted to integrate the dragging. the book shall be dragged only when the mouse button is pressed ...but i didn't find a function for that. What i can achieve is either drag it after it got clicked or drag it always when clicked.
for example i tried this code:
i defined 3 variables in the main timeline:
firstclick (to monitor if it is the first click or not)
clicker (to monitor if the button is clicked right now)
dragger (to monitor if the book gets dragged)
Code:
onClipEvent(mouseDown){
if(_root.firstclick=="0"){
_root.firstclick="1";
}
else{
_root.clicker="1";
}
}
onClipEvent(mouseMove){
if(_root.clicker=="1"){
_root.dragger="1";
_root.mybook.startDrag();
};
}
onClipEvent(mouseUp){
if(_root.firstclick=="1"){
_root.mybook._xscale=120;
_root.mybook._yscale=120;
_root.firstclick="2";
}
else if(_root.dragger=="0"){
_root.clicker="0";
_root.firstclick="0";
_root.mybook._xscale=100;
_root.mybook._yscale=100;
_root.mybook._x=10;
_root.mybook._y=10;
}
else if(_root.dragger=="1"){
_root.dragger="0";
_root.clicker="0";
_root.mybook.stopDrag();
}
}
the zooming works but not the dragging (i presume because the dragging would start after the click not while the button is pressed.
i tried to work with listeners (for the first time) but to no avail, because if i listen for clicks or drags that interfered with the pageflip function where you click and drag the pages as well.
can some one ...pretty pretty please ... show me a better way to achieve this?
yours
Stefan
Long MP3 Won't Stop Playing
Hi, forum. First of all, bless all of you old salts who make a bee-line to the Newbies threads to read the likes of this. You're the class I should be taking at the local BOCES, but for lack of $.
Anyway, today I placed a 4-minute-long piece of music, an MP3 with top resolution (iTunes), onto a layer, to read the track onto an exposure-sheet. (Anyone remember those?) The song shows up as a single frame. I hit the Play button on the control panel, and the music plays. I hit anything else, or attempt to scratch with the red frame marker, and nothing happens. It keeps going till the end, or till I quit Flash.
My equipment: iMac, 256mb, Flash 5. My education: the manual.
Rick Wolff
How Can I Stop Sound From Playing
I got a simple question - I bet you have a simpler answer
What I want..
-------------------
Make an animated gif of a flag move when u have the mouse over the button(gif)and at the same time play the national anthem until you remove the mouse away from the button - then the music and animation should stop.
What I have done..
-------------------
a)Made a MC (flag_move) and imported the animated flag.gif to the MC. Also imported the anthem.mp3 file. Added a new layer and at the first frame on that layer I put the mp3 with sync:start
b)Created a button (flag_butt). At the "UP"-state I hade a gif of the flag not moving. On the "OVER"-state I placed my MC (flag_move). "DOWN"- and "HIT"-state I left alone.
c)Placed an Instance of the button on the stage
What happens..
-------------------
When I move the cursor over the flag it starts to animate it and the anthem plays just like I want - BUT - when I remove the cursor from the button-instance the music continues until the mp3 is done. NOW What/How should I do to get the music to stop at the same time my marker leaves the buttonarea ????? ??
Stop MC Playing Again In Scene 2
Hi
I need assitance figuring this out.
I have a Flash MX movie that contains a movie clip.
In scene 1 the movieclip plays.
When It finishes, it goes to scene 2 and stops.
However because the animation has been put into a movie clip, in scene 2 the animation plays again.
How can I make the movieclip in scene 2 goto its last frame?
One answer is not to use scenes which I would prefer not to do.
Thanks
Stop And Clear MC From Playing
I have an MC called MCShip.
I want to assign a button an Action Script ... that onPress, the MCShip movie clip will stop playing and clear itself from the screen.
How do I type that Action Script?
Playing To Last Frame, Then Stop..
Well as the title says, when i push a button, i want a movieclip to play to the end of its timeline and then stop. (its constantly looping now). I would guess that and action saying gotoendAndStop(u get the idea) or something like that would be what i need.
Remember i cant just use stop in the timeline cause of the loop. Or maybe if i could activate a stop function when i hit a button?
Thanks in advance...
-Bad fish
Button - Stop The Currently Playing Mc...
Hi,
I have a complex timeline with many different MCs playing, telling each other to play when they end, and advance on the main time etc etc.
I have a global stop (and play) button. Is there a way to make this button "smart" as in
code:
on(release){
// look for the value of _root.CurrentlyPlayingMC and stop it
_root.CurrentlyPlayingMC.stop();
}
How do I set the value of 'CurrentlyPlayingMC' to the currently playing MC?
I tried adding a _root.CurrentlyPlayingMC = "introduction"; at the beginning of the MC (changing the variable value for each MC) but the button didn't do anything.
I so close to this project I am forgetting my AS. Maybe someone with less on their plate can help me out
Thanks,
/Flip
Song Stop Playing
How to make the song stop playing when going to next scene?
any scripting ?
Stop Sound Playing Over The Top Of Itself
Okay, i really need some help on this. I have a play button where if clicked will play the sound over the top of it when its already playing, if that makes any sense. the sound is already called on the first frame. if the user clicks the play button again, it will play over it.
heres my play button code. i need to know what to add to add to make it check to see if the audio is already playing. My audio sound is named myMusic.
on (press) {
if (playing != true) {
if (paused != true) {
playing = true;
paused = false;
stopped = false;
myMusic.start(0, 999);
}
if (paused == true) {
playing = true;
paused = false;
stopped = false;
myMusic.start(myMusicPosition, 0);
_root.myMusic.onSoundComplete = function() {
myMusic.start();
};
}
}
}
Thanks
Timeline Keeps Playing Even With Stop();
I've added a file, its going to be a game, but i have a problem with it:
After the power goes down to 0 (if u collide with enemy power goes down) the game takes you to the loosing screen, and there's a "replay" button there. When pressed it supposed to take you to the first frame of the main time line, but it starts looping for some reason. please help, thank u
How Do I Stop A Movie From Playing Over And Over
I have a square movie in the center of my page, i want it to animate anytime i resize the window, but i want it to animate only once, but it keeps going and going everytime i resize the window, how do i make it to play only once?
this is my actionscript:
stop();
square_mc.stop();
Stage.scaleMode = "noScale";
Stage.align = "LT";
Stage.height = 100;
Stage.addListener(square_mc);
square_mc.onResize = positionSquare;
function positionSquare()
{
square_mc._x = Stage.width/2 - (square_mc._width/2);
square_mc._y = Stage.height/2 - (square_mc.height/2);
square_mc.play();
}
positionSquare();
square_mc.stop();
Stop 1 Sound, But Keep Playing Another
Hi all.
I've a real headache with this one.
I have a preloader, with a sound loop - once the main stuff kicks in there's a video with voice over.
Now once the video kicks in, i want the previous sound loop to stop.
Its just not having it - its all or nothing.
Any ideas please?
I'm using flash mx2004, ta.
Stop BGM When Video Is Playing.
How should build my flash when I need my bgm to stop playing when a video clip is playing and start again when no video clip is playing. My bgm is on the main timeline and the action scrip is with in a movie clip (button).
Button Won't Stop Playing
Hello I'm new here and i figured some of you smart people out there may be able to help me or at least guide me in the right direction.
My problem is that i have a button which in the over state has a movie clip on it. I also put an action on it so when you rollover it it plays a motion tween. Everything works great except if you hold the mouse over the button it will continue to play the same movie and tween over and over again. I put a stop in every place i could think of and it just won't work. any tips would be greatly appreciated.
Thanks
Video Won't Stop Playing
Hello,
i have posted this one before, but didn't get an answer, i will try to be clearer.
i have a flvplayback on my timeline which auto loads a video. On another layer at frame 20 there is a stop command. So, the timeline stops at frame 20 but the video continues playing, all is well. There is a button on the stage that resumes the timeline by telling it to gor to frsme 21. At this point i would like the video to stop and disapear. I have tried several things, but nothing works. Please help!
thanks
Non-Stop Sound Playing ...
hi ,
i want 10 wav.z get played without any delay ,
i have a 200 kb wav .. and then 9 .. 100 kb wav z
the first one will be played with a preloader and other ones should be loaded while the first one is playing , so after the first one is finished the sound will be continued ... ( i know how to attach the preloader to the first wav whay should i do about the other parts )
I got 5 days to find the answer ...so i really need any help possible.
thnk u
How To Stop Movieclip From Playing?
Hi, newbie here. I have a problem stopping or unloading a movieclip. I created an empty movieclip in my main timeline and loaded another movieclip(notswf) into it using the code below.
this.attachMovie("levitate", "home", 2);
stop();
I put the above code in the first frame of my main movie as i want the movieclip "levitate" to start playing automatically
(levitate is the name of movieclip i want to attach)
(home is the name of the empty movieclip)
It works. However how do I stop this movie from playing when I go to another frame or page? Thanks in advance.
Stop 1 Movie When Playing Another
I have a project with 5 flv files in it. I have buttons to take the user to whichever clip they would like to hear (they are audio only, with controllers).
The problem is, once you have started any of the clips playing, if you click to go to another one, the first one continues to play at the same time. Is there a simple script to tell whatever may already be playing to stop before the other one begins?
This is my first Flash project,btw-- I don't know anything! :)
Can't Stop The Videos From Playing
Hello, I was wondering if anyone could help me. I have quite a few videos on my web pages but they play automatically when i get to the page. and all play at once. Im trying really hard to stop them so this doesn't happen. Ive tried using the behaviors and actions but nothing is working. Could anyone help?
Need To Stop Audio Playing
Hi, I'm building a Flash website.
I've used frames with names to contain the different 'pages' of the site. On the frame called 'SVHS1' I've built an XML mp3 player with buttons and a volume slider.
If I press the stop button on my mp3 player and then navigate to another frame (any frame before or after ‘SVHS1’) the site works fine, and the mp3 player works perfectly if I go to that frame again. But if I navigate to another frame without first stopping the song it continues to play even though I’m not on the mp3 player frame, and if I go back to the mp3 player before the song has finished it starts playing automatically from the beginning of the first song in the XML list again and simply doubles up the sound, which is horrible. When this happens the playback controls only affect the 2nd version (understandably).
Naturally, I don't want to the user to have to press the 'Stop' button before navigating elsewhere in the site. I think this is probably quite simple to fix and I assume that I have to write some script (an eventListener and function similar to that which allows the 'stop' button to work) that tells the mp3 player to stop playing if/when the user navigates away from that frame...but I don’t know how to do this.
Any help would be much appreciated.
Thanks
Ben
The attached script is for the mp3 player frame.
Attach Code
SVHeadline1.addEventListener(MouseEvent.CLICK, SVHeadline1Clicked);
SVHeadline2.addEventListener(MouseEvent.CLICK, SVHeadline2Clicked);
var getYoutube:URLRequest = new URLRequest("http://uk.youtube.com/user/PollingStationProds");
SVHeadline3.addEventListener(MouseEvent.CLICK, SVHeadline3Clicked);
function SVHeadline1Clicked(event:MouseEvent):void
{
gotoAndPlay("SVHS1");
}
function SVHeadline2Clicked(event:MouseEvent):void
{
gotoAndPlay("SVHS2");
}
function SVHeadline3Clicked(event:MouseEvent):void
{
navigateToURL(getYoutube);
}
volume_mc.slider_mc.useHandCursor = true;
var musicReq:URLRequest;
var music:Sound = new Sound();
var sc:SoundChannel;
var currentSound:Sound = music;
var pos:Number;
var songPlaying:Boolean = false;
var xml:XML;
var songlist:XMLList;
var currentIndex:Number = 0;
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, whenLoaded);
function whenLoaded(e:Event):void
{
xml = new XML(e.target.data);
songlist = xml.song;
musicReq = new URLRequest(songlist[0].url);
music.load(musicReq);
sc = music.play();
title_txt.text = songlist[0].title;
artist_txt.text = songlist[0].artist;
sc.addEventListener(Event.SOUND_COMPLETE, nextSong);
}
loader.load(new URLRequest("PSPjukebox.xml"));
mp3btn_FF.addEventListener(MouseEvent.CLICK, nextSong);
mp3btn_RW.addEventListener(MouseEvent.CLICK, prevSong);
mp3btn_PAUSE.addEventListener(MouseEvent.CLICK,pauseSong);
mp3btn_STOP.addEventListener(MouseEvent.CLICK,stopSong);
function nextSong(e:Event):void
{
if (currentIndex < (songlist.length() - 1))
{
currentIndex++;
}
else
{
currentIndex = 0;
}
var nextReq:URLRequest = new URLRequest(songlist[currentIndex].url);
var nextTitle:Sound = new Sound(nextReq);
sc.stop();
title_txt.text = songlist[currentIndex].title;
artist_txt.text = songlist[currentIndex].artist;
sc = nextTitle.play();
songPlaying = true;
currentSound = nextTitle;
sc.addEventListener(Event.SOUND_COMPLETE, nextSong);
}
function prevSong(e:Event):void
{
if (currentIndex > 0)
{
currentIndex--;
}
else
{
currentIndex = songlist.length() - 1;
}
var nextReq:URLRequest = new URLRequest(songlist[currentIndex].url);
var prevTitle:Sound = new Sound(nextReq);
sc.stop();
title_txt.text = songlist[currentIndex].title;
artist_txt.text = songlist[currentIndex].artist;
sc = prevTitle.play();
songPlaying = true;
currentSound = prevTitle;
sc.addEventListener(Event.SOUND_COMPLETE, nextSong);
}
function pauseSong(e:Event):void
{
pos = sc.position;
sc.stop();
songPlaying = false;
mp3btn_PLAY.addEventListener(MouseEvent.CLICK,playSong);
}
function playSong(e:Event):void
{
if(songPlaying == false)
{
sc = currentSound.play(pos);
sc.addEventListener(Event.SOUND_COMPLETE, nextSong);
songPlaying = true;
mp3btn_PLAY.removeEventListener(MouseEvent.CLICK,playSong);
}
}
function stopSong(e:Event):void
{
sc.stop();
pos = 0;
songPlaying = false;
mp3btn_PLAY.addEventListener(MouseEvent.CLICK,playSong);
}
//----VOLUME----//
var dragging:Boolean = false;
var rectangle:Rectangle = new Rectangle(0,0,75,0);
volume_mc.slider_mc.addEventListener(MouseEvent.MOUSE_DOWN,dragIt);
volume_mc.slider_mc.addEventListener(MouseEvent.MOUSE_UP,dropIt);
stage.addEventListener(MouseEvent.MOUSE_UP,dropIt);
function dragIt(e:Event):void
{
volume_mc.slider_mc.startDrag(false,rectangle);
dragging = true;
volume_mc.slider_mc.addEventListener(Event.ENTER_FRAME, adjustVolume);
}
function dropIt(e:Event):void
{
if (dragging)
{
volume_mc.slider_mc.stopDrag();
dragging = false;
}
}
function adjustVolume(e:Event):void
{
var vol:Number = volume_mc.slider_mc.x / 75;
var st:SoundTransform = new SoundTransform(vol);
if (sc != null)
{
sc.soundTransform = st;
}
}
Need To Stop Audio Playing
Hi, I'm building a Flash website.
I've used frames with names to contain the different 'pages' of the site. On the frame called 'SVHS1' I've built an XML mp3 player with buttons and a volume slider.
If I press the stop button on my mp3 player and then navigate to another frame (any frame before or after ‘SVHS1’) the site works fine, and the mp3 player works perfectly if I go to that frame again. But if I navigate to another frame without first stopping the song it continues to play even though I’m not on the mp3 player frame, and if I go back to the mp3 player before the song has finished it starts playing automatically from the beginning of the first song in the XML list again and simply doubles up the sound, which is horrible. When this happens the playback controls only affect the 2nd version (understandably).
Naturally, I don't want to the user to have to press the 'Stop' button before navigating elsewhere in the site. I think this is probably quite simple to fix and I assume that I have to write some script (an eventListener and function similar to that which allows the 'stop' button to work) that tells the mp3 player to stop playing if/when the user navigates away from that frame...but I don’t know how to do this.
Any help would be much appreciated.
Thanks
Ben
The attached script is for the mp3 player frame.
Attach Code
SVHeadline1.addEventListener(MouseEvent.CLICK, SVHeadline1Clicked);
SVHeadline2.addEventListener(MouseEvent.CLICK, SVHeadline2Clicked);
var getYoutube:URLRequest = new URLRequest("http://uk.youtube.com/user/PollingStationProds");
SVHeadline3.addEventListener(MouseEvent.CLICK, SVHeadline3Clicked);
function SVHeadline1Clicked(event:MouseEvent):void
{
gotoAndPlay("SVHS1");
}
function SVHeadline2Clicked(event:MouseEvent):void
{
gotoAndPlay("SVHS2");
}
function SVHeadline3Clicked(event:MouseEvent):void
{
navigateToURL(getYoutube);
}
volume_mc.slider_mc.useHandCursor = true;
var musicReq:URLRequest;
var music:Sound = new Sound();
var sc:SoundChannel;
var currentSound:Sound = music;
var pos:Number;
var songPlaying:Boolean = false;
var xml:XML;
var songlist:XMLList;
var currentIndex:Number = 0;
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, whenLoaded);
function whenLoaded(e:Event):void
{
xml = new XML(e.target.data);
songlist = xml.song;
musicReq = new URLRequest(songlist[0].url);
music.load(musicReq);
sc = music.play();
title_txt.text = songlist[0].title;
artist_txt.text = songlist[0].artist;
sc.addEventListener(Event.SOUND_COMPLETE, nextSong);
}
loader.load(new URLRequest("PSPjukebox.xml"));
mp3btn_FF.addEventListener(MouseEvent.CLICK, nextSong);
mp3btn_RW.addEventListener(MouseEvent.CLICK, prevSong);
mp3btn_PAUSE.addEventListener(MouseEvent.CLICK,pauseSong);
mp3btn_STOP.addEventListener(MouseEvent.CLICK,stopSong);
function nextSong(e:Event):void
{
if (currentIndex < (songlist.length() - 1))
{
currentIndex++;
}
else
{
currentIndex = 0;
}
var nextReq:URLRequest = new URLRequest(songlist[currentIndex].url);
var nextTitle:Sound = new Sound(nextReq);
sc.stop();
title_txt.text = songlist[currentIndex].title;
artist_txt.text = songlist[currentIndex].artist;
sc = nextTitle.play();
songPlaying = true;
currentSound = nextTitle;
sc.addEventListener(Event.SOUND_COMPLETE, nextSong);
}
function prevSong(e:Event):void
{
if (currentIndex > 0)
{
currentIndex--;
}
else
{
currentIndex = songlist.length() - 1;
}
var nextReq:URLRequest = new URLRequest(songlist[currentIndex].url);
var prevTitle:Sound = new Sound(nextReq);
sc.stop();
title_txt.text = songlist[currentIndex].title;
artist_txt.text = songlist[currentIndex].artist;
sc = prevTitle.play();
songPlaying = true;
currentSound = prevTitle;
sc.addEventListener(Event.SOUND_COMPLETE, nextSong);
}
function pauseSong(e:Event):void
{
pos = sc.position;
sc.stop();
songPlaying = false;
mp3btn_PLAY.addEventListener(MouseEvent.CLICK,playSong);
}
function playSong(e:Event):void
{
if(songPlaying == false)
{
sc = currentSound.play(pos);
sc.addEventListener(Event.SOUND_COMPLETE, nextSong);
songPlaying = true;
mp3btn_PLAY.removeEventListener(MouseEvent.CLICK,playSong);
}
}
function stopSong(e:Event):void
{
sc.stop();
pos = 0;
songPlaying = false;
mp3btn_PLAY.addEventListener(MouseEvent.CLICK,playSong);
}
//----VOLUME----//
var dragging:Boolean = false;
var rectangle:Rectangle = new Rectangle(0,0,75,0);
volume_mc.slider_mc.addEventListener(MouseEvent.MOUSE_DOWN,dragIt);
volume_mc.slider_mc.addEventListener(MouseEvent.MOUSE_UP,dropIt);
stage.addEventListener(MouseEvent.MOUSE_UP,dropIt);
function dragIt(e:Event):void
{
volume_mc.slider_mc.startDrag(false,rectangle);
dragging = true;
volume_mc.slider_mc.addEventListener(Event.ENTER_FRAME, adjustVolume);
}
function dropIt(e:Event):void
{
if (dragging)
{
volume_mc.slider_mc.stopDrag();
dragging = false;
}
}
function adjustVolume(e:Event):void
{
var vol:Number = volume_mc.slider_mc.x / 75;
var st:SoundTransform = new SoundTransform(vol);
if (sc != null)
{
sc.soundTransform = st;
}
}
Movie Should Stop...but Keeps Playing
ok...I promise...I'm not on drugs.
I also apologize for the length of this...but I have to explain.
This is driving me nuts....I've done a simple presentation....large, but simple.
It's basically a demo of a product that tracks trucking fleets via GPS.
Anyway, the movie starts....goes to a certain keyframe, loads all the pretty graphics and such and the navigation, then....STOPS....waiting for a mouse click on one of the buttons. So far so good.
Now....if you click the "View Demo" button, it simply jumps down the timeline...and starts playing the demo movie...like it's supposed to.
Here's where the weird stuff starts.
Within this demo movie...I have a simple button, that allows the user to escape the demo....when clicked...it simply goes back to the begining of the timeline to a particular keyframe with a stop action on it.
And then....it stops....All good so far.
However, after a few seconds....maybe 5 or 10....it starts the demo again....just jumps down the timeline and starts playing again!!!!....There is no fancy Action Script or anything.....I'm very confused.....and am hoping that someone may shed a little light on this.
The file is huge...so posting it is no good.
Anyone?
Stop Sound Playing Over The Top Of Itself
Okay, i really need some help on this. I have a play button where if clicked will play the sound over the top of it when its already playing, if that makes any sense. the sound is already called on the first frame. if the user clicks the play button again, it will play over it.
heres my play button code. i need to know what to add to add to make it check to see if the audio is already playing. My audio sound is named myMusc.
on (press) {
if (playing != true) {
if (paused != true) {
playing = true;
paused = false;
stopped = false;
myMusic.start(0, 999);
}
if (paused == true) {
playing = true;
paused = false;
stopped = false;
myMusic.start(myMusicPosition, 0);
_root.myMusic.onSoundComplete = function() {
myMusic.start();
};
}
}
}
Thanks
Stop A MC From Looping Or Playing
how to stop a movie clip from playing or looping?
i have main movie clip, i use looping to insert 'pass' movie clip into it, in 'pass' movie clip, there is a script to make 'pass' movie clip to move around, here is the logic
setinterval(move,1)
function move()
{
...........
..........
...........
.........
setinterval(rest,2000)
function rest()
{
..............................
..............................
..............................
if (pass._y == yyy)
{
//stop this pass movie clip from looping or moving or interval
}
}
}
any idea, thanks
Stop A Movie From Playing
Hi
I have this clock which I just want the hand to move only by 180 degrees
So I have this code like ( not complete code here)
Code:
this.createEmptyMovieClip("myclock", 3);
/*..
...
.. some code here and then
*/
myclock.onEnterFrame = function () {
myclock.secondsHand._rotation+=1;
if( myclock.secondsHand._rotation==180)
{
trace("Wow");
myclock.stop();
}
}
but this is not working
Can someone tell me how I can stop it at 180?
I do get a trace "Wow" but it keeps on playing
Thanks
Stop Buttons While Mc Playing
hi i have a number of buttons in a flash movie that show different photos. It's pretty simple (you can see it here: http://www.oliperphonic.com/tst-page.html)
The problem i have is that if you click one button then impatiently click the next one it won't work as the mc is still playing and kind of gives the impression that you have to click the button twice. Is there anyway to stop the buttons from working while the clip is playing out?
Another question but not so important is: You'll notice how if you click the pics from the bottom up the previous little button fades back in and the new photo shows. However if you don't go in order from bottom to top the wrong pic fades back in (should be the last one you were on). Is there a simple way of making this so? Just some ideas would be great, i'm a bit of a flash simpleton i'm afraid.
Many thanks for any help
Movieclip Stop Playing
ok, i'm trying to get a movieclip within a movieclip to stop playing when it reaches its last frame.
let me describe my problem:
it should start playing when the user rolls over the movieclip that is containing it(i'll call this mc1, and the movieclip within it mc2). i've put a stop action in mc2's last frame but it won't stop and plays again and again. one thing i should point out is that there is a variable in mc1 that tells the movie whether it's ok to play the movie in reverse when the user rolls over mc1, if this is false, that means that it plays normally(not in reverse). i'm using "play()" to play mc1 when the user rolls over it and this is where i think the problem is; even though the last frame of mc2 has a stop action, it is somehow told to play again?
anyways, this is just a guess, i haven't figured out why or how to fix it. i'm not sure if my explanation was too hard to understand so i'll try to clarify it if anyone wants me to. if anyone can give me a solution, it would be very much appreciated.
-i'll try to upoad a fla asap
How Do I Stop A Movie From Playing
hi guys...
heres my problem. I have two movies ( A and B) playing continously in a scene ( looping). After a few seconds, I would like movie A to stop ( freeze) while movie B continues on.
How do i do this? I tried putting a "stop" action on movie A but it stops everything else including movie B.
thanks!
Movie Should Stop...but Keeps Playing
ok...I promise...I'm not on drugs.
I also apologize for the length of this...but I have to explain.
This is driving me nuts....I've done a simple presentation....large, but simple.
It's basically a demo of a product that tracks trucking fleets via GPS.
Anyway, the movie starts....goes to a certain keyframe, loads all the pretty graphics and such and the navigation, then....STOPS....waiting for a mouse click on one of the buttons. So far so good.
Now....if you click the "View Demo" button, it simply jumps down the timeline...and starts playing the demo movie...like it's supposed to.
Here's where the weird stuff starts.
Within this demo movie...I have a simple button, that allows the user to escape the demo....when clicked...it simply goes back to the begining of the timeline to a particular keyframe with a stop action on it.
And then....it stops....All good so far.
However, after a few seconds....maybe 5 or 10....it starts the demo again....just jumps down the timeline and starts playing again!!!!....There is no fancy Action Script or anything.....I'm very confused.....and am hoping that someone may shed a little light on this.
The file is huge...so posting it is no good.
Anyone?
Stop Sound Playing Over The Top Of Itself
Okay, i really need some help on this. I have a play button where if clicked will play the sound over the top of it when its already playing, if that makes any sense. the sound is already called on the first frame. if the user clicks the play button again, it will play over it.
heres my play button code. i need to know what to add to add to make it check to see if the audio is already playing. My audio sound is named myMusc.
on (press) {
if (playing != true) {
if (paused != true) {
playing = true;
paused = false;
stopped = false;
myMusic.start(0, 999);
}
if (paused == true) {
playing = true;
paused = false;
stopped = false;
myMusic.start(myMusicPosition, 0);
_root.myMusic.onSoundComplete = function() {
myMusic.start();
};
}
}
}
Thanks
|