child swapdepths?

I have a question about a child component's hitTest. Say I have a MainCanvas component which holds ViewZero, ViewOne and ViewTwo. Further, ViewTwo holds a ComboBox (which I'm creating from scratch).

- ViewZero
- ViewOne
- ViewTwo

Within that ComBox, I have a dropdown which slides up and down. When the ComboBox is dropdown is visible, I want to test for it's hitTest so I can close it. For example, in AS2 I can do something like this:

Code: private function mouseDownHandler() : Void { closeOnMouseUp = isDropVisible && (!dropdownCanvas.hitTest(_level0._xmouse, _level0._ymouse, false) } private function mouseUpHandler() : Void { if (closeOnMouseUp) //Close the dropdown; }

Posted On: Thursday 25th of October 2012 11:20:26 PM Total Views:  317
View Complete with Replies

Related Messages:

Flash Replacing array and removing previous children   (294 Views)
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(; 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.
Targeting mc children only   (320 Views)
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
Flex form layout - add first child vertically aligned with label   (333 Views)
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
Same base class for two different child classes in different swfs   (312 Views)
, 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
how can i keep one child by default when my page loads?   (285 Views)
hi , i want to keep Default one child when my page loads.i have arraycollection of the 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 forward
Can't addchild within this class?   (319 Views)
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.
targeting child of parents child   (297 Views)
, 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!
Change parent without moving child   (299 Views)
, I'm working on a project and I need to be able to change the movieclips parent without moving the child, so I can tween it into position myself. Any ideas on how I would do this
How to add a child to a particular scene's stage?   (309 Views)
I have to scenes, dashboard and game. I want to add a child just to game's stage. Can someone tell me the syntax for this
remove child = null before setting it to null?   (282 Views)
sometimes I remove child and trace it afterwards and it outputs null although I havent yet set it to null, why is that and do I need to set it to null also in that case Code: trace(holderArr[loadedThumbs].getChildByName("photo_bg")); //[object MovieClip] holderArr[loadedThumbs].removeChild(holderArr[loadedThumbs].getChildByName("photo_bg")); trace(holderArr[loadedThumbs].getChildByName("photo_bg")); //null holderArr[loadedThumbs].photo_bg = null; //trace(holderArr[loadedThumbs].getChildByName("photo_bg")); //null
Add link inside Addchild   (301 Views)
HI I have an MC that I want to add to Stage dynamically. Until here everything seems fine: for (var j:int = 0; j < nomePostosArray.length; j++) { var MC:MovieClip = new mc(); namelistscroller.text.addChild(MC);"newsMc"+j; trace("newsMc"+j); MC.y=MC.height*j+MC.y+20*j; trace(MC.y); MC.nome.text = j+". "+nomePostosArray[j]; MC.morada.text = moradaPostosArray[j]; MC.codigo.text = codigoPostosArray[j]; MC.contacto.text = contactosPostosArray[j]; MC.mapLink = ""; } the variable mapLink is inside the MC. This should be a link that should follow when someone press the link button inside MC. This is the only part that is not working. Can anyone give me a hint
How to remove childs from external Swfs?   (296 Views)
I have a huge doubt about controlling childs with external movies.. For example: Code: var myLoader:Loader = new Loader(); addChild(myLoader); The external swfs are loaded inside the myLoader variable.. How manage the external movies if they have a eventListener in a button like Code: removeMC.addEventListener(MouseEvent.CLICK, removeSwf); function (e:MouseEvent):void{ trace("What can I do"); } Simple doubt.. But I Need help!
Problems with removechild   (310 Views)
I wonder if someone can help me with removeChild i made a class preloadContent, it preloads content but when i want to load the next external image or swf he doesn't remove the old content, can someone help me with that, its a reocuring problem for me i dont understand the removechild stuff. this is my class: Code: package { import gs.*; import gs.easing.*; import flash.display.*; import flash.display.StageAlign; import flash.display.StageScaleMode; import; import*; import*; public class PreloadContent extends MovieClip { public var main; public var xmlmenu; public var imageLoader:Loader; public var container; public var placeholder; public var changeSize; public var url; public var firstTime:Boolean = true; public var hoog; public var breed; public function PreloadContent(mainClass, container, placeholder, changeSize):void { this.main = mainClass; this.container = container; this.placeholder = placeholder; this.changeSize = changeSize; } public function preloadContent(contentUrl, hoog, breed):void { this.url = contentUrl; // Show Preloader this.placeholder.preloader.visible = true; this.hoog = hoog; this.breed = breed; // Set properties on my Loader object imageLoader = new Loader(); imageLoader.load(new URLRequest(url)); imageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, imageLoading); imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded); } public function imageLoaded(e:Event):void { // Hide Preloader this.placeholder.preloader.visible = false; this.changeSize.changeSize(this.hoog, this.breed); // The container animation takes 1 seconde so wait until the animation is done and then load the image, 1, {onComplete:placeContent}); } public function placeContent():void { // remove content if (firstTime == false) { this.placeholder.imageLoadArea.removeChild(imageLoader); } // Load Content this.placeholder.imageLoadArea.addChild(imageLoader); trace(image); firstTime = false; } public function imageLoading(e:ProgressEvent):void { // Get current download progress var loaded:Number = e.bytesLoaded / e.bytesTotal; // Send progress info to "preloader" movie clip this.placeholder.preloader.SetProgress(loaded); } } }
How to remove child?   (294 Views)
When beginning without any key pressed the ryustance_mc plays as it should. When right or left key is pressed the ryuwalk_mc plays but the ryustance_mc plays at the background. How to remove it from the holder The thing is when I stop pressing any of the keys then ryustance_mc must play again. function control(event:Event):void { if(rightKeyIsDown) { holder_mc.addChild(ryuwalk_mc);; holder_mc.x += speed; } if(leftKeyIsDown) { holder_mc.addChild(ryuwalk_mc);; holder_mc.x -= speed; } } initializeGame();[/code] Please help me. Thank You
visible children with invisible parents   (312 Views)
Hi all, I've looked but can't find this anywhere. This may well just be because it can't be done but here goes. Does anyone know of a way that I can make a MoviecClip "visible=false" whilst stopping just one of its children's, children's, children...etc from also going invisible. I am aware that it can be done by setting them all individually but this will take a lot of code (and I like tidy code...and I'm lazy), and I am reluctant to use a loop as it will interrupt the animation that is going on at the time. Any suggestions would be appreciated.
delete all children   (320 Views)
I have a movieclip that will have between 3 and 6 children in it. I need a way to delete all the children. What is the best way to do this Cheers, AK
Access a var inside a child MC   (301 Views)
I'm new to AS3 and have a movie clip on the stage that contains a var, the MC is called "myMC" ie Code: var path = "my path";//this is in the first frame of myMC I want to access this value from the parent element, in this case it is the stage. So on the first frame on my stage i have, Code: trace(myMC.path);// this returns underfined This would work in AS2. Can i access this or do i need to create a class to access vars of a child
clicking on a sprite with a textfield child   (349 Views)
kirupers!!! I've been out of as3 for a few weeks but when I start coding again, I start coming back again to the forum I have a movieclip in the library (menu_button) which only consists of a textfield. This is an item of a dynamic menu I build by adding new instances of the menu_button class. It seems that when I click in the movieclip, it's the textfield that fires the mouse event, instead of the movieclip which contains the textfield. Whe I do trace( I get "dynamic" (for dynamic textfield I supose...) Another problem I have is that when I do menu_button.buttonMode= true I don't get that gloved hand we all love... this should be simple... Am I missing something important TIA! Pier
Controlling .text prop of a TextField as a child object of a MovieClip - not working   (343 Views)
, I know this one is going to sound ridiculously stupid, but while I am more than capable of controlling the text property of a TextField when it is on the stage by itself, my testing of a altering a TextField's text as a child of a MovieClip object is failing miserably. Can anyone tell me what kind of knuckleheaded mistake I'm making I tried to write out the code as clean as possible below... //IMPORTS... //VARIABLES... //create movieclip object var myMovieClip:MovieClip = new MovieClip(); //create object to be made a child object of myMovieClip var myChildObject:TextField = new TextField(); myChildObject.text = "Child Object"; = "Object1";//COMMANDS... TextField //add myChildObject as a child of myMovieClip myMovieClip.addChild(myChildObject); //place myMovieClip on the stage addChild(myMovieClip);//ADDEVENTLISTENERS... //this will allow user to click on the stage activating a change in the x-coordinate of myChildObject stage.addEventListener(MouseEvent.CLICK, changeChildObjectProperties); stage.addEventListener(MouseEvent.MOUSE_WHEEL, add2ndObject);//FUNCTIONS... //ADDEVENTLISTENER FUNCTIONS... function changeChildObjectProperties(event:MouseEvent):void { //CHANGING THE 'x' & 'width' PROPERTIES WORK JUST FINE... myMovieClip.getChildByName("Object1").x += 50; myMovieClip.getChildByName("Object1").width = 250; //!!!THIS IS THE THING THAT DOESN'T WORK NO MATTER WHAT... myMovieClip.getChildByName("Object1").text = "Object1's text has been changed..."; } function add2ndObject(event:MouseEvent):void { var my2ndChildObject:TextField = new TextField(); = "Object2_" + myMovieClip.numChildren; my2ndChildObject.text =; myMovieClip.addChild(my2ndChildObject); my2ndChildObject.y += 20; } //END ADDEVENTLISTENER FUNCTIONS //NORMAL FUNCTIONS... //END NORMAL FUNCTIONS //END FUNCTIONS
How to ignore masking on one particular child   (304 Views)
Hi , I was working with masks today and something was bugging me... For example, I have a Movieclip and 2 Childs: - Parent: Movieclip - Child of Movieclip: Mask - Child of Movieclip: Shadow Now, Mask is working properly for Movieclip and is also applying the mask effect to Shadow. I would like Shadow to stay behind Movieclip but to ignore the Mask effect. Is it possible Or should Shadow be adopted by Stage instead of Movieclip