targeting child of parents child


, I;m pretty new to Kirupa, but it has helped me alot in the past finding out more about Actionscript 3. I have a problem and I cannot get to fix it, it might be a simple thing but as I'm not a real OOP coder, I'm experiencing headaches .

Here's the situation:
I have a scene(as3) with on frame one the preloader that centers on the canvas, on the second frame there's two MC's; one containing the Background that scales proportionally and centers. The second MC on the same frame contains my website content(called main_) that doesn't scale but only centers on the canvas. Now I created two buttons in that main_ MC to jump to the next frame of the Backgroud MC. so actually I'm trying to target frames or framelabels of another child of the parent of main_ MC.

I've tried multiple things like MovieClip(this.parent)... and adding the child to its parent and try to inherit its listener function. It throws errors or isn't doing anything.

I think I'm not thinking in the correct hierarchy or I'm making a mistake. Or it might not even be possible, Does anybody have some suggestions thanx in advance!
Posted On: Thursday 25th of October 2012 10:15:45 PM Total Views:  339
View Complete with Replies

RELATED TOPICS OF Flash / ActionScript PROGRAMMING LANGUAGE




Flash Need Help naming and targeting;

i need help doing this : please read and sorry if the code is too long : This is my AS file : Code: package { import flash.events.Event; import flash.net.URLLoader; import flash.net.URLRequest; import flash.display.Sprite; import fl.controls.DataGrid; import fl.core.UIComponent; import flash.display.Loader; import flash.display.MovieClip; import flash.display.Shape; import flash.events.MouseEvent; import fl.controls.Label; import fl.events.ComponentEvent; import flash.system.System; public class tut extends Sprite { private var xml:XML; var aGrid:DataGrid = new DataGrid ; public function tut() { readXML(); } private function readXML():void { var loader:URLLoader = new URLLoader(new URLRequest("points.xml")); loader.addEventListener(Event.COMPLETE,xmlLoaded); aGrid.x = 30; aGrid.y = 300; } public function restart(e:MouseEvent):void { readXML(); } public function xmlLoaded(e:Event):void { var ind:int var myCircR:int = 20; xml = new XML(e.target.data); xml.ignoreWhitespace = true; var f:uint; for (f = 0; f < xml.point.length(); f++) { var full_mc:MovieClip = new MovieClip ; var dr:MovieClip = new MovieClip ; full_mc.buttonMode = false; full_mc.x = xml.point[f]. @ xPos; full_mc.y = xml.point[f]. @ yPos; full_mc.ind = f dr.graphics.lineStyle(1) dr.graphics.beginFill(0xff0000); dr.graphics.drawCircle(myCircR/2,myCircR/2,myCircR/2); full_mc.addEventListener(MouseEvent.CLICK,drawGrid); full_mc.addChild(dr) addChild(full_mc) } } public function drawGrid(e:Event):void { aGrid.width = 250; aGrid.height = 100; aGrid.remove(); aGrid.columns = ["Label","Data"]; var s:uint; var q:Number = e.target.ind for (s = 0; s < xml.point[q].value.length(); s++) { aGrid.addItem({Label:xml.point[q].value[s]. @ label,Data:xml.point[q].value[s]}); } trace(q) addChild(aGrid); } } } here is my XML file : Code: 01Here is our message. 564848744 02Here is our message. 564848744 03Here is our message. 564848744 04Here is our message. 564848744 05Here is our message. 564848744 01Here is our message. 564848744 02Here is our message. 564848744 03Here is our message. 564848744 04Here is our message. 564848744 05Here is our message. 564848744 So as you see all i need is when i call drawGrid() i can get some kind of number from the clicked full_mc so i can loop the in that certain Please help and if anyone have any comment on my coding plz let me know.
VIEWS ON THIS POST

154

Posted on:

Tuesday 11th September 2012
View Replies!

try to targeting cursor with circle which is made by sprite.

Hi I'm a newbie about actionscript and i tried to make a circle which follow the cursor but i have a small problem here.The circle follows the cursor but there is a constant distance between my cursor and circle and i dont know what is the solution.Is there anyone who can help me p.s:Sorry about my english ,its not my native language.
VIEWS ON THIS POST

114

Posted on:

