Current location: Hot Scripts Forums » General Web Coding » Flash & ActionScript » Memory leaks – eventlisteners and new sounds.


Memory leaks – eventlisteners and new sounds.

Reply
  #1 (permalink)  
Old 10-13-10, 09:13 AM
jaxzjaxz jaxzjaxz is offline
New Member
 
Join Date: Oct 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Memory leaks – eventlisteners and new sounds.

Memory leaks – eventlisteners and new sounds.

Dear all,
I have written up a media player code, which does what it is supposed to do, but the System.totalMemory steadily increases with time.
My code essentially consists of nested calls using EvenListeners that trigger initiation of new sounds.
I call up mp3 files that load and start play and on EventCOMPLETE load the next file
Example of code snippet:
**
Code:
function LoadNextTheme(e:Event = null):void   	// set next theme
{
	if (A_play)  {
		nextA = new Sound();
		nextA.addEventListener(Event.COMPLETE, PlayNextTheme);
		nextA.load(gettheme);		
	}
	else 	{
		nextB = new Sound();
		nextB.addEventListener(Event.COMPLETE, PlayNextTheme);
		nextB.load(gettheme);		
	}	
}

function PlayNextTheme(e:Event):void	
{
		if (A_play) {
			ThemeLong = nextA.length; 
			if (SC_A != null) {SC_A.stop();}										
		      SC_A = nextA.play();
		}
		else   {
			ThemeLong = nextB.length; 
			if (SC_B != null) {SC_B.stop();}										
			SC_B = nextB.play();
			SC_B.soundTransform = muteform_AB;						
		}
	var timer_AB: Timer = new Timer(ThemeLong - dt,1);	
	if (special conditions met) {
		timer_AB.addEventListener(TimerEvent.TIMER, LoadNextTheme); 
		timer_AB.start();	 
}
What parts of this kind of code keep adding to total system memory?
And how can I best stop that leak?
Please advice,
Jaxz
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 06:58 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.