accessing property of child of a display object

i need some help to understand how to access a property of a child of a DisplayObject.

within a class i have an object with the variable name: btnLMain
i have assigned it a name property: = "btnLMain";
btnLMain also has a property: btnLMain.clickNum = 0; // thats the one i need to access
when i instantiate the class (btnL) containing this code in the parent class i need to access the property "clickNum" so i did this:

var dispObj:DisplayObject = btnL.getChildByName(btnLMain);

but then i get the error: 1119: Access of possibly undefined property clickNum through a reference with static type flash.display:DisplayObject.

so then i reviewed documentation and from what i understand i am not able to access the property of the child of the DisplayObject as it is a static property... please correct me if i'm wrong.

so now i am trying to figure out how to access that property in the child Class.

do you have any advice for me

Posted On: Thursday 25th of October 2012 09:21:09 PM Total Views:  362
View Complete with Replies

Related Messages:

XML: accessing all ancestors.   (120 Views)
I am missing a way to call all xml element's ancestors like in PHP Code: element.descendants() but the other way round. Any thoughts
Error accessing images from XML   (117 Views)
Code: for (var n:int = 0; n < images.length(); n++) { if (images[n].attribute("source") == { var thumbList = images.@source[n].parent().parent().image.@thumb; thumbLoader = new Loader(); thumbLoader.load(new URLRequest(thumbList)); thumbLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbHandler); function thumbHandler(event:Event):void { addChild(thumbLoader); } } } I get all the URL.s of the images I want to load, but it also throws me these errors! Error opening URL Then all the URLs of the images Error #2044: Unhandled IOErrorEvent:. text=Error #2036: Load Never Completed. This dynamic XML gallery is driving me crazy! Anyone with good knowledge in building these and care to help out Ill pay if needs be! Another thing, does anyone know any good tutorials, documention or even books that cover everything about e4x /rundevo
loaded .swf accessing FlashVars   (124 Views)
OK, I've got an AS3 app we'll call Game.swf, which needs to access FlashVars from Game.html... easily done with Code: LoaderInfo(this.root.loaderInfo).parameters; It turns out that Game.swf is heavy enough to require a preloader. The only effective way of doing that in AS3 is to load Game.swf into Preloader.swf, which is embedded in Preloader.html. The question is, where do the FlashVars go (in Preloader.html ), and how can Game.swf access those variables Any suggestions on how to do this Many
Having trouble comprehending OOP principles of accessing objects outside of class   (116 Views)
I'm having a bit of trouble understanding how to access objects (object instantiated from other classes) from within a class. There's so much spaghetti code to go through, right now I'm porting all timeline code in one project to different classes. What are the different ways of accessing objects or classes from within one class Don't get me wrong, I understand that you have to instantiate a class and then use its name plus the dot character to access any properties, but sometimes I get confused and would just like a simple explanation of the best way to go about accessing objects from within a class (and not just the main class).
Flash running locally accessing XML   (131 Views)
I'm having the hardest time with this. I want to test this site locally. When I publish my Flash file, it loads up the XML file just fine. When I run it in a browser, however, it doesn't load up the XML file. I've found many answers to this, sandbox, crossdomain.xml, nothing seems to be working for me. This is extremely frustrating. I just want to test it locally! The swf is being embedded into my HTML page using SWFobject. Any ideas at all
Flash arg... accessing XML Attributes name... not data   (107 Views)
Bellow is an example senocular posted a long time ago. It's great but I am trying to figure out how to access the Attribute names so that I can build a hash from XML data, so I need to access more then just the attribute data, I need the attribute name as well. I want to be able to query the XML for the value "name" and "id". The deed output from the example bellow is: /* Output: name id */
External SWF - accessing the stage   (126 Views)
This works fine in my Move but when I load this as an external movie Code: stage.addEventListener(MouseEvent.MOUSE_MOVE, moveMyMouse); the error is "Cannot access a property or method of a null object reference." How can I use the parent stage to detect the mouseevents
Problem with accessing AS3 vars while using google map api   (124 Views)
I've created a google map application using AS3 that creates a map, gives it custom zoom controls and adds a custom marker to the map. I'm trying to get my custom marker to access variables on the main timeline but keep getting... TypeError: Error #1034: Type Coercion failed: cannot convert d81 to flash.display.MovieClip. at marker/frame1() Has anyone had any experience with this problem I've tried everything I could think of for accessing the variables from inside the MovieClip to sending the variables from the main timeline with no success.
Problems with dispatchEvent and with accessing a netStream object inside custom class   (121 Views)
Hej Guys! I currently work on a simple VideoObject class. This class extends Sprite. The constructor takes 3 parameters: the filename of a .flv, width and height of the video. The class does all the netConnect and netStream stuff to load the video and add it to its displayList. My goal is that I can finally simply create a new VideoObject wherever I want, supply the 3 parameters and get the reference to a sprite containing a connected, streaming and paused video. Then I could for example place the VideoObject somewhere on the stage and resume playing or seek or whatever. I hope that's understandable so far. Basically my class works. But I still encounter a bigger and a minor problem: The bigger problem: As you can see in the code below, I create a netStream inside my VideoObject class called ns as a public property. But when I try to access the netStream Object through an instance of my VideoObject, I get an error telling me that I try to access a null object reference. Tracing myVideoObject.ns returns null as well. Now what could be the problem I mean, I should be able to access the netStream object from outside the class as well, right The smaller problem: I try to dispatch a custom event when the video is ready and listen for the event from outside the class (see .fla code). The event gets dispatched but so far I have not been able to receive it. Any ideas would be highly appreciated! Here comes the class: PHP Code: package{ importflash.display.Sprite;;;;;;;; publicclassVideoObjectextendsSprite{ publicvarvideoURL:String; publicvarvideoWidth:int; publicvarvideoHeight:int; publicvarns:NetStream; publicvarvideo:Video; privatevarnc:NetConnection; privatevarmyEvent:Event; publicfunctionVideoObject(videoURL:String,videoWidth:int,videoHeight:int) { this.videoURL=videoURL; this.videoWidth=videoWidth; this.videoHeight=videoHeight; init(); } // //initialize privatefunctioninit():void { myEvent=newEvent("video_loaded"); nc=newNetConnection(); nc.addEventListener(NetStatusEvent.NET_STATUS,netStatusHandler); nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR,securityErrorHandler); nc.connect(null); } // //checknetworkconnectionandproceedifsuccessfull privatefunctionnetStatusHandler(event:NetStatusEvent):void { switch({ case"NetConnection.Connect.Success": connectStream(); break; case"NetStream.Play.StreamNotFound": trace("Unabletolocatevideo:"+videoURL); break; } } // //beginvideostreaming privatefunctionconnectStream():void { varns:NetStream=newNetStream(nc); ns.addEventListener(NetStatusEvent.NET_STATUS,netStatusHandler); ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR,asyncErrorHandler); varvideo:Video=newVideo(); video.attachNetStream(ns);; ns.pause(); video.width=videoWidth; video.height=videoHeight; video.x=-videoWidth/2; video.y=-videoHeight/2; addChild(video); dispatchEvent(myEvent); } // //handlesecurityerrors privatefunctionsecurityErrorHandler(event:SecurityErrorEvent):void { trace("securityErrorHandler:"+event); } // //handleasyncerror privatefunctionasyncErrorHandler(event:AsyncErrorEvent):void { //ignoreAsyncErrorEventevents. } } } and here is the .fla where I create a videoObject and listen for my event: PHP Code: varmyVideo:VideoObject=newVideoObject("test.flv",720,405); myVideo.x=stage.stageWidth/2; myVideo.y=stage.stageHeight/2 addChild(myVideo); trace(myVideo.ns); myVideo.ns.resume(); myVideo.addEventListener("video_loaded",onVideoLoaded); functiononVideoLoaded(event) { trace("videoloaded"); }
Problem(I think...) accessing instance objects.   (148 Views)
First up, my first post here, so hi to all. Ok the problem I've got isn't really a bug, I mean the code does what I want so far, but I think I might going about it the wrong way. Simple game, a breakout clone in AS3, although this time I was messing about splitting it up into classes, but was having trouble accessing instances of those classes... Way I got around it was to... add them to arrays... example, creating an instance of a menu... Code: var menuItem = new MainMenu(); menuArray.push({aButton:addChild(menuItem.createStartBtn())}); menuArray.push({aButton:addChild(menuItem.createOptionBtn())}); // some time later menuArray[0].aButton.x = 10; That cant be right though can it I mean I was ok with it when I was sticking instances of blocks and player paddle etc into arrays, but now sticking the menu screen into an array Is there a better way of accessing them, other then adding them to an array like thatOr am I just worrying about nothing EDIT: Well, doesn't look like I'm going to get a reply to this thread... but no worries, I found a better solution, for anyone else who might suffer a brain fart like I did and finds this, make the external class return an object, and in the main class be sure to have an object variable handy ( var bla:Object; ), just assign the returned object to that, no need for arrays. If object variable has scope, no problems accessing it form anywhere else.
Help with Senocular's TopLevel class accessing stage   (131 Views)
, Hope your Sundays is going well Mine isn't.. I;ve been struggling with Senocular's TopLevel class usage. A quick overview is that my Document Class extends TopLevel and makes th static variables (as per Senocular's post) and then I have some remoting classes that fetch things from my database. I can use the TopLevel to access [object Stage] but when I try to access anything on that it just says '1119: Access of possibly undefined property HB1 through a reference with static type flash.display:Stage' compile-time error - this is when using Code: trace(TopLevel.stage.HB1); I also tried Code: var TL = TopLevel.stage; trace(TL.HB1); which gives me "ReferenceError: Error #1069: Property HB1 not found on flash.display.Stage and there is no default value. at Remoter/::healthUpdate()" Run-time error. AM i missing some interim property that stores the actual objects There is an instance of the target on the stage with instance name of "HB1" and I can access it from the Document Class with just "trace(HB1);" I can't just pass a reference directly, and I can't find anyone with issues regarding Senocular's code, so I guess I'm just missing something. the describeType() result for the TopLevel.stage (called from non-document class) doesn't enlighten me, lots of properties but none seem to relate to much. Any help gratefully received! Edit: I have also tried playing with the linkages but didn't entirely understand what it meant, so left it with nothing ticked, but none of the settings seemed to help.
class vs. instance: accessing public methods   (143 Views)
I have a Segment class and instances of the segment class. Public functions called from the class itself fail, where functions called from instances work. Example: Code: import Scripts.Segment; // my class import flash.geom.Point; var p1:Point = new Point(1, 3); var p2:Point = new Point(7, 4); var p3:Point = new Point(4, 5); var p4:Point = new Point(5, 1); var mySegment1:Segment = new Segment(p1, p2); // generate two instances var mySegment2:Segment = new Segment(p3, p4); var p5:Point = mySegment1.intercept(mySegment1, mySegment2); // works var p6:Point = Segment.intercept(mySegment1, mySegment2); // gives me an error Error looks like this, by the way: 1061: Call to a possibly undefined method intercept through a reference with static type Class. How do I access the methods without using an instance Like the way one might use Point.distance(p1, p2)
problem with accessing sub movieclip's textfields' properties in different frames   (144 Views)
hi. i have a movieclip called rootmc in the root timeline (frame 1) and there is a 10 frame in rootmc and 10 sub mc in every frame. and there are text fields in sub mc's. like this: rootmc / mc1 (in frame1 of rootmc) / txt1 (frame 1 of mc1) rootmc / mc2 (in frame2 of rootmc) / txt2 (frame 1 of mc2) rootmc / mc3 (in frame3 of rootmc) / txt3 (frame 1 of mc3) . . . i want to restrict textfield with "0-9" and "." but i have to type every 10 frame in rootmc's to restrict like this code: mc1.text1.restrict = "0-9\\."; mc2.text2.restrict = "0-9\\."; mc3.text3.restrict = "0-9\\."; . . . how can i do this in rootmc frame 1 to restrict textfields only one frame code sorry for bad english.
Help with accessing dynamically gen mc from a class (code included).   (128 Views)
Hi all hope you had good holidays! Hope you can help. I have a doc class(main) and a mc with linkage (follower class). Basically its a mouse follower that i want as a class. But am getting this error: Main class has been instantiated correctly TypeError: Error #1009: Cannot access a property or method of a null object reference. at follower() at main() I have class inst in doc class via:- var mouse:follower = new follower(); addChild (mouse); Here is the follower class:- package { import flash.display.MovieClip; import com.greensock.TweenLite; import com.greensock.TweenMax; import; import flash.ui.Mouse; import; public class follower extends MovieClip { public function follower() { // constructor code //Listen when the mouse moves stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoves); //This function is called when the mouse moves function mouseMoves(e:Event):void { //Tween the follower movie clip to the cursor's coordinates, 0.5 ,{x :mouseX, y: mouseY}); } //Call the function which tween various properties of the follower up(); //This function adds more blur and scales the follower function up():void { //Tween the blur, 0.5, {blurFilter:{blurX:15, blurY:15}}); //Tween the scale and call the function down() when finished, 0.5, {scaleX: .75, scaleY: .75, onComplete: down}); } //This function removes blur and scales the follower function down():void { //Tween the blur, 0.5, {blurFilter:{blurX:10, blurY:10}}); //Tween the scale and call the function up() when finished, 0.5, {scaleX: 0.5, scaleY:0.5, onComplete: up}); } } } } many
accessing properties of movie clip   (107 Views)
I have the following prob : I created several instance of the same MC like this ActionScript Code: for (j=0; j
CS3 Problem accessing data loaded from external textfile.   (113 Views)
Hi , I'm trying to load data from an external textfile, called "config_flash.txt". It works perfectly if applying the fetched data is done within the same function where the loading is done. However, I would like to use the fetched variables in other parts of the script. Here's what works: Actionscript Code: var varLoader:URLLoader = new URLLoader(new URLRequest("config_flash.txt"));varLoader.addEventListener(Event.COMPLETE, completeConfiguration);function completeConfiguration(event:Event):void { var loadedVars:URLLoader = URLLoader(; var variables:URLVariables = new URLVariables(; var text1:String = variables.text1; var text2:String = variables.text2; myTextfield.text = text1 + " " + text2;} Here's what I want: Actionscript Code: var varLoader:URLLoader = new URLLoader(new URLRequest("config_flash.txt"));varLoader.addEventListener(Event.COMPLETE, completeConfiguration);function completeConfiguration(event:Event):void { var loadedVars:URLLoader = URLLoader(; var variables:URLVariables = new URLVariables(; var text1:String = variables.text1; var text2:String = variables.text2;}myTextfield.text = text1 + " " + text2; So, basically I want the variables/values defined inside the function to be available anywhere in the script. The error that the second code snippet causes is as follows: "1120: Access of undefined property text1/text2". I have a feeling that this has a very simple solution, but I'm not so good with this whole code jargon world .
problem in accessing cookie with flash in IE   (99 Views)
I want to write a Flash application which need to access my browser(Internet Explorer) cookie. My program work well in all browser except Internet Explorer. This is part of my code: Code: Quote: function test() {"eval","alert(document.cook ie)"); } What is the problem with Internet Explorer
accessing properties and methods of an external swf   (114 Views)
I've read through about 100 posts on this subject, but none seem to fit my situation. I can't access the props and methods of an external AS3 swf after it's loaded by Here's a very simplified version of the code for (the calling swf): Code: package{ import flash.display.Sprite; import; import; import flash.display.Loader; public class Main extends Sprite{ private var imgLoaded:Boolean = false; private var imgLdr:Loader; private var contentSWF:Sprite; public function Main(){ loadSWF(); } public function loadSWF():void { imgLdr = new Loader(); var urlReq:URLRequest = new URLRequest("Sub.swf"); imgLdr.load(urlReq); imgLdr.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler); } private function onCompleteHandler(event:Event):void{ event.currentTarget.removeEventListener(Event.COMPLETE, onCompleteHandler); contentSWF = event.currentTarget.content; addChild(contentSWF); trace(contentSWF.testBool); // This throws the following error: // 1119: Access of possibly undefined property testBool // through a reference with static type flash.display:Sprite. } } } Here's the code for (the external swf): Code: package{ import flash.display.Sprite; import; public class Sub extends Sprite{ private var _testBool:Boolean = false; public function Sub(){ init(); } private function init():void{ testBool = true; } public function get testBool():Boolean { return _testBool; } public function set testBool(val:Boolean):void { _testBool = val; dispatchEvent(new Event(Event.CHANGE)); } } } Can someone please help with this
accessing PHP variables within timeline   (114 Views)
I'm struggling with some actionscript and was hoping some far more knowledgable people than myself might be able to help me I have a flash counter, it works off an integer i.e number = '12345' I'm trying to hook my counter up to a PHP script that echo's a DB query. Now I've had no issue passing the variable and I can even display it in a dynamic text field but no matter what I try I cannot get the "number" varibable to use my PHP variable The dynamic text field shows the correct value clear as day but the counter just shows "undefined". The code is below with comments if anyone could point me in the right direction I would appreciate it so much! ActionScript Code: //create a new "LoadVars" object myLoadVar = new LoadVars (); //load the contents of the text file into the LoadVars object myLoadVar.load("somedomain dot com somescript.php"); //check to see if the loading is completed and, if so, put the contents in the text field myLoadVar.onLoad = function (success){ if (success == true) { // the 'seats' text field gets successfully populated with var here seats.text = myLoadVar.myCount; } } // this doesn't work number = myLoadVar.myCount // this does work though number = '12345' Many
URLLoader accessing XML from an API   (107 Views)
I'm writing a simple class that will be used to access data from an API takes XML queries and returns the data in an XML format. In my main document class I import the API class "import API;" then am accessing various methods of my class to access different calls to the API (var myAPI:API = new API();, then API.method() ) My main questions are: 1. With the URLLoader having a delay, I suppose there is no way in my main class to return data to the original call via a return statement( myXMLData = API.getSomeData() ). Basically, how do I write a generic "onComplete" function such that it knows which method in the class called it, where to store the data, and how to tell the original call in the document class that the load is complete and to begin using the data Here is the code for my class so far: Code: package { import flash.display.Sprite; import; import; import; import; import; public class API extends Sprite{ const DEV_KEY:String = "***"; var xmlResponse:XML; public function API() { } private function sendRequest(xmlData:String):void { var xmlDataEncoded:String = escape(xmlData); var xmlSendLoad:URLLoader = new URLLoader(); trace("sending: " + xmlDataEncoded); xmlSendLoad.addEventListener(Event.COMPLETE, onComplete, false, 0, true); xmlSendLoad.addEventListener(IOErrorEvent.IO_ERROR, onIOError, false, 0, true); xmlSendLoad.load(new URLRequest("" + xmlDataEncoded)); } private function onComplete(evt:Event):void { try { xmlResponse = new XML(; trace("Response: " + xmlResponse); removeEventListener(Event.COMPLETE, onComplete); removeEventListener(IOErrorEvent.IO_ERROR, onIOError); } catch (err:TypeError) { trace("An error occured when communicating with server:\n" + err.message); } } private function onIOError(evt:IOErrorEvent):void { trace("An error occurred when attempting to load the XML.\n" + evt.text); } public function getAPIVersion():void { sendRequest(""); } public function getSeason():void { sendRequest(""); } public function getUser(user:String, pw:String) { sendRequest(""); } public function getPlayerList(user:String, pw:String) { sendRequest(""); } } }