Monday 1st October 2012
View Replies!

Help with index and targeting

ppl cool forum you have here please read my code and give me some help Code: package { // import needed classes import flash.events.Event; import flash.net.URLLoader; import flash.net.URLRequest; import flash.display.Sprite; import fl.controls.DataGrid; import fl.core.UIComponent; import flash.display.Loader; import flash.display.MovieClip; import flash.display.Shape; import flash.events.MouseEvent; import fl.controls.Label; import fl.events.ComponentEvent; import flash.system.System; public class tut extends Sprite { private var xml:XML; var aGrid:DataGrid = new DataGrid ; public function tut() { readXML(); } private function readXML():void { var loader:URLLoader = new URLLoader(new URLRequest("points.xml")); loader.addEventListener(Event.COMPLETE,xmlLoaded); aGrid.x = 30; aGrid.y = 300; } public function restart(e:MouseEvent):void { readXML(); } public function xmlLoaded(e:Event):void { var ind:int; var myCircR:int = 20; xml = new XML(e.target.data); xml.ignoreWhitespace = true; var f:uint; for (f = 0; f < xml.point.length(); f++) { var full_mc:MovieClip = new MovieClip ; var dr:MovieClip = new MovieClip ; full_mc.buttonMode = false; full_mc.x = xml.point[f]. @ xPos; full_mc.y = xml.point[f]. @ yPos; full_mc.ind = f; dr.graphics.lineStyle(1); dr.graphics.beginFill(0xff0000); dr.graphics.drawCircle(myCircR/2,myCircR/2,myCircR/2); full_mc.addEventListener(MouseEvent.CLICK,drawGrid); full_mc.addChild(dr); addChild(full_mc); } } public function drawGrid(e:Event):void { aGrid.width = 250; aGrid.height = 100; aGrid.remove(); aGrid.columns = ["Label","Data"]; var s:uint; ///////problem next line var q:Number = e.target.ind; for (s = 0; s < xml.point[q].value.length(); s++) { aGrid.addItem({Label:xml.point[q].value[s]. @ label,Data:xml.point[q].value[s]}); } trace(q); addChild(aGrid); } } } xml file : Code: 01Here is our message. 564848744 02Here is our message. 564848744 03Here is our message. 564848744 04Here is our message. 564848744 05Here is our message. 564848744 01Here is our message. 564848744 02Here is our message. 564848744 03Here is our message. 564848744 04Here is our message. 564848744 05Here is our message. 564848744 so all i need is when i call drawGrid(); i can get a number like an index number from the clicked full_mc, to be the q value in drawGrid() to loop through the in that certain in my XML data.
VIEWS ON THIS POST

212

Posted on:

Monday 1st October 2012
View Replies!

geo targeting in Flash

Something has come up where we may need to do some geo targeting to deliver different content to a video player based on the client's (as in end-user) location. Basically, we would want to control the delivery based on country. This sounds like a huge, deep topic that I can't even begin to address. Anyone have any thoughts or experience doing this sort of thing with Flash content The swf may need to sit on a server we have no back-end access to, so ideally it would be a solution that doesn't require PHP or any other sort of back end...but I'm not sure if that's possible.
VIEWS ON THIS POST

111

Posted on:

Friday 12th October 2012
View Replies!

problem targeting child

all. I need a liitle help with tageting a child. I'm attaching an array of boxes from the library to the stage with a ticker interval. I want each box to do something (like go to frame 2) each time the ticker fires. How do I implement this
VIEWS ON THIS POST

225

Posted on:

Friday 12th October 2012
View Replies!

HELP: Problem targeting MovieClips within ScrollPane

, I'm trying to use scroll panes for the first time and I'm having trouble targeting the movieclips inside of the scroll pane. to clarify the set up the whole scrollpane set up is inside of bigger movieclip (mc1) which gets added dynamicaly to the stage through actionscript. I placed a scrollpane on the timeline then used the components inspector to specify a movieclip(mcContent) as the content. the movieclip has several other movieclips(link1, link2, etc.) nested inside which will act as links. that is what i need to target. my code looks like mc1.scrollPane.mcContent.link1.buttonMode = true; The thing is it doesn't work and I get an error which says ReferenceError: Error #1069: Property mnuLinks_mc not found on fl.containers.ScrollPane and there is no default value. if anyone knows what i did wrong any help would be greatly appreciated.
VIEWS ON THIS POST

132

Posted on:

Friday 12th October 2012
View Replies!

having problems targeting mc text field

I'm adding a child from the library, and trying to set the textfield (alphabet) of my movieclip (symbol9). I can't seem to figure out how to target the text of the dynamic text field alphabet. letterButton.addChild(new symbol9()); letterButton.symbol9.alphabet.text = _letterslist[i]; Isn't working. I see my movie clip, just no text.
VIEWS ON THIS POST

130

Posted on:

Friday 12th October 2012
View Replies!

having problems targeting mc text field

I'm adding a child from the library, and trying to set the textfield (alphabet) of my movieclip (symbol9). I can't seem to figure out how to target the text of the dynamic text field alphabet. letterButton.addChild(new symbol9()); letterButton.symbol9.alphabet.text = _letterslist[i]; Isn't working. I see my movie clip, just no text.
VIEWS ON THIS POST

139

Posted on:

Friday 12th October 2012
View Replies!

targeting multiple movieclips in one line of code

I have a question to which the answer might be really simple, I just can't find it anywhere It's a matter of finding the right syntax I guess. Hope one of you can help out. Lets say I have two movieclips on stage called Clip1 and Clip2 Both contain dynamic textboxes with tha same name: txtOutput I could use the following code: ActionScript Code: Clip1.txtOutput.text = "some string"; Clip2.txtOutput.text = "some string"; Or in one line: ActionScript Code: Clip1.txtOutput.text = Clip2.txtOutput.text = "some string"; But I'd like to use something like : ActionScript Code: [Clip1,Clip2].txtOutput.text = "some string"; //or [Clip1&Clip2].txtOutput.text = "some string"; //or [[Clip1],[Clip2]].txtOutput.text = "some string"; Which I just made up and does not work I have just two clips so using a for loop sounds like overkill. Does anyone know the correct syntax
VIEWS ON THIS POST

117

Posted on:

Friday 19th October 2012
View Replies!

targeting a component in a class

I want to load a swf into a byte array before loading it into an swf loader. I'm wondering how I would target a specific swf loader to do this to since I have 3 different ones.
VIEWS ON THIS POST

222

Posted on:

Friday 19th October 2012
View Replies!

add child to an added child?

Hi , I am making a simple xml gallery that loads in images into a movie clip that looks like a Polaroid. So, the idea is that flash will see how many image need to me imported. Then in the for loop it will add child the Polaroid mc (which has been exported for actionscript and the class named "Polaroid"). The inside that Polaroid mc there is an empty mc called "polimageHolder_mc" that I want to load the xml loaded image into. I keep getting this error "TypeError: Error #1010: A term is undefined and has no properties", when I use the code below. It makes sense to me but my syntax is obviously incorrect. Any ideas on how I should script it ActionScript Code: function loadPolaroidXML():void { var imageLoader:Loader; var xml:XML; var xmlList:XMLList; var xmlLoader:URLLoader = new URLLoader(); xmlLoader.load(new URLRequest("images/content.xml")); xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded); function xmlLoaded(event:Event):void { xml = XML(event.target.data); xmlList = xml.children(); for (var i:int = 0; i < xmlList.length(); i++) { imageLoader = new Loader(); imageLoader.load(new URLRequest(xmlList[i].attribute("thumbPath"))); var polaroid:Polaroid = new Polaroid; app_mc.mainSec_mc.addChild(polaroid); polaroid.x = 150 * i; polaroid.y = 100 app_mc.mainSec_mc.polaroid.polimageHolder_mc.addChild(imageLoader); } } }
VIEWS ON THIS POST

100

Posted on:

Thursday 25th October 2012
View Replies!

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.name = "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); displayObj.clickNum++; 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
VIEWS ON THIS POST

417

Posted on:

Thursday 25th October 2012
View Replies!

Can't remove all loaded children in a gallery because can't close() a loader!

0 down vote favorite This is the code i used in a gallery that loads images sequentally. My problems comes in when you have to open a different image album and have to eliminate all the previously loaded children in the movieclip. The problem is that sometimes the user leaves the album page before ALL the pics laod so when they click on a new album to open it a new image is placed somewhere else cause the loader has already been launched. I've tryd to close() the loader but it doesn't seem to work. I'd appreciate it inmensly if you can give me a hand.
VIEWS ON THIS POST

346

Posted on:

Thursday 25th October 2012
View Replies!

The supplied DisplayObject must be a child of the caller.

What does it mean And why doesnt my code work PHP Code: stop();importflash.events.Event;varTimerApple:Timer=newTimer(500);TimerApple.addEventListener(TimerEvent.TIMER,OnStartApple);TimerApple.start();functionOnStartApple(e:Event){\t\tvaraf:Sprite=newEnemy();\t\taf.x=Math.random()*640;\t\taddChild(af);\t\t\t\t//Removefromstage,willgivepoint\t\taf.addEventListener(Event.ENTER_FRAME,hitTheGround)\t\tfunctionhitTheGround(e:Event):void\t\t\t\t{\t\t\t\t\t\tif(af.hitTestObject(Basket)){\t\t\t\t\t\tremoveChild(af);\t\t\t\t\t\t}\t\t\t\t}\t\t\t\t//Controllingbasket\t\t\t\tBasket.addEventListener(MouseEvent.MOUSE_DOWN,fl_ClickToDrag_2);\t\t\t\tfunctionfl_ClickToDrag_2(event:MouseEvent):void\t\t\t\t{\t\t\t\tBasket.startDrag();\t\t\t\t}\t\t\t\t} And then the class "Enemy" PHP Code: package{\t\timportflash.events.Event;\t\timportflash.display.MovieClip;\t\timportflash.display.Sprite;\t\timportflash.text.TextField;\t\tpublicclassAppleextendsSprite{\t\t\t\tprivatevarcore:Object;\t\t\t\tpublicfunctionApple(){\t\t\t\t\t\taddEventListener(Event.ADDED_TO_STAGE,onadd);\t\t\t\t}\t\t\t\t\t\t\t\tprivatefunctiononadd(e:Event){\t\t\t\t\t\tcore=MovieClip(root);\t\t\t\t\t\taddEventListener(Event.ENTER_FRAME,loop);\t\t\t\t}\t\t\t\t\t\t\t\tprivatefunctionloop(e:Event){\t\t\t\t\t\ty+=10;\t\t\t\t\t\t}\t\t\t\tpublicfunctionremoveListeners():void{\t\t\t\t\t\tremoveEventListener(Event.ENTER_FRAME,loop);\t\t\t\t}\t\t}}
VIEWS ON THIS POST

346

Posted on:

Thursday 25th October 2012
View Replies!

Flash Replacing array and removing previous children

all. I have a problem with replacing values in an array. I have this code that takes the string values out of an XML file: Code: publicfunction loadXML(xml:Event):void { container = new XML(xml.target.data); var aantalSommen:Number = container.somTotaal.length() -1; var randomSom:Number = Math.round(Math.random()*aantalSommen); uitkomstGetal = container.somTotaal.uitkomst.text()[randomSom]; trace("Uitkomst getal: "+uitkomstGetal) deSom = container.somTotaal.som.text()[randomSom]; trace("De som: "+deSom) Ballen = container.somTotaal.andereGetallen.text()[randomSom] +","+ container.somTotaal.uitkomst.text()[randomSom]; trace("Extra ballen: "+Ballen)getallenRij = Ballen.split(","); And then this code inside a function which adds a new child (tijdelijkeBal) for every string in the array: Code: for each (var buttonArray:String in getallenRij){ tijdelijkeBal = new Getal((String)(buttonArray)); tijdelijkeBal.x = Math.random() * stage.stageWidth; tijdelijkeBal.y = Math.random() * stage.stageHeight; addChild(tijdelijkeBal); tijdelijkeBal.mouseChildren = false; ballenRij.push(tijdelijkeBal); } And I have this in my constructor function: Code: lader.addEventListener(Event.COMPLETE, loadXML); lader.load(new URLRequest("sommen/plus.xml")); So far so good. Every time I reload my application, it takes a random set of 5 strings from the XML and it adds the 5 children. What I want to do is reload the XML so that the previous added childred are replaced with new ones when I execute another lader.load(new URLRequest("sommen/plus.xml")); Right now it's so that whenever I load a new URLRequest for the XML file it just adds new children and leaves the previous ones there. I tried doing removeChild(tijdelijkeBal); but that just removes one child. I think the last one in the array in fact. I hope this made sense.
VIEWS ON THIS POST

336

Posted on:

Thursday 25th October 2012
View Replies!

Targeting mc children only

Hi everybody, i want to target all the mc nested in a parent mc and I'm using this script Code: for (var i:uint = 0; i
VIEWS ON THIS POST

353

Posted on:

Thursday 25th October 2012
View Replies!

Flex form layout - add first child vertically aligned with label

Hi all.. In flex form layout the output will be horizontal 'test' But my constraint is i want to align the textbox(first child of the form item ) vertically with the label. How can i do this Any inputs invited
VIEWS ON THIS POST

373

Posted on:

Thursday 25th October 2012
View Replies!

Same base class for two different child classes in different swfs

, Following is my code of base class : Code: public class Application extends Sprite { private static var instance:Application; public function Application() { instance = this; } private function showBlurLayer(flag:Boolean):void { //some code here... } public static function showBlurLayer(flag:Boolean):void { instance.showBlurLayer(flag); } } swfA ==> Document class Code: public function SWFA extends Application { //FLV player code goes here... } swfB ==> Document class Code: public function SWFB extends Application { public function SWFB() { addEventListener("addedToStage", addedToStageHandler); } private function addedToStageHandler(e:Event):void { Application.showBlurLayer(true); var media:Media = new Media() addChild(media); } } SWFB ==> Media class Code: public class Media extends Sprite { public function Media() { var loader:Loader = new Loader(); loader.contentLoaderInfo.addEventListener("complete", completeHandler); var closeBtn:Button = new Button(); closeBtn.label = "Close"; closeBtn.addEventListener("click", closeClickHandler); addChild(closeBtn); } private function closeClickHandler(e:MouseEvent):void { Application.showBlurLayer(false); this.visible = false; } private function completeHandler(e:Event):void { addChild(loader); } } --------------------------------------- So the problem here is when I call Application.showBlurLayer(true), it works fine (actually it applies blur filter). But after the swfA is loaded correctly, and when I click on "Close" button and call Application.showBlurLayer(false), it does not work. Can some one help in this matter Thank you, Naresh
VIEWS ON THIS POST

355

Posted on:

Thursday 25th October 2012
View Replies!

how can i keep one child by default when my page loads?

hi , i want to keep Default one child when my page loads.i have arraycollection of the container.in that i have used repeater whose dataprovider is arraycollection.what i have to do for that can i put some code in init() function.but which code i should put in it any suggestions.pl forward
VIEWS ON THIS POST

315

Posted on:

Thursday 25th October 2012
View Replies!

Can't addchild within this class?

I may be losing my mind. I am simply trying to add a textfield and addchild to that textfield. Here is the textfield class Code: package { import flash.display.*; import flash.text.TextField; import flash.text.TextFieldAutoSize; import flash.text.TextFormat; public class TextTween { // public var label:TextField; // public var labelText:String; public function setLabel(str:String) { var labelText:String = str; configureLabel(labelText); } public function configureLabel(labelText:String):void { var tField:TextField = new TextField(); tField.text = labelText; tField.x = 200; tField.y = 200; tField.autoSize = TextFieldAutoSize.LEFT; tField.background = true; tField.border = true; var format:TextFormat = new TextFormat(); format.font = "Verdana"; format.color = 0xFF0000; format.size = 10; format.underline = true; tField.defaultTextFormat = format; // addChild(tField); trace (tField.text); // traces out perfectly } } // end class } // end package This is how I am calling it from Frame 1 Code: var texty:TextTween = new TextTween(); var blah:String = "blabbers"; texty.setLabel(blah); Works great until I try to addChild to that textField from either Frame 1 or the class itself. I can trace it perfectly, trace the class, trace the functions, trace everything in the functions but I can not addChild. Ugh. Anybody know whats going on This is scaring me.
VIEWS ON THIS POST

367

Posted on:

Thursday 25th October 2012
View Replies!