remove child = null before setting it to null?

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

Posted On: Thursday 25th of October 2012 10:29:26 PM Total Views:  232
View Complete with Replies

Related Messages:

help with removeChild   (58 Views)
I am new to Flash and still learning. I found this magnify code and tweaked it a bit. I wanted the magnifying glass to appear and work on the click of a button instead of automatically appearing as the code was designed. Here is the code: Code: var magPoint:Point = new Point(0, 0); var dMap:BitmapData = new BitmapData(colorMap_mc.width, colorMap_mc.height) dMap.draw(colorMap_mc) /// I was able to add the function to a button by adding this code goMagnify.addEventListener(MouseEvent.CLICK, magA); goMagnify.useHandCursor = true; function magA(e:MouseEvent):void{ addChild(lens_mc); //////////// end of added code addChild(colorMap_mc); var magFilter:DisplacementMapFilter = new DisplacementMapFilter (); magFilter.scaleX = 50 magFilter.scaleY = 50 magFilter.componentX = 2 magFilter.componentY = 4 magFilter.mode = "color" magFilter.color = 0x000000 magFilter.alpha = 0 magFilter.mapPoint = magPoint; magFilter.mapBitmap = dMap; scrollPane.filters = [magFilter] scrollPane.addEventListener(Event.ENTER_FRAME, onFrame) function onFrame(e:Event){ magPoint.x += ((mouseX-colorMap_mc.width -90)-magPoint.x)*0.3 magPoint.y += ((mouseY-colorMap_mc.height -80)-magPoint.y)*0.3 lens_mc.x = magPoint.x-19 lens_mc.y = magPoint.y+13 magFilter.mapPoint = magPoint scrollPane.filters = [magFilter] } } //with this code I can only remove lens_mc the remove colorMap_mc does not work noMagnify.addEventListener(MouseEvent.CLICK, magB); noMagnify.useHandCursor = true; function magB(e:MouseEvent):void{ addChild(lens_mc);///graphic removeChild(lens_mc);///graphic addChild(colorMap_mc);///magnifier removeChild(colorMap_mc);///magnifier } With this I can get the graphic and the magnifier to appear but only the graphic to disappear. How can I get both to appear and disappear with the click of a button
remove from array   (51 Views)
i am creating an array that holds my variables... details.push([vCode,vColor,vItemNumber]); but i want to delete the row from the array where vItemNumber = mymovie.mytextlist.selectedItem.ItemNumber but what is the code to delete data from the array hope that makes sense!
Want to remove XML tags.   (53 Views)
I'm tryng to remove xml tags from the data that is imported to the stage. Tryed many different ways but all get me errors. How to it in the right way Right now everything from the xml file shows up, but i want it to show only text between title and kirjeldus tags. here's the fla file ActionScript Code: import; import fl.controls.UIScrollBar; import; var myTxt:TextField = new TextField(); myTxt.border = true; myTxt.width = 300; myTxt.height = 400; myTxt.x = 100; myTxt.y = 50; var mySb:UIScrollBar = new UIScrollBar(); mySb.direction = "vertical"; // Size it to match the text field. mySb.setSize(myTxt.width, myTxt.height); // Move it immediately below the text field. mySb.move(myTxt.width + myTxt.x, myTxt.y); // put them on the Stage addChild(myTxt); addChild(mySb); // load text var loader:URLLoader = new URLLoader(); var request:URLRequest = new URLRequest("N:/Search/search.xml"); loader.load(request); loader.addEventListener(Event.COMPLETE, loadcomplete); function loadcomplete(event:Event) { // move loaded text to text field myTxt.text =; // Set myTxt as target for scroll bar. mySb.scrollTarget = myTxt; } and heres xml file Code: Toiduaine1 Kogus: 100g Rasva: 1.8 g. Valke: 3.9 g. Ssivesikuid: 94 g. Kiudaineid: 5.7 g. Kaloreid kokku: 390 Kcal Toiduaine2 Kogus: 200g Rasva: 1.8 g. Valke: 3.9 g. Ssivesikuid: 94 g. Kiudaineid: 5.7 g. Kaloreid kokku: 390 Kcal
removeChild() not working   (68 Views)
i tryied all 3 methods removeChild() removeChildAt() unloadAndStop(); but still m unable to unload file. Actually m loading a swf file which contains a video. The other video gets loaded but its sound continues. Can anyone suggest me any solution.. m new on as3... this is the code what i had tried: i= interviewVideo_mc.empty_mc.numChildren; while(i--){ trace("in while "+i); interviewVideo_mc.empty_mc.removeChildAt(i); } interviewVideo_mc.empty_mc.unloadAndStop(); interviewVideo_mc.empty_mc.removeChild(module1Load er); interviewVideo_mc.empty_mc.removeChildAt(0);
away3D add/remove/add again error   (189 Views)
hi, i have one problem, and i've been searching a lot but can't find an answer with this, i hope you can help me... with an addChild i'm loading an external swf with away3D content, it loads without a problem, then i want to unload it, i've tryied with unload(); and removeChild, and it unload, until here, everything woks perfect... BUT.... when i try to load again the movie there's an error... Error #1009: No se puede acceder a una propiedad o a un mtodo de una referencia a un objeto nulo. at CUBE_fla::MainTimeline/MouseDown() this is the code to insert the movie, it is in a function with a listener a normal button... and the code to unload... ActionScript Code: var galeria3D = new Loader(); galeria3D.load(new URLRequest("CUBE.swf")); contSwfext.addChild(galeria3D); cubeTit.m9.addEventListener(MouseEvent.CLICK, cierraCub); function cierraCub (e:MouseEvent):void{ galeria3D.unload(); i think that the problem is not here, because i'm doing exactly the same with another swf movies and this is not happening... i think the problem is in CUBE.swf, cause it has a stage.addEventListener...then the movie tries to acced to the stage when it is not ready yet... but i don't know how to solve it... this is the code in CUBE that i think is causing the problem ActionScript Code: function MouseDown(event:MouseEvent):void{ lastPanAngle = camera.panAngle; lastTiltAngle = camera.tiltAngle; lastMouseX = stage.mouseX; lastMouseY = stage.mouseY; move = true; view.render(); } stage.addEventListener(MouseEvent.MOUSE_DOWN, MouseDown); I tried adding a contentLoaderInfo but doesn't work, i mean it loads without problem, and unload... but same problem... loading again i have the same error... and the movie turns slow... this is the code anyway... ActionScript Code: var contenedor:MovieClip = new MovieClip(); var galeria3D:Loader = new Loader(); galeria3D.load(new URLRequest("CUBE.swf")); galeria3D.contentLoaderInfo.addEventListener(Event.COMPLETE, insertMovie); function insertMovie(evt:Event):void{ addChild(contenedor).name = "contenedor"; contenedor.addChild(galeria3D).name = "galeria3D"; } if you have any idea to solve it i'll appreciate that, i'm desperate, my actual solution is just to made an alpha when it is load but the solution is far away from being an elegant solution, and the movie runs kind of slow... Thank's for your attention...
addChild/removeChild Problem   (76 Views)
I have no ideo why that smily face is in there or why there are some random spaces, like in that "s ayhelp" and "st ophelp" business. Those aren't in my code. Everything else in the code looks correct.
Can't remove all loaded children in a gallery because can't close() a loader!   (253 Views)
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.
AS3.0>>> removeChild   (88 Views)
I'm assuming some of you's must be doin some AS3.0 so i'll post it here to see if anyone knows the answer. i have an array of MovieClips that i'm checking in an enterFrame event to see if the scaleX has hit one... if it has remove the child from the display list. I keep getting an ArgumentError: Error #2025: The DisplayObject supplied must be a child of the caller. now... what i'm doing is adding a child on every frame (a mc)... pushing it into an array and then checking the whole array to see if nay have hit their target scaleX's as below Code: for (var i:int = this.ball_array.length - 1; i >= 0; i--) { if (this.ball_array[i].scaleX >= 1) { this.removeChild(this.ball_array[i]); } } there's obviously somit worng with the way i'm doing this. Does anyone have any ideas Cheers Jimmy
How would you remove these listeners?   (81 Views)
PHP Code: functionaddListeners(...objects):void { for(vari:int=0;i
removeChild from inside a class   (73 Views)
, I have a hopefully very simple problem. I created two children from my document class "MainClass". One (hero) is of the class "HeroDo" and another is from the class "canDy". Code: public static var hero:HeroDo=new HeroDo public static var blue:canDy=new canDy public function MainClass () { this.addChild(blue) this.addChild(hero) ... Now the simple thing I want to do is to remove the "blue" child from within a function of the "hero" child and the hero child to remove itself from "its inside". I tried this, but it gives me an error. :C Code: removeChild( I'm very new to AS3, so sorry if that is a stupidly easy question.
Flash question about removeChild()   (75 Views)
Hi. So, I read this article "What removeMovieClip() Becomes in AS3" here on kirupa, and I still don't get something about it. So I put an MC on the stage using addChild(), which I linked to a class in the properties. That class checks (among other things) the Y-position of the MC in each frame, and then removes it from the display list when it reaches a certain position. Now, the code keeps running of course, and thus try to remove the MC each frame, since it still seems to be at the wrong position. Since it has already been removed, I get error messages of course. I could put most of the code of that class in a try/catch thing or check with some if's whether the MC is still on the stage. However, depending on the amount of MCs I put on the stage this way, I'd end up with quite some amount of useless code that would check stuff each turn. Now in that article was said: However, removeChild() will not remove the instance from memory, only the display list so it is not seen by the user. If you need the movie clip to be removed from memory, you will need to make sure there are no variables left that reference that movie clip. For class properties, null is used; for dynamic properties, delete. My question is: Do I then have to manually delete every variable, listener, property etc that might be associated to that clip So first the event-listener that checks each frame where the MC is, then the variables containing other information about the MC and so on... or is there some kind of function that does all this for me
Unload and removeChild problem   (105 Views)
I'm having trouble trying to get rid of an image in my container when I click on a thumbnail. I keep getting an error saying DisplayObject must be a child of the caller. I've looked around the web and can't figure out what I'm doing wrong, nor am I sure what the error means when its referencing the caller. Any help appreciated! Code: stop(); import fl.containers.UILoader; import caurina.transitions.*; //---------loading the external xml file------- var urlRequest:URLRequest = new URLRequest("luxury.xml"); var urlLoader:URLLoader = new URLLoader(); var myXML:XML = new XML(); var xmlList:XMLList; myXML.ignoreWhitespace = true; urlLoader.addEventListener(Event.COMPLETE,fileLoaded); urlLoader.load(urlRequest); var featureURL:String = new String; var main_content:Sprite; var featureLoader:Loader; var featureDesc:String; //--------holds the paths to the thumbnails------- var arrayURL:Array = new Array(); //--------holds the paths to the big photos------- var arrayName:Array = new Array(); //--------holds the thumbnail objects------- var holderArray:Array = new Array(); //--------represents the number of collumns------- var nrColumns:uint = 2; //-------represents the container of our gallery var sprite:Sprite = new Sprite(); addChild(sprite); var thumb:Thumbnail; //-------- the thumbnails container------- var thumbsHolder:Sprite = new Sprite(); sprite.addChild(thumbsHolder); //-------- the photoLoader container------- sprite.addChild(imageArea); //-------- loads the big photo------- var photoLoader:UILoader = new UILoader(); photoLoader.y = 30; photoLoader.x = 10; photoLoader.width = 550; photoLoader.height = 330; imageArea.addChild(photoLoader); //-------load feature--------------- function loadFeature():void{ featureLoader = new Loader(); featureLoader.load(new URLRequest(featureURL)); featureLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadImage); } function loadImage(event:Event):void{ imageArea.addChild(featureLoader.content); featureLoader.content.x = 25; featureLoader.content.y = 30; imageArea.desc.text = featureDesc; } /* we loop through the xml file populate the arrayURL, arrayName and position the thumbnalis */ function fileLoaded(event:Event):void { myXML = XML(; xmlList = myXML.children(); ParseProperty(myXML); loadFeature(); for (var i:int=0; i
Does BitmapData.dispose() remove memory occupied by its Bitmap   (85 Views)
, This is my scenario 1: I upload an image 2: Without altering it,I make a copy of it and use it display to users in resized format note: I won't display the original image. 3:Now when user deletes the resized image,i need to delete the image loaded as bitmap i.e. the original image which i won't be displaying For that I used bitmap.bitmapData.dispose() method.But,it doesn't free up the memory taken by the bitmap. For instance at initial state the memory usage is 58 Mb and upon loading 3 images the size increases to 87 Mb. And when I delete all the images the size decreases to 81 MB only. So,I feel the loaded bitmap is not completely removed. Any idea what should I do
all remove or no remove   (58 Views)
This is the code for my rotating menu in scene two,the problem description is in below //Save the center coordinates of the stage var centerX:Number = stage.stageWidth / 2; var centerY:Number = stage.stageHeight / 2; var NUMBER_OF_ITEMS:uint = 11; //Radius of the menu circle (horizontal and vertical) var radiusX:Number = 200; var radiusY:Number = 100; //Angle difference between the items (in radians) var angleDifference:Number = Math.PI * (360 / NUMBER_OF_ITEMS) / 180; //How fast a single circle moves var angleSpeed:Number = 0; //Scaling speed of a single circle var scaleSpeed:Number = 0.0002; //This vector holds all the items var itemVector:Vector. = new Vector. ; //This loop creates the items and positions them //on the stage for (var i:uint = 0; i < NUMBER_OF_ITEMS; i++) { //Create a new menu item var item:Item = new Item(); //Get the angle for the item (we space the items evenly) var startingAngle:Number = angleDifference*i; //Set the x and y coordinates item.x = centerX + radiusX * Math.cos(startingAngle); item.y = centerY + radiusY * Math.sin(startingAngle); //Save the starting angle of the item. //(We have declared the Item class to be dymamic. Therefore, //we can create new properties dynamically.) item.angle = startingAngle; //ow no mouse children item.mouseChildren = false; //Add the item to the vector itemVector.push(item); //Add the item to the stage addChild(item); //Add an item number to the item's text field if(i==1){ item.itemText.text = "1970"; item.addEventListener(MouseEvent.CLICK,y1970); function y1970(event:MouseEvent):void { gotoAndPlay(1,"y1970"); parent.removeChild(this); } } else if(i==2){ item.itemText.text="1975"; item.addEventListener(MouseEvent.CLICK,y1975); function y1975(event:MouseEvent):void { gotoAndStop(1,"y1975"); parent.removeChild(this); } } else if(i==3){ item.itemText.text="1980"; item.addEventListener(MouseEvent.CLICK,y1980); function y1980(event:MouseEvent):void { gotoAndStop(1,"y1980"); parent.removeChild(this); } } else if(i==4){ item.itemText.text="1985"; item.addEventListener(MouseEvent.CLICK,y1985); function y1985(event:MouseEvent):void { gotoAndStop(1,"y1985"); parent.removeChild(this); } } else if(i==5){ item.itemText.text="1990"; } else if(i==6){ item.itemText.text="1995"; } else if(i==7){ item.itemText.text="2000"; } else if(i==8){ item.itemText.text="2005"; } else if(i==9){ item.itemText.text="2010"; } else if(i==10){ item.itemText.text="2015"; } else{ item.itemText.text="2020"; } } //We use ENTER_FRAME to animate the items addEventListener(Event.ENTER_FRAME, enterFrameHandler); //This function is called in each frame function enterFrameHandler(e:Event):void { //Calculate the angle speed according to mouse position angleSpeed = (mouseX - centerX) / 5000; //Loop through the vector for (var i:uint = 0; i < NUMBER_OF_ITEMS; i++) { //Save the item to a local variable var item:Item = itemVector[i]; //Update the angle item.angle += angleSpeed; //Set the new coordinates item.x = centerX + radiusX * Math.cos(item.angle); item.y = centerY + radiusY * Math.sin(item.angle); //Calculate the vertical distance from centerY to the item var dy:Number = centerY - item.y; //Scale the item according to vertical distance item.scaleY = (dy / radiusY); //If we are above centerY, double the y scale if (item.y
removeChild?   (74 Views)
hello. How do I remove a child for good I am loading some text via xml and when I go to remove the child and load the next text, the next set of text goes on top of the old set of text because it is still in the sprite that was used and is being reused for the new text. I used removeChild(masterHolder); and then called the function which loads the next xml text. If that does not make sense pls let me know!
removeChild not working   (91 Views)
, I am new to flash as3, I am trying to figure out how do I remove a child after I add one into a mc. here is my code: var two_mc:Two=new Two(); pic_mc.addChild(two_mc); pic_mc.removeChild(pic_mc.two_mc); The error that is shows up is: TypeError: Error #2007: Parameter child must be non-null. at flash.display:isplayObjectContainer/removeChild() at test2mc_fla::MainTimeline/frame1() I cant remove the child if i add a child inside a movieclip, is there something that iam doing wrong Thank you
removeChild(myMc) Problem?   (67 Views)
Hi , I am pretty new to as3. I am trying to build a website, and here is the logic behind my problem. 1- I have a "Gallery" button which will go and get the "Gallery" movie clip from the library when clicked 2- I have an "About" button which will go and get the "About" movie clip from the library when clicked HERE IS THE PROBLEM: the movie clips adds up on top of each other, How am I supposed to remove anyother pre-existing movie clips on the stage and the removeChild(); doesn't work here is the colde about_btn.addEventListener(MouseEvent.CLICK, getAbout); function getAbout(event:MouseEvent):void { var myMovieClip:MovieClip = new aboutTest(); addChild(myMovieClip); setStage(); stage.addEventListener(Event.RESIZE, stageResize); function setStage():void { var WIDTH:Number = stage.stageWidth; var HEIGHT:Number = stage.stageHeight; myMovieClip.x = WIDTH/2; myMovieClip.y =330; } function stageResize(e:Event):void { setStage(); } } galleryTest_btn.addEventListener(MouseEvent.CLICK, getGallery); function getGallery(event:MouseEvent):void { var myMovieClip2:MovieClip = new galleryMovieTest(); addChild(myMovieClip2); setStage(); stage.addEventListener(Event.RESIZE, stageResize); function setStage():void { var WIDTH:Number = stage.stageWidth; var HEIGHT:Number = stage.stageHeight; myMovieClip2.x = WIDTH/2; myMovieClip2.y =330; } function stageResize(e:Event):void { setStage(); } var myMovieClip:MovieClip = new aboutTest(); removeChild(myMovieClip); } is this the right way to make a website at all Thankx a loooot
Flex How to remove/disable link from loaded swf content?   (120 Views)
How to remove/disable link from loaded swf content In flex I have an image component, which loads swf through "source". This loaded swf contains "clickable" links. I want to this loaded swf a simple image behave.
remove MovieClip   (75 Views)
how can I remove a movie clip on MOUSE OUT What am I doing wrong here that is giving me this error Error: ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller. at flash.display:isplayObjectContainer/removeChild() at MethodInfo-14() out Code Used: Code: item.addEventListener(MouseEvent.MOUSE_OVER, roll4); function roll4(e:MouseEvent):void { trace("rolled"); var realShirt1:real = new real(); addChild(real1); } item.addEventListener(MouseEvent.MOUSE_OUT, out4); function out4(e:MouseEvent):void { removeChild(real1); }
Sprite trying to remove itself from the stage is throwing errors.   (118 Views)
I'm trying to have a bullet Sprite remove itself from the stage once it is off the stage, but Flash keeps throwing #1009 errors at me. I've looked over the code several times and don't understand what's wrong. Bullet code: Code: package { import flash.display.Sprite; import flash.display.MovieClip; import*; public class Bullet extends Sprite { private var bullet_direction; private var bullet_speed; public function Bullet(xLoc:Number, yLoc:Number, angle:Number, speed:Number) { x = xLoc; y = yLoc; bullet_direction = angle; bullet_speed = speed; addEventListener(Event.ENTER_FRAME, BulletMovement,false,0,true); } public function BulletMovement(e:Event) { y -= bullet_speed * Math.sin(bullet_direction); x += bullet_speed * Math.cos(bullet_direction); if ( x > 500 || x < -20 || y > 660 || y < -20 ) { DestroyBullet(); } } public function DestroyBullet():void { removeEventListener(Event.ENTER_FRAME, BulletMovement); (stage as MovieClip).removeChild(this); } } } Error message: Code: TypeError: Error #1009: Cannot access a property or method of a null object reference. at Bullet/DestroyBullet() at Bullet/BulletMovement()