Hi everyone, I am not too sure what is causing this to happen but maybe a few suggestions is all it will take to fix this problem. Please try the following link to view the movie: http://sweetness.dyndns.org/home.cfm?intro=false&showMP3=true The provided link displays an MP3 player I've been working on (90% completed) and there's a huge problem I just found few minutes ago. When you move the mouse over embedded movie (left/right/left/right...continuously), the scrolling text you see in the blue window scrolls at the proper speed. However, once you stop moving the mouse over the movie or you move the mouse off of the movie, the text scrolls extremely slow. I honestly have no clue what is causing this to occur. I even uncommented my mouseListener functions to see if that was the problem and it wasn't. If there is any further information that you would like to better understand my current issue, please post a reply with whatever you need. I'm not posting my actionscript because it's really long and I don't want yall to waste an hour reading code (boring as heaven!). Thank you all in advance. Regards, Adam
Here's a question: Does the mouse have any effect as far as the frames Rate ("fps") goes? This may be what the problem is, and maybe there's a work around for the following code practice. Here's the code that starts scrolling the text the first time in the movie telling the user that the MP3 player has been loaded properly: // inititialized variables var scrollTextID = null; var soundLoaderID = null; var scrollSpeed = .5; var initialMCPos = _root.MCsound_info._x; var final_MC_Pos = (initialMCPos + _root.mask._width); // functon declarations function loadFunction() { if(mySound.getBytesLoaded() == mySound.getBytesTotal()){ clearInterval (soundLoaderID); _root.MCsound_info.sound_info = "Song loaded successfully! Please wait..."; // sound_info is the dynamic text field setTextScrollerInterval(); } } function setTextScrollerInterval() { scrollTextID = setInterval(startTextScroll,10); } function startTextScroll() { _root.MCsound_info._x -= scrollSpeed; szSoundInfoLen = _root.MCsound_info.sound_info.length; // The length of the text string that is scrolling EndOfScrollPos = (szSoundInfoLen * 5)-30; // DO NOT EDIT: The position of the text that will let us know when to move text to other side of masking box if(_root.MCsound_info._x <= (initialMCPos-EndOfScrollPos)) { _root.MCsound_info._x = final_MC_Pos; } }
the mouse position could have an effect on cpu usage if your script contains code manipulating enough objects to be noticable. the code you posted would have no significant effect on the apparent fps. you have some other code that tracks the mouse's position that's causing the problem.
kglad, You were right, and that's what I had assumed. I must not have commented out ALL of the mouse listeners when I tested that theory the first time. I commented out ALL of the mouse listener functions and the problem stopped. Now, here's a question. How do I add a mouse listener SPECIFICALLY for a particular "Movie Clip". For instance, on my volume slider, when you click the "tick" to slide the volume slider left or right, I turned the "tick" ( the little 2 x 5 px bar) into a Movie Clip symbol, named it "VolTick", and added a mouse listener like so: Mouse.addListener(VolTick);. Now, in the reference for Flash MX, Mouse.addListener[/B} registers and object. Is the MC symbol, "VolTick", technically and object? When I debug my movie inside of Flash MX and add a "trace" method, even if the mouse isn't directly over the "VolTick" MC symbol, the trace method is invoked. How do I make it so that the trace method (or in general, the "VolTick.mouseMove = function() { ... };" ) is invoked ONLY when the mouse moves over the VolTick MC symbol? Thank you again. Mouse.addListener Availability Flash Player 6. Usage Mouse.addListener (newListener) Parameters newListener An object. Returns Nothing. Description Method; registers an object to receive notifications of the onMouseDown, onMouseMove and onMouseUp callback handlers. The newListener parameter should contain an object with defined methods for the onMouseDown, onMouseMove, and onMouseUp events. When the mouse is pressed, moved, or released, regardless of the input focus, all listening objects that are registered with the addListener method have either their onMouseDown method, onMouseMove method or onMouseUp method invoked. Multiple objects may listen for keyboard notifications. If the listener newListener is already registered, no change occurs.
every movieclip is an object so yes, VolTick is an object. and you can add a mouse listener when the mouse is over VolTick, but that would be redundant. you would be better served to apply mouse events directly to VolTick. for example, if you wanted to adjust the volume of the currently playing movie when the mouse is dragging your slidder you can use the following attached to VolTick (your slider, i assume): on(press){ this.startDrag(0,leftx,this._y,rigthx,this._y): // insert appropriate position-limits in startDrag(); volumeI=setInterval(_root.volumeF,100,this._x,leftx,rightx); } on(release){ this.stopDrag(); clearInterval(volumeI); } and attached to a frame: function volumeF(arg,L,R){ yourSound.setVolume(100*(arg-L)/(R-L)); }
kglad, Thank you. That sounds like a better plan and I'm going to code my movie that way. I'm just curious and this question doesn't have to be answered...why does keeping a constant eye on the mouse effect the CPU so greatly? In my opinion, that's something that should be worked on..or maybe it's somewhat of an advantage to others. Whatever the case may be, it's still odd. Thank you again for all of your kind wisdom. Regards, Adam
using a mouse listener essentially requires a loop of code that checks mouse activity (position, button presses etc) with each time increment. that requres some amount of cpu overhead. normally i wouldn't expect that to cause an apparent playback problem. but the code in your mouse listener must have required enough cpu cycles to slow playback. what was the code in your listener?
The following code is my mouse listener functions. By simply setting an interval whenever the mouse is moved over the symbols, I can easily bypass the whole mouse listener crap. By the way, after doing so, the movie plays perfectly (i.e., No lag!!!). After experiencing this problem, I now know that I must dramatically limit the amount of Mouse listening I do. I thank the creator of Actionscript for "setInterval()" and "clearInterval()". They save so much coding time and give you so much more ideas to impliment into your movies. I love it! Thank you kglad for all of your input. Regards, Adam // was previously VolBG.onMouseMove = function() {}; function VolBGonMouseMove() { if(overVolBG && !VolSliderMoving){ tempVolLevel = VolBG._xmouse+50; tempVolLevel = (tempVolLevel > 100) ? 100 : tempVolLevel; tempVolLevel = (tempVolLevel < 0) ? 0 : tempVolLevel; timerText = " " +(tempVolLevel)+ " %"; } } // was previously VolTick.onMouseMove = function() {}; function VolTickonMouseMove() { if(overVolBG && VolSliderMoving){ tempVolLevel = (VolBG._xmouse+50); tempVolLevel = (tempVolLevel > 100) ? 100 : tempVolLevel; tempVolLevel = (tempVolLevel < 0) ? 0 : tempVolLevel; timerText = " " +(tempVolLevel)+ " %"; controller.volumeSet = tempVolLevel; controller.mySound.setVolume(tempVolLevel); } else if(overVolBG && !VolSliderMoving){ tempVolLevel = VolBG._xmouse+50; tempVolLevel = (tempVolLevel > 100) ? 100 : tempVolLevel; tempVolLevel = (tempVolLevel < 0) ? 0 : tempVolLevel; timerText = " " +(tempVolLevel)+ " %"; } } // was previously DurTick.onMouseMove = function() {}; var i = 0; function DurTickonMouseMove() { with(DurTick){ if(DurSliderMoving && controller.IsPlaying){ // calculate elapsed time for song absoluteDurHours = ( ( (controller.mySound.duration * .001) /60) /60); absoluteDurMinutes = ( (controller.mySound.duration * .001) /60); absoluteDurSeconds = controller.mySound.duration * .001; absoluteDurPos = (DurTick._x-Dur_left); // between 0 and 100 secsPerTick = absoluteDurSeconds/100; tempNewSecs = (absoluteDurPos * secsPerTick); controller.p_hours = Math.floor(((controller.mySound.position * ..001)/60)/60); controller.p_minutes = Math.floor((Math.floor(controller.mySound.position * .001)/60)); controller.p_seconds = Math.floor((tempNewSecs)); playAt = Math.floor((tempNewSecs)); // This does a little fancy check to increase the minutes when seconds reach 60 i = ((tempNewSecs/60) >= (i+1)) ? Math.floor(tempNewSecs/60) : i; // moving right i = ((tempNewSecs/60) < i) ? Math.floor(tempNewSecs/60) : i; // moving left controller.p_minutes = i; controller.p_seconds = (controller.p_seconds > 59) ? (controller.p_seconds - (60*controller.m)) : controller.p_seconds; controller.m = (controller.p_minutes > 0) ? controller.p_minutes : (controller.m*1); controller.n = (controller.p_minutes == controller.n) ? (controller.n+1) : (controller.n*1); controller.p_seconds = (controller.p_seconds == 60) ? "0" : controller.p_seconds; controller.p_seconds = (controller.p_seconds < 10) ? "0"+controller.p_seconds : controller.p_seconds; timerText = (controller.p_hours>0 && controller.d_hours>0) ? ((controller.p_hours+":"+controller.p_minutes+":"+controller.p_seconds)) : (controller.p_hours>0) ? ((controller.p_hours+":"+controller.p_minutes+":"+controller.p_seconds)) : (!controller.p_hours>0 && controller.d_hours>0) ? ((controller.p_minutes+":"+controller.p_seconds)) : (controller.p_minutes+":"+controller.p_seconds); } } }
Actually, each function is designated it's own MC instance in which case, there are three separate intervals; one for each function. The CPU rate is not affected by doing a setInterval, unlike the object.onMouseMove() methods. I see your point though. Is there a simpler way to go about displaying (1) the actual time position in the song when someone drags the duration tick [like in Win. Media Player], (2) The volume level when cursor is "over" the volume slider, (3) The volume level as the user drags the volume tick? This seams to be the most beneficial and easy way to do what I just described. Any suggested are greatly appreciated. Regards, Adam
if you're initiating 3 setInterval()'s when your slider is pressed (and clearInterval() when your slider is released) to check those check those 3 things, then that shouldn't be a problem. i thought those functions were executing in response to mouse movements.
[Note: MC = "Movie Clip" in this thread/post] Yeah, oringinally they were. However, I converted the Mouse listener code ( object.onMouseMove = function() {...} ) into normal functions in which each function has it's own interval; when mouse is moved over MC A, setInterval(functionA, i). where i is time in milliseconds, calls functionA(). Then clearInterval(functionA_ID) is set when mouse is moved off MC A...and this is the case for three separate movie clips: (1) The background for my volume slider, (2)the volume slider itself, and (3) the duration slider. I hope that explanation helps a little better. Regards, Adam
Don't see what you're looking for? Try a search.
|