SEARCH YOUR SOLUTION HERE  

How to remove child?

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);
ryuwalk_mc.play();
holder_mc.x += speed;
}
if(leftKeyIsDown) {
holder_mc.addChild(ryuwalk_mc);
ryuwalk_mc.play();
holder_mc.x -= speed;
}
}


initializeGame();[/code]


Please help me.
Thank You

Posted On: Thursday 25th of October 2012 10:36:22 PM Total Views:  244
View Complete with Replies




Related Messages:

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!   (252 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(MainClass.blue) 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(event.target.data); 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 flash.events.*; 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()
remove child = null before setting it to null?   (231 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
Making a generated movieclip self destruct (remove from screen) after x seconds?   (80 Views)
I'm making a game where little parcels appear and if they aren't dragged to the correct zone within 5 seconds, they disappear and the player loses points. The problem i'm having is that i'm generating the movieclip parcel objects as follows: function generateMCByString(id:String):MovieClip { var mcObj:Object = null; mcObj = getDefinitionByName(id.toString()); return (new mcObj()) as MovieClip; } Then creating the movieclip and adding it to the screen depending on certain conditions as follows: mc = generateMCByString(currentParcel); mc.value = currentParcel; addChild(mc); mc.x = 386.9; mc.y = -100; mc.addEventListener(MouseEvent.MOUSE_DOWN, dragStarter); mc.addEventListener(MouseEvent.MOUSE_UP, dragStopper); tweenMove0 = new Tween(mc, "y", None.easeOut, -100, 238, 3, true); currentParcel is 1 of 3 (randomly selected) movieclip names (redParcel, yellowParcel and orangeParcel). What I need to do is add some code to say "after a movieclip has been generated...if it is still here in 5 seconds time..." It sounds simple but I can't figure it out for the life of me! I've tried setInterval with something like: timedProcess = setInterval(timeCheck, 5000); but how can I pass the actual movieclip "handle" along with the function so that timeCheck knows which movieclip to delete Any suggestions gratefully received!
removeChild()   (60 Views)
Hi - In my simple code I am adding a swf via addChild. Fine. Code: var nws:Loader = new Loader() nws.load(new URLRequest("news.swf")) addChild(nws) however further on in my code - I want this swf or nws var to be removed when clicking on another button .. so I use removeChild(nws); within another function. But AS3 comes up with an error saying that nws is undefined property with this removeChild line. How else can I say "when nws is loaded - and upon clicking this button - remove it"
How to remove childs from external Swfs?   (245 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   (252 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 flash.events.Event; import flash.events.*; import flash.net.*; 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 TweenLite.to(this.container, 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); } } }