ActionScript 3.0 :: Coding Hierarchy And Removing Child?
Jan 26, 2010
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..
[Code]...
View 0 Replies
Similar Posts:
Jan 20, 2010
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".Here is some example code of one button on the navigation:
nav_mc.personalbtn_mc.addEventListener(MouseEvent.CLICK, buttonClick2);
function buttonClick2(event:MouseEvent):void {
gotoAndStop("personal");[code]...
It seems to me that actionscript will not read all the way down to the bottom when looking for objects.For example: The first if statement where it's asking if workss_mc exists or not, that will work if it's at the top, but if I move it down to the bottom it will not work.
View 33 Replies
Jun 6, 2011
i am slightly confused about the parent and child relationship. lets assume we have several different instances, what would be difference of adding them all as children of the stage and creating a parent-child hierarchy between them(other than the access path).
View 5 Replies
Jan 19, 2011
I have a class linked with a movie clip, and in this movie clip I want to be able to add an event listener that calls a function in the Document class (the class you link with the fla as a whole). How can I do that? Say the name of my document class is KPScript.as. In my GameController.as class, I want to listen for key input and call pageChange() in KPScript.as when it gets called. Would I have to import KPScript.as into the GameController.as? If so, I wouldn't want to create another instance of the KPScript object.
View 1 Replies
May 24, 2011
I have a generic function to build rows of controls (each row comprising of sliders, radio buttons, reset buttons, text display) etc, and some functionality to change underlying data based on these
As I didn't want to write specific code for each row, I had code written by which I can detect the row on which there has been a mouseevent, and though the row access each individual control
[Code]...
View 2 Replies
May 12, 2010
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:
Code:
import fl.transitions.Tween;
import fl.transitions.easing.*;
[code]........
View 2 Replies
Aug 4, 2009
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{
[code]....
View 1 Replies
Feb 2, 2009
Im using the following code to create a mc from a template iv made stored in the library:
var galleryThumbs:MovieClip = new contentTemplate();
galleryThumbs.x = 710;
galleryThumbs.name = "galleryThumbs";[code].........
that all works fine but then im trying to remove it with this, with no success:
if (galleryBox){
removeChild(galleryThumbs);
}
View 6 Replies
Aug 10, 2011
Here it is:
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..
View 3 Replies
Feb 8, 2010
I'm trying to remove an instance by name, that was previously captured when it was created. (in a property)
ActionScript Code:
trace(this._blockInstance); //returns instance name, eg "instance203"
But when i try to combine that with the removeChild method, it don't work.
ActionScript Code:
this.removeChild(getChildByName(this._blockInstance));
error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Board/boardBlockClick()
View 7 Replies
Jan 8, 2012
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();
[code].....
View 4 Replies
Oct 6, 2010
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.
View 1 Replies
Jan 26, 2009
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.
View 1 Replies
Oct 2, 2009
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.
View 0 Replies
Nov 11, 2010
When I put in this code
ActionScript Code:
stage.removeChild(dementorBlack);
it doesnt work as it says it cannot find dementorBlack basically.Here's my .as file where all this is going on.
ActionScript Code:
//the directory structure to this file
package [code].....
View 3 Replies
Nov 28, 2010
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;
[code]....
View 5 Replies
Jan 2, 2012
I have a main_mc that loads and external xml slideshow on frame 1 via this code:
ActionScript Code:
stop();
import fl.transitions.Tween;
import fl.transitions.easing.*;
[Code].....
View 5 Replies
Jul 24, 2009
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);
[Code].....
View 5 Replies
Aug 12, 2009
I'm having a problem removing a child from the stage that is added dynamically. Shouldn't this work...
[Code]....
View 3 Replies
Feb 2, 2011
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...
[Code]...
View 5 Replies
Oct 5, 2009
I got a Homepage set up and I have a Contact Form on Frame 55 of my main movie clip.The form is created on runtime using AS with the following code:
ActionScript Code:
import com.warmforestflash.ContactForm;
var contactForm:ContactForm = new ContactForm();
[code].....
View 1 Replies
Nov 9, 2009
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);
[code]....
View 0 Replies
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.
View 1 Replies
Mar 11, 2010
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.
Here's what I'm doing:
Code:
package {
import flash.display.MovieClip;
import flash.utils.Timer;
import flash.events.*;
import flash.ui.Mouse;
[Code] .....
It's the removeChild(cow) line that throws the "null" error.
View 1 Replies
May 1, 2010
I'm moving two objects accross the stage at different rates using the same function:
Code:
function moveClip(clip,speed){
clip.addEventListener(Event.ENTER_FRAME,moveIt);
function moveIt(event:Event) {
[Code]....
In AS2 I'd just use dot notation as above and it would work from anywhere or perhaps _root.red....
I've tried root. stage. childbyname Not sure where to from here.
View 2 Replies
Apr 2, 2012
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 */
[code].....
View 6 Replies
Jul 21, 2009
"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.
[Code]...
View 2 Replies
Dec 8, 2011
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?
View 2 Replies
Mar 31, 2011
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?
View 6 Replies
Jan 13, 2010
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].....
View 1 Replies