ActionScript 3.0 :: Removing A Child Under A Special Condition?
Jan 28, 2010
Work_mc has to be removed when you click personal_btn under only one occurrence. When it is loaded from workss_mc. When it is loaded from workss_mc it is done with addChild.So this is the navigation in a whole.
Button
Work -> work_mc(selection of work)(on timeline) -> workss_mc (this contains all work) added as a child Personal -> personal_mc(selection of work)(on timeline) -> persoanlss_mc (this contains all personal work) added as a child
So the goal is here, is once you are in personalss_mc or workss_mc you need to be able to go back to personal_mc or work_mc to look at the selection of work here, so by doing this I am using addChild & removeChild. This is where the problem lies, if a user does this then decides to swap pages then the page overlaps work_mc or personal_mc.
I have created 2 sprites each containing a dynamic text field child. I then add this as a child of the stage. (I have done this in order to make the text clickable with a hand cursor on mouseover)It loads in fine, I just run into problems when trying to REMOVE it the sprite containing the text."ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller."Sections concerned in red:
However, either I'm declaring my variables at the wrong bit/way or there is another problem, as I have been able to add the child I want to from the display list (sidepoint: is it right to call the display list everything in the library on stage at runtime plus those things you have exported for actionscript usage??!)...but when I want to remove it at the next cuepoint nothing happens. I feel this is a basic principle that is alluding me here.
Code: vid.addEventListener(MetadataEvent.CUE_POINT, cueText); function cueText(e:MetadataEvent): void{
var ZombieInstanceTimerL:Timer = new Timer(8000,60); ZombieInstanceTimerL.addEventListener(TimerEvent.TIMER, ZombieTimerLfunction); ZombieInstanceTimerL.start();
[Code]....
Basicly im first setting a timer of 8 seconds for a zombie to sprawn then it sets the properties and then using the addChild method it adds the zombie every 8 seconds. then i made the zombie move but as if it hits the character i make it stop and go to the attacking scene which is frame 4 and then when it isnt hitting it, it goes back to frame 2 which is walking,, then i made a Zombie death code which works by in the zombie attack class it has hittests for all the weapons and it reduces a varible in a GlobalVaribles class the varible is called ZombieHP and here it says if ZombieHP is below 1 it should go to 3 which is the death scene and add a point to the score but the hp and gotoAndStop affects all of the zombies so when it hits one they all die how can i make it so only the one its hitting can be affected..
I've run into a problem when trying to move one of my sprites from the stage when it dies.So far what I'm having to do is call the Death method from the main class, which then goes to the Enemy Class in order to play the animation, once the animation has reached the last frame an event is triggered which is situated in the main frame which then removes the now dead enemy from the stage. However it doesn't appear to be able to target the child which I want removed =/Main Class:
Code: private function hitCheck(e:Event = null):void{ var samuraiPos:Number = SamuraiChar.samuraiPos();
Have a rather bizarre issue with Flex throwing an error when teh application is running in the background. I use Selenium and SeleniumFlexApi to run various tests against my app. If the browser window is in the foreground or any part of it is visible to teh screen, the test pass as expected. However, if the window is in the background and not visible, I am getting the following error in 1 part of my app.
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller. I have a VBOX that creates a number of children and then upon creationComplete(or UpdateComplete, I've tried both) it then needs to remove any of the children that are not visible. Each child has a listener for CreationComplete which checks if the child is visible and if not, adds it to an array which is iterated over when the parent UpdateComplete is fired. I cant seem to find any reason for this behavior and am curious if its an issue with the Flex Component LifeCycle.
In my document class I have assigned the root of fla to theRoot movieclip as theRoot = MovieClip(this.root); And as my program proceeds I have added several childs to theRoot. Now at the end of my program I need to delete all the childs of theRoot. So,how can I do this without individually deleting single childs.
I have these lines of code on frame 55 on the Main Timeline that generates the contact Form :
ActionScript Code: import com.warmforestflash.ContactForm; var contactForm:ContactForm = new ContactForm(); contactForm.x = -200;
[Code].....
My problem is, that I want the contact Form to be deleted everytime I change the frame means --> everytime I go to another subpage of the homepage. So I would need a script to check for instances of the contact Form class on every subpage-frame and to delete them if present.
I'm trying to create s simple website by using flash. My idea was to have a series of buttons that when i click will add a child to my stage. Now my problem is that i can only figure how to remove that child again by clicking the same button, i would like that the child could be removed by clicking any given button.
Below you see the code for two of my buttons. It is basically made up of the snippets from Flash CS5. I've restricted the amount of children thath can be added, so that no two subpages (children) can be added at the same time. When i add the child by pressing a button the child will be the seventh child on the stage. Is it possible to then make a piece of code for the button so that given a child number seven is already at the stage this will be removed?
ActionScript Code: infobtn.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF_info); var fl_Loader:InfoPage = new InfoPage(); var fl_ToLoad:Boolean = true;
I have written this little script, as i want to remove some of the text fields that are currently contained within the Display Objec, however it does not like to see the TextField as a varaible name. How would i convert the object from an array to become a textfield that can be removed, after being added through addChild()
This is the script
var delayHeading:Number = 1500;var repeatHeading:int = 1;var setShow:Timer = new Timer(delayHeading, repeatHeading);setShow.start();setShow.addEventListener(TimerEvent.TIMER_COMPLETE, maybeLater);
so here goes the description of what i'm (trying) to make : i want to make a slideshow with AS 3, it will load external image which the location will be written in xml after it has load all the image it will play by itself and change beetwen image with transition.. well i manage to : read the xml, load the picture one by one and convert it into a bitmap tipeafter convert it to a bitmap tipe data i save it into an arrayafter all the image has been laoded , converted into bitmap and saved into array to display the image itself i first add the the image which has been save into the array to the container that i specially made to hold this (well actually because transition manager can only have effect on MovieClip).
myMCContainer.addChild(myImageArray[imageIndex]); that's how i display it (of course i have added "myMCContainer to the stage").
well the real problem is when i tried to use remove child fo myMCContainer it give me error #2025, and when i tried to check number of child that myMCContainer has it returned 0 even after adding the image...
I have 4 separate photogalleries, they are all swfs called by buttons with UI loaders attached. The problem is when one is called the loader remains on the stage I need to be able to remove any loader on stage BEFORE calling another page weather its a photogallery or not.Easiest explanation is how I used to do it in AS2 example 2 btns /2 load separate swfs into level1 on each btn I would have
unLoadMovie(1) LoadMovie (xxx.swf) 1
I need to do the same thing in AS3 Also, do I need to use separate loaders or can I use one loader and instance names? Below is the code I have now (btns are in two areas)
main timeline btns (all btns except photogallaries) stop(); home_btn.addEventListener(MouseEvent.CLICK, onHomeClick);
To give a brief background of what's going on here. I am building a personal site where I have a navigation, and I have other subnavs inside of certain pages. Such as if I go to "work" inside of work i have "motion", "web" & "print".
I'm having a problem with remove child in certain areas.. One would be when I load one page from the navigation then go to the "WORK" link, work won't show. Also..when I remove a movieclip elsewhere(this is under the same circumstance) then click on a link it does not remove that movieclip that is loaded again.
For example, click personal, click a thumbnail,(this adds workpersonalss_mc) then click back(this removes work personalss_mc then adds workpersonal_mc back), the click a navigation button it still remains..
I'm having trouble removing a child that I have spawned from an array. If I try to use the same for each loop that I use to address the children in the array in other functions, it removes all children that are in the array, but if I try to remove only that child, it complains the child is null. The clickListener function is working out if the crosshairs are on the cow when the mouse clicks, but I want to wait two seconds (to allow the death animation to play in the clicked cow) before removing the child.
I am trying to have a single parent class that a wide variety of classes can extend. Each of them has the exact same event listeners and remove function so I thought I would try to write the function a single time in the parent class.Parent Class:
Code: public function removeMe():void { /* REMOVE EVENT LISTENERS */
"TypeError: Error #2007: Parameter child must be non-null. at flash.display:isplayObjectContainer/addChild() at newLFXsite_fla::MainTimeline/onClick()"
so i get this error every time i click on the about page after the homepage appears on screen, from what i know im doing everything right, but i guess theres something wrong that i cant see.
I'm creating buttons like so: for (k=0; k<5; k++) { myLink = new LinkClass(); myLink.name = "link" + k; box.boxMC.linksMC.addChild(myLink); }
This creates 4 movieClips with the names "link0", "link1", etc. How do I remove them? I try this: box.boxMC.linksMC.removeChild(myLink); But it just removes the last one made (link3). How do I have all of them removed?
i just started learning flash. Anyways, I have a movieclip that is removed when i quit the game from the menu e.g. removeChild(character). When i press "start" on the menu, i would like the character to re-appear. How can i add him again ONLY if he's been deleted?
I have an image map with hotspots that animate when clicked and bring up info onto the stage. My problem today is how to stop the animation and remove the info on one button when a second button is clicked. The info is intended to appear in a space to the side of the image map.MY code works apart from it throws up an error when user clicks on the hotspot.[coder]I'm pretty sure that there is a more elegant way of doing this, particularly as there will be ten buttons overall.[Code].....
I'm trying to build a small game to try and get into ActionScript. This is my first real attempt at ActionScript.Currently I have an Enemy superclass and an Enemy_One class that extends that superclass.When an enemy has moved off screen I want to remove it from the frame. Here's the errors I'm getting:
Code: TypeError: Error #1009: Cannot access a property or method of a null object reference. at Enemy/checkHitPlayer() at Enemy/loop() Enemy.as
I understand that the major difference between AS2 and AS3 is that in AS3 you have to put all your script in a separate layer, and unlike AS2 you can't add them to buttons or movie clips themselves on their respective layers.
I'm doing a project for school where I'm required to make a flash portfolio.
I have Five buttons, and right now, two of those buttons goes to a frame to display a picture. However, I've made the other buttons dynamic, and they call other swf files to show an image gallery, a game and another image viewer.
What I have a problem with is when I click the first dynamic button, and the swf if added to the parent movie clip, it does not leave the stage when another dynamic button is clicked.
So what I have is all the SWFs loaded on top of each other.
writing a code that will remove child for each button when ANY other button is clicked.
here is the code I have:
stop(); btn3.addEventListener(MouseEvent.CLICK, buttonClick); function buttonClick(event:MouseEvent):void{ gotoAndStop(3);
I'm having a problem with removeChild(x) not completing purging the object. I run an if statement to see if the object is null before creating a new one, once I create it the first time it is never null even after I removeChild(x) so the if statement fails.Note: There aren't any external EventListeners in the shop to removethis seems like a simple fix and is driving me up a wall In the parent I start off with a placeholder:
I have two classes, one called car, one called game. When the user drives a car off the map, i wish to remove the car from the map, do some fiddling with vars (lifes etc) and then re-add the child.But i get the following error #1009: Cannot access a property or method of a null object reference.. I think it is because the car class is still trying to control the car even though it is being removed.
Car Class
Code: package { // IMPORT ANY CLASSES OR LIBRARIES import flash.display.MovieClip;