A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Actionscript not recognizing "stage" properties (access of undefined property)

  1. #1
    Junior Member
    Join Date
    Oct 2007
    Posts
    1

    Actionscript not recognizing "stage" properties (access of undefined property)

    Not too hard of a problem, I'm just missing something minor probably. All my stage objects in flash are set up with instance names, referenced the AS file within the flash file, and turned off "automatically create stage instances" but I still get errors for every instance I reference in my actionscript file (1120: Access of undefined property btnSite

    My AS file:
    Code:
    package
    {
    	import flash.display.Sprite;
    	import flash.display.MovieClip;
    	import flash.events.NetStatusEvent;
    	import flash.net.NetConnection;
    	import flash.net.NetStream;
    	import flash.media.Camera;
    	import flash.media.Microphone;
    	import flash.media.Video;
    	import flash.net.Responder;
    	import fl.controls.Button;
    	import fl.controls.TextInput;
    	import flash.events.SyncEvent;
    	import flash.events.MouseEvent;
    	import flash.net.SharedObject;
    	import flash.net.URLRequest;
    	import flash.net.navigateToURL;
    	import fl.controls.TextArea;
    	import flash.events.FocusEvent;
    	import fl.events.ComponentEvent;
    	import flash.net.ObjectEncoding;
    
    	public class CommSuite extends Sprite
    	{
    		private var netOut:NetStream;
    		private var netIn:NetStream;
    		private var nc:NetConnection;
    		private var videoOut:Video;
    		private var videoIn:Video;
    		private var myStream:String;
    		private var clientStream:String;
    		private var goodConnection:Boolean;
    		private var mic:Microphone;
    		private var cam:Camera;
    		private var responder:Responder;
    		private var rtmpNow:String;
    		private var button:Button;
    		private var webSO:SharedObject;
    		private var textInput:TextInput;
    		private var webURL:String;
    		private var webRequest:URLRequest;
    		
    		private var chatButton:Button;
    		private var textSO:SharedObject;
    		private var textArea:TextArea;
    		private var chatInput:TextInput;
    		private var chatName:TextInput;
    		private var catchKey:Boolean;
    		private var noName:Boolean;
    
    	
    		public function CommSuite()
    		{
    			NetConnection.defaultObjectEncoding = flash.net.ObjectEncoding.AMF0;
    			rtmpNow = "rtmp:/communicationSuite";
    			nc = new NetConnection;
    			nc.connect(rtmpNow);
    			
    			nc.addEventListener (NetStatusEvent.NET_STATUS,getStream);
    			
    			btnSite.addEventListener (MouseEvent.CLICK,showSite);
    			
    			inputChat.addEventListener (ComponentEvent.ENTER,checkKey);
    			
    			btnChat.label="Send Message";
    			btnChat.addEventListener (MouseEvent.CLICK,sendMsg);
    			
    			inputName.text="<Enter Name>";
    			inputName.addEventListener (FocusEvent.FOCUS_IN,cleanName);
    			
    			nc.addEventListener (NetStatusEvent.NET_STATUS,getConnected);
    			
    		}
    		
    		public function getConnected(e:NetStatusEvent)
    		{
    			goodConnection = e.info.code == "NetConnection.Connect.Success";
    			
    			if(goodConnection)
    			{
    				
    				webSO=SharedObject.getRemote("website",nc.uri,false);
    				webSO.connect (nc);
    				webSO.addEventListener (SyncEvent.SYNC,checkSite);
    				
    				textSO=SharedObject.getRemote("test",nc.uri,false);
    				textSO.connect (nc);
    				textSO.addEventListener (SyncEvent.SYNC,checkChat);
    			}
    			else
    			{
    				trace("Connection Not Established");
    			}
    		}
    		
    		public function checkSite(object:SyncEvent):void
    		{
    			for (var count:uint; count<object.changeList.length; count++)
    			{
    				switch (object.changeList[count].code)
    				{
    					case "clear" :
    					break;
    					
    					case "success" :
    					trace (webSO.data.website);
    					break;
    					
    					case "change" :
    					webRequest=new URLRequest(webSO.data.website);
    					navigateToURL (webRequest,"_blank");
    					break;
    				}
    			}
    		}
    		
    		public function checkChat(object:SyncEvent):void
    		{
    			for (var count:uint; count<object.changeList.length; count++)
    			{
    				switch (object.changeList[count].code)
    				{
    					case "clear" :
    					break;
    					
    					case "success" :
    					break;
    					
    					case "change" :
    					areaChat.appendText (textSO.data.userText + "\n");
    					break;
    				}
    			}
    		}
    		
    		private function cleanName (object:FocusEvent):void
    		{
    			inputName.text="";
    		}
    		
    		private function sendMsg (e:MouseEvent):void
    		{
    			noName=(inputName.text=="<Enter Name>" || chatName.text=="");
    			if (noName)
    			{
    				textArea.appendText ("You must enter a name \n");
    			}
    			else
    			{
    				textSO.setProperty ("userText",inputName.text +": "+ inputChat.text);
    				textArea.appendText (inputName.text +": "+ inputChat.text + "\n");
    				inputChat.text="";
    			}
    		}
    		
    		private function checkKey (e:ComponentEvent):void
    		{
    			noName=(inputName.text=="<Enter Name>" || inputName.text=="");
    			
    			if (noName)
    			{
    				textArea.appendText ("You must enter a name \n");
    			}
    			else
    			{
    				textSO.setProperty ("userText",inputName.text +": "+ inputChat.text);
    				areaChat.appendText (inputName.text +": "+ inputChat.text + "\n");
    				inputChat.text="";
    			}
    		}
    
    		private function showSite (evt:MouseEvent):void
    		{
    			webSO.setProperty ("website", "http://"+ inputSite.text);
    		}
    				
    		
    		private function getStream (e:NetStatusEvent):void
    		{
    			
    			goodConnection=e.info.code == "NetConnection.Connect.Success";
    			if (goodConnection)
    			{
    				responder=new Responder(streamNow);
    				
    				nc.call ("streamSelect",responder);
    			}
    		}
    		
    		private function streamNow (streamSelect:String):void
    		{
    			
    			cam=Camera.getCamera();
    			cam.setMode(40, 50,12);
    			cam.setQuality(0,80);
    			cam.setKeyFrameInterval(12);
    			
    			mic = Microphone.getMicrophone();
    			mic.rate=11;
    			mic.setSilenceLevel(12,2000);
    			
    			videoOut=new Video(140,140);
    			addChild(videoOut);
    			videoOut.x=53;
    			videoOut.y=46;
    			
    			
    			videoIn=new Video(140,140);
    			addChild(videoIn);
    			videoIn.x=253;
    			videoIn.y=46;
    			
    			switch (streamSelect)
    			{
    				case "left" :
    				myStream="left";
    				clientStream="right";
    				break;
    				
    				case "right" :
    				myStream="right";
    				clientStream="left";
    				break;
    			}
    
    			netOut=new NetStream(nc);
    			netOut.attachAudio (mic);
    			netOut.attachCamera (cam);
    			videoOut.attachCamera (cam);
    			netOut.publish (myStream, "live");
    			
    			netIn=new NetStream(nc);
    			videoIn.attachNetStream (netIn);
    			netIn.play (clientStream);
    		}
    	}
    }
    The errors are anything like input...or btn...etc.

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Is that class the Document class?
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Junior Member
    Join Date
    Oct 2007
    Posts
    1
    Quote Originally Posted by cancerinform
    Is that class the Document class?
    Nvm, I fixed it. All thanks to my prof's terrible lectures, instead of deselecting initiate stage properties I had to rather KEEP it checked. What a great instructor /sarcasm. Although, my other problem is still there (see other thread).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center