ActionScript 3.0 :: RemoveChild From Inside A Class?

May 3, 2011

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[code]....
...
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:[code]...

View 6 Replies


Similar Posts:


ActionScript 3.0 :: _Deleting_ A Movieclip From Inside Its Own Class (not Using RemoveChild)?

Mar 7, 2009

I have started learning AS3 after a long stint doing work on AS2, and to test my abilities, I decided to make a quick breakout game. It has gone fine so far until I get to the part where I need to remove the bricks when they are hit. My current code for the class of a Brick is attached, and is started when a Brick is minstantiated on the Stage. However, when I use:

parent.removeChild(this);

it makes the Brick invisible but the AS3 code still runs and the ball bounces off where the moveiclip of the Brick used to be; the eventListener for ENTER_FRAME I added still runs even though I have deleted the MovieClip. This doesn't work either:

this = null;

I have to say I don't like the whole Garbage Collection idea of AS3; it seems half-hearted and uncontrollable; being a .NET developer I am used to more control than this. What was wrong with "this.removeMovieClip();" and how can I correct this? My current swf: http:[url]....(there are other things wrong, like bad collision detection,

View 3 Replies

ActionScript 3.0 :: Removechild Inside A Movieclip

Jul 24, 2009

I have a flash button that once clicked that adds an existing movie clip in my library to the stage. Basically what I am trying to achieve is like a popup window in flash so it opens a movieclip and then I have a close button inside the movieclip. Now what I want to achieve is to close the movieclip once I've added it to the stage.I'm trying to use the removechild but I'm getting errors e.g. The supplied DisplayObject must be a child of the caller.at flash.display::DisplayObjectContainer/removeChild()The way I add the movieclip to the stage is by using the following code:[code]

View 4 Replies

ActionScript 3.0 :: RemoveChild Inside A Loaded SWF?

Jan 7, 2011

there how can i use removeChild inside a SWF that i added in my timeline i mean ive got my swf i addChild it and inside the second SWF is a close button which i want to removeChild itself :S is there anyway to do that?:S

[Code]...

View 0 Replies

ActionScript 3.0 :: Parent.removeChild Inside Construstor?

Sep 3, 2009

I have recently experienced problems with attempt to remove DisplayObjects that were placed at design time.I have some class "Locator" inherited from Sprite. Several instances of it are placed at the stage at design time.Locator constructor fills parent variables and tries to remove the instance itself from parent:

ActionScript Code:
public function Locator()
{
// give parent some important data

[code]....

All instances now process constructor, but only one of them processes event handler.

View 9 Replies

ActionScript 3.0 :: Class Running After RemoveChild?

Feb 28, 2010

I have an external class added to the document when a menu is opened. When the menu is closed the function is removed.
 
But then the document tries to run onEnter function of the class, which references stage and I get the null error. How should I set it up so the document doesn't run the class after removeChild()?

[Code]....

View 5 Replies

ActionScript 3.0 :: Tween Then RemoveChild Class Questions?

Jul 10, 2009

I wanted to create a class that you send a display object to and it tweens out (lets just say fades out for now), and then removes it from it's parent, and nulls it. So this is what I came up with:

Code:
package com.TweenOut{
import flash.display.DisplayObject;
import flash.display.DisplayObjectContainer;

[code]...

but, i'm getting this error.. TypeError: Error #1034: Type Coercion failed: cannot convert com.Pages:esignPage@2786f9d1 to com.TweenOut.TweenKill.So, obviously it can't convert _livePage.. but.. am I misunderstanding the error, is it trying to convert it to com.TweenOut.TweenKill, or is it just not able to convert it to a DisplayObject like I assume??

Also, I should note that _livePage is a subclass of a custom class I wrote, and that class is a subclass of MovieClip.. Doesn't that mean that _livePage would be a DisplayObject? Does this have to do with calling the super() in either of those super classes?

I'm making great headway into understanding all of this as3 stuff, but some things still get me. I'm having trouble understanding the big picture, I feel like there has to be a better way to handle "page changes" or "section changes". For instance, am I doing it a weird way by making a class that tweens out anything I send to it? Should I just be doing the tween and removal inside the class that the DisplayObject is a child of?

View 6 Replies

ActionScript 3.0 :: RemoveChild When Child Is Type Class

Jul 23, 2009

I'm working on a game where I'm adding a symbol (an enemy unit) from the Library via addChild() to an instance on the Stage. The symbol has Linkage/Class enabled so I can stick stat variables directly on it for easy access.The problem is that I want to use the same name for enemies (like en0, en1) in different areas, but if I try to removeChild(), I get Error 1067: Implicit coercion of type Class to type DisplayObject.

View 1 Replies

ActionScript 3.0 :: Introduce Code In The Original Class That Mentions RemoveChild()?

Jan 9, 2010

I ave created my first class Ellipse, which I am using to make a simple drawing app. This is simply an excercise so I can understand the Proces of writing more complex ode.Everything was going well but I cannot erase what I produce on the stage. I created a box_mc as a way to contain the drawing but only the box_mc is removed not the drawing, which I thought was inside. I have tried changing the class and Base Class in the properties but that did not work.I'm attaching the code bot Class.as and the fla file as they stand now so maybe someone can point me in the right direction.I was wondering if I need to introduce code in the original Class that mentions removeChild();

View 13 Replies

Actionscript 3 :: Error #1006 RemoveChild Is Not A Function. Timer Delay RemoveChild

Mar 29, 2010

I'm trying to build a conditional statement that will addChild and removeChild at different Timer Delays. Before I go any further, I thought, I should mention that I'm usinig TweenMax to ease the alpha of ease Child from 1 to 0 and back during the process to imitate a fade-in/out.

I'm getting issue with only one line - inside a conditional statement.It's running "OK". The movie runs as I want it, but the remove/addChild transitions are not at the speed I want it at. I am getting an error message in the output, but other than that, the movie runs fine.

stop();
import com.greensock.*;
import com.greensock.easing.*;
import com.greensock.plugins.*;

[code]....

View 2 Replies

ActionScript 3.0 :: Calling A Function From An Extended Class Inside A Top Level Class

Sep 23, 2009

package{
public class Character{
protected var _hp:uint = 50; //Character Health Points
protected var _power:uint = 5; //Damage dealt

[Code].....

I`m instancing a Character and a Player in the Main Timeline, all in frame 1.
When I use: ""player.attack(character)"" it works fine by itself.

So I added the if (defender._hp <= 0) this.win() which gives me the following error:

1061: Call to a possibly undefined method win through a reference with static type Character.

"defender" is a Character instance, "this" is a Player instance and "win()" is a Player method. I try to call the Player method inside a Character method using the Player instance adding the "." and his method name

Do I really need to define the win() function in the Character class? Is there a bypass to use a subclass method in a parent class method if it`s called from an instance of the subclass?

View 6 Replies

ActionScript 3.0 :: Referencing A Textfield Inside A Movieclip Class From Document Class

Feb 3, 2009

Ok, this is one of those walls that I know once I can jump over it, I will be a much happier developer again.

I've done tons of reading, and think I have a firm understanding that the general consensus is that if you want to reference something, it needs to be added to the display list, using addChild().

I hate to be defiant, but what if I don't want to?

Or at the very least, what if I want to add a movieclip class to the stage using addChild, and then reference objects inside it?

It is much easier this way than what most people recommend - adding 15 objects via addChild, then setting the x and y for the, etc.

That said, I'm all about using classes and using as3 the way it was meant to be used. So what this is, is a best practices question I guess.

HERE ARE THE STEPS I'M TRYING:

- Create new flash document

- Draw graphic symbol bg, with text field over it, select them, convert to movieclip symbol, and export class name "box", then delete it from stage

- Add document class .as file, which simply adds that class "box" from the library, to the display list using a simple addChild()

- Set a name for that box using box.name = "test" let's say

- Do a simple trace like the following - "getChildByName('test').textFieldName" - it shows up great

- So then, I'll now try to set the text by doing this - getChildByName('test').textFieldName.text = "yo";

That last line above, is what doesn't work. I know I'm referencing wrong, but how would a pro as3 developer, reference something on the stage within a movieclip class, from the document class?

View 1 Replies

ActionScript 3.0 :: Moving A Child From A Class To A Holder Sprite Inside That Class?

Feb 12, 2009

i have a BasicMap.as that takes an Array and populates itself with the MC objects passed to it by a String reference.it inherits from Sprite, and so it just places the objects on its self.then i have a class that inherits from that class, and gives a little more functionality to it, but in order for it to do that, it needs to place the objects not on itself, but instead inside a holder Sprite, so here is my problem:

code:
package Mushroom{
import flash.display.Sprite;

[code]......

View 8 Replies

ActionScript 2.0 :: SetInterval With A Class - Function Doesn't Work Inside Class ?

Oct 7, 2004

I was wondering why my current code for calling a setInterval on a function doesn't work inside my class.I have this code inside one function, calling a second function.

intID = setInterval(selfReferential, dupe, 30, 0x000000);

The selfReferential keyword refers to the current class,but was defined previously (selfReferential = this; ).I get no errors, but the dupe() function is never called.and I had the selfReferential variable replaced with the this keyword at one point as well.

View 5 Replies

ActionScript 2.0 :: Make Class Instances Into Listeners And Broadcasters From Inside Each Class?

Jul 8, 2007

I want to know how to make class instances into listeners and broadcasters, from inside each class. Here is what I am trying specifically... part of the Proj class... (projectiles, as a matter of fact)

Code:
private function listen():Void {
u.register(this);
onUpdate = function(){
step(); // a function I have which makes the projectile move (not shown)
}
}

where "u" is another class, the Updater class with this code...

Code:
class Updater {
// const. --- make this a broadcaster
public function Updater(){

[code]....

PS: What is the syntax for using AS2 code tags instead of just "[CODE|"?

View 2 Replies

ActionScript 2.0 :: Instantiating Character Class Inside Of Game Class

Feb 18, 2007

I am having a problem instantiating a Character class inside of a game class.I am working on converting URL...l these tutorials to A.S. 2.0.[code]

View 2 Replies

ActionScript 3.0 :: Dynamically Create Class Inside A Class?

Apr 19, 2010

This is what i'm trying to do :

I have 1 class that extends movieclip, let's call it Class0. I have 1 class that extends movieclip, let's call it Class1.

I create an instance of Class0 on stage like : var myClip0:Class0 = new Class0(this, "Class1");

The class Class0 when initializing, will create a new movieclip (myClip1) and add it as child, as an instance of Class1, like myClip0.myClip1. But it's when i create that clip, i want to tell it, it's an instance of Class1, like :

private var myClip1:Class1 = new Class1(this);

Where Class1 could be any class.

How do i pass Class1 to Class0 so it can create it dynamically?? Do i have to use the apply function??

inside Class0, i have a function that does :

Code:
if(subClass){
initSubclass(subClass);
}

[Code].....

View 8 Replies

ActionScript 3.0 :: Class Instantiation Inside Class?

Dec 24, 2009

Performance wise, is it better to instantiate inside or outside the constructor?

Code:
public class example {
private var _mc:MovieClip = new Movieclip();

[code]......

View 4 Replies

ActionScript 3.0 :: RemoveChild(); RemoveChild()?

Feb 21, 2009

I cant do 2 removeChild(); 's beneath eachotherSo their always will remain 1 child how can i delete that one?

addChild
removehild does work
removeChild

[code]......

View 2 Replies

How To Get Preloader To Work Inside Class

Nov 6, 2009

I am very new to flash and on the net I've found a class that allows me to use a nice scroll bar for the content. My problem is that I can't get a preloader working with the class. When I want to add scrips to the frames it bugs the class if I try to implement the preloader inside the class I can't get it working. Here's the class I am using for the scroll bar. - if you want to test it, it will require additional data. You can get it all here: [URL].

package{
import flash.display.*;
import flash.text.*;
import flash.events.*;
import gs.TweenLite;
import com.warmforestflash.ui.FullScreenScrollBar;
public class Main extends Sprite{
[Code] .....

If I try to insert the preloader script inside the class it has problems with the stop(); & play(); commands. Any way to get a preferably simple preloader working with the class I am using?

View 1 Replies

ActionScript 1/2 :: Using GetURL() Inside A Class?

Feb 27, 2007

i've defined a class and inside that within a function i''m calling the getURL function and passing the variables using the POST method.but while compiling the compiler throws and error of There is no property with the name 'POST'when i try to assign ths "POST" to a string variable and pass that variable to the getURL function i'm getting an error of only "POST" or "GET" method is allowed.

View 8 Replies

ActionScript 3.0 :: GotoAndStop From Inside A Class?

May 11, 2011

I have a problem running gotoAndStop from insida a class (.as). I have a class called deathScreen, when you click a button which i made it will go to another frame. This is what i have:
 
package classes
{
import flash.display.MovieClip;
import classes.dummyCamera;

[Code]....
 
When i run this i get an error saying: TypeError: Error #1009: Cannot access a property or method of a null object reference. at Function/<anonymous>() The object is created dynamiccly in the code (precisly when the player dies, this object is placed on the stage)

View 2 Replies

ActionScript 3.0 :: Can't Use This Class Inside My MovieClip

Nov 21, 2011

The attached SlideshowExample.as file works quite nice when I use it on stage directly. But when I tried to use it in Gallery_mc movie clip, it doesn't work

View 3 Replies

ActionScript 2.0 :: Arrays Inside A Class?

Feb 3, 2009

I have a private class variable that is an array. I have the getters and setters like I would for any other variable. When I push something on to the array from outside of the class using the instancename.arrayname.push() it pushes it onto all of the arrays of all instances of that object like it is a static variable or something.

View 2 Replies

ActionScript 3.0 :: Difference Between Using 'this' Inside Class And Not Using It

Dec 24, 2009

i am not very clear what is the difference if you are using this and if you are not.[code]In php you have to use $this to access class properties. But in actionscript you don't.In AS you can trace testVar using this or without it like this:[code]

View 3 Replies

ActionScript 2.0 :: LoadVars Inside Class ?

Feb 18, 2004

How can I use LoadVars inside a class?I mean, if I assign the method name to onLoad of LoadVars, the method will be override, and will not pertence to my class.look this:

[AS]
class myClass{
var lv:LoadVars;[code]...

this at onLoad function points to loadVars not to myClass.the only solution I found to this was to myClass extends LoadVars, but it limit me since AS 2 does not support multiple-Inheritance.I think I will face the same problem with all others components that does not has addEventListener capabilitie.

View 3 Replies

ActionScript 2.0 :: Getting XML Content Inside A Class

Nov 8, 2005

Take a look at these example:

Code:
function loadMap():Void {
varxdata:XML = new XML();
xdata.ignoreWhite = true;

[Code]....

Now, im creating a local variable var var_temp:String; cause, there is no way that i can pass the values, inside the onLoad handler to a property of the class.

If i try some this.some_var its reference to escope inside the onLoad handler..

View 2 Replies

ActionScript 2.0 :: Using XML Inside Of A Class File?

Nov 24, 2006

I have created a class file with 2 functions one to load an xml file and the other to parse the file and push the values into an array. My problem is that I can't access this array inside another function unless pass the array as a parameter or the main timeline. Below is the class file I'm using:

Code:
import mx.utils.Delegate;
class XmlTest
{

[Code]....

What I would like to do is pass the array to another function in the class file. This function would loop through the array and push certain values into an array that would be returned to the main timeline so I can using them.

View 4 Replies

ActionScript 2.0 :: Key Events Inside Class

Feb 19, 2007

I am curious in what strategies people are using (if they are using) the Key events inside of their classes. I am trying to build up a character class and I wanted to encapsulate the movement inside of the class.

View 3 Replies

ActionScript 2.0 :: How To Use LoadVars Inside Class

Feb 18, 2004

I mean, if I assign the method name to onLoad of LoadVars, the method will be override, and will not pertinence to my class.

[AS]
class myClass{
var lv:LoadVars;
function myClass(){
lv = new LoadVars();
lv.onLoad = onLoad;
} function onLoad(sucess:Boolean):Void{
trace(this);
} function trigger(){
lv.sendAndLoad("testeURL",lv,"POST");
}}

This at onLoad function points to loadVars not to myClass. The only solution I found to this was to myClass extends LoadVars, but it limit me since AS 2 does not support multiple-Inheritance. I think the same problem with all others components that does not has addEventListener capabilities.

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved