Advertisement

07.09.2008 at 11:15AM PDT, ID: 23551238
[x]
Attachment Details

Code Optimization/Check for memory leaks help..

Asked by engineroom in Macromedia Flash

Hey all, I built this flash application that will Stream videos from a site based on an XML doc. I don't really have a question. Being that i'm no flash expert, I was hoping to get an extra set of eyes for my code. Is there anything i can do to optimize it? Do i have any memory leaks of any sort?  Please let me know. I would really appreciate it!

er

P.S.  frame(2) just does a gotoAndPlay(1)  Thanx all!Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
var video:Video = new Video(1280,720);
addChild(video);
 
var xml:XML;
var whoIs:Number = 0;
var firstTime:Boolean = true;
var curVideo:String;
 
var nc:NetConnection = new NetConnection();
nc.connect(null);
 
var ns:NetStream = new NetStream(nc);
ns.addEventListener(NetStatusEvent.NET_STATUS, onStatusEvent);
 
function onStatusEvent(stat:Object):void
{
	switch(stat.info.code){
		case "NetStream.Play.Stop" :
		
		if (whoIs<xml.video.length()-1){
		whoIs++	
		}else{
		ns.close()
		
		gotoAndPlay(2);
		}
	
		curVideo = xml.video.attribute("vName")[whoIs];	
		ns.play("http://www.site.com/videos/"+curVideo);
		
	}
}
					
var meta:Object = new Object();
meta.onMetaData = function(meta:Object)
{
	trace(meta.duration);
}
 
ns.client = meta;
 
video.attachNetStream(ns);
 
 
 
/* XML Loading Code and Intial Display of Rates and header */
 
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onLoaded);
 
function onLoaded(e:Event):void
{
	xml = new XML(e.target.data);
	curVideo = xml.video.attribute("vName")[whoIs];
	
	
	ns.play("http://www.site.com/videos/"+curVideo);
 
}
 
loader.load(new URLRequest("http://www.site.com/xml.asp?zid=3"));
 
stop();
 
 
Loading Advertisement...
 
[+][-]07.24.2008 at 01:00PM PDT, ID: 22082927

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Macromedia Flash
Sign Up Now!
Solution Provided By: blue-genie
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628