ActionScript 3.0 :: Remove A MC From The Stage From Within Its Own Class?
Aug 3, 2009
I am trying to remove a MC from the stage from within its own class and trying to keep it so no matter what that MCs object is called it will work. I am using this and it seems to work, but wondering if there is another/better way to do this?
parent.removeChild(this);
View 1 Replies
Similar Posts:
Jul 17, 2009
I am using a component in my application, but it turns out, it's slowing my app down big time b/c it doesnt remove an eventListener on stage for mouse move. Is there a way I can remove this listener? I can't get into the class b/c it's a component and it doesnt have any sort of kill function to call.
View 15 Replies
Dec 20, 2009
I'm making a game for children where they have to pay money by dragging it on a square. It al works wel only when i pick the first coin of one euro without going over the coin of 2 euro and then pick up a 2 euro coin the one euro disappears. after then it all works fine.i cant remove my duplicate euro's from the stage when i clic on pay here is my code for the euro's the euro's are in a emty movieclip
[code]...
View 2 Replies
May 3, 2010
I have a class called shapeC that only creates a rectangle and then addChild(rectangle);. That class is instantiated on the main timeline. Currently, the only way you can see that rectangle is to add the instantiated class to the stage via addChild(shapeC);. My question is, is there a way that the shapeC class can add the rectangle to the root stage without requireing the instantiated class to be added to the stage?
View 4 Replies
Nov 8, 2009
I have question regarding removing instantiated objects. Let's say i have a main class in which i instantiate a custom video player (or whatever) class:
[Code]...
From my experience, if i don't destroy for example event listeners from my VideoPlayer class and just remove VideoPlayer class the way described they still get fired with null exception messages etc. This is something that's bugging me for a while so i would really like to know what's best thing to do here?
View 1 Replies
Jul 1, 2010
can you tell me a simple and clean way to pass the dimension of the stage to another class, imported in my documentclass?
View 2 Replies
Apr 19, 2010
On the click of a button I am having a movie clip load onto the stage from the library using the _root.attachMovieClip command and that part of my code is working perfectly.I have a close button embeded into the movieclip being loaded in but I am unable to get it to remove the movieclip from the stage when the close button is clicked. The close button has to be inside the loading movie clip so it doesn't interfere with other items on the stage which is why i'm not using _visible to show and hide the menu.
View 2 Replies
Aug 24, 2009
I'm trying to remove a swf from the stage when a button is clicked to go to the next frame.
Below is my code for loading the swf and know I need to use the removeChild function to do it but don't know what to target.
loadme();
function loadme():void
{
var l:Loader = new Loader();
[Code].....
View 7 Replies
May 23, 2011
im trying to remove these movie clips from the stage but its not working. Im spawning the movie clip to the stage every time i slide the timeline_slider, which is instance name for a slider component.
I manage to put the spawned movie clip in a array using push, but i don't know how to delete them. Because what i want to happen is that every time i slide the slider i only want a certain amount of movie clips on the stage, but what is happening is they spawn on the stage and stay there.
for example. if i slide 1 across it spawns 5 mc if i slide again to the second increment it spawn 4 so total number on movie clips on the stage is 9.
i want to only spawn the number of movie clips that increment on the slider is set to. i would also like it to work backwards as well, so if im on the second increment it should have 4 movie clips on the stage, and if i go back to the first increment i should only have 5 movie clips on the stage. this is my code for spawning with the slider
this is my arrays of the numbers are now many movie clips i want to spawn to the stage.
Code:
var rdCounts:Array = [5516 / 1000,5517 / 1000,5570 / 1000,5585 / 1000,5596 / 1000,5656 / 1000,5804 / 1000,5965 / 1000,8692 / 1000,15194 / 1000,16475 / 1000];
var NewAuspop:Array= new Array();
[Code].....
View 1 Replies
Jul 10, 2011
If i have a MC on stage called 'mc' why will this not work[code]...
what do i need to remove this from stage?
View 7 Replies
Jul 16, 2009
I'm slightly new to Flash CS3 + AS3 combo, so its more of a lack of practice question. My question stems from the problem described here http:[url].... . Note, its not the same problem, its a new one.The Problem ,So I have multiple library assets (which are on teh stage) and I want to assign similar functionality to all of them.
Attempt 1: So I create the n assets, create a custom class in AS3, link them to Flash CS3 and obviously enough it gives me the error that multiple assets can't be linked to the same class.Obvious enough to understand (well not completely, because from a programmers background it doesn't make sense).
Attempt 2: Same as attempt 1, but instead of linking all the assets to the same class I make the base class the same class, and let the derived class be dynamically created by Flash on compile time.So the linking works, but the problem is, in my base class I have a method which does something (say an tween) on a child of the library asset. So if the assets on the stage/library are called asset1, asset2, asset3 (same name for asset name, class name, id name), each of them has a sub-movieclip called ... say 'foo'. now if I manually wrote a class for each asset, I could do 'this.foo' to play with the sub-movieclip. However since this functionality is in the parent class, I'm unable to do it.
P.S. If you're form a programming/OOP background, its basically a abstract class problem. My Base class knows how to doSomething(), but it needs aSomething, which is defined in the Derived classes. However I found out that AS3 classes don't support virtual(C++ )/abstract (Java) in the true sense of the word (unless I missed some obvious documentation).
View 3 Replies
Dec 7, 2009
Is there a way I can reference a Movie clip I have on the main stage from a custom class of a document class?[code]
View 1 Replies
Oct 14, 2011
I need to use stage.width/height in my CustomClass so I found some topics about it.
if (stage)
{
init(ar,firma,kontakt,oferta,naglowek,tekst,dane);
[code]......
View 1 Replies
Mar 7, 2012
How to access a display object on the stage in a class which is not a document class?
I am looking for a solution that doesn't involve passing the stage as a parameter to the class.
One solution i always come across is using "TopLevel.as". Is it a good method because as far as I have heard using global variables is not recommended because it might cause some problems while working on big projects.
View 1 Replies
Jul 2, 2009
I was wondering how do you access the stage property from a different class that's not the principal class tied to the fla? Essentially, I have main.as which calls another class menu.as, and I can't seem to be able to use the stage.stageWidth property from menu.as. What's the proper way to be able to use the stage property from any class? Do I have to import it separately each time?
View 2 Replies
Dec 8, 2009
Is there a way to refer to a Movieclip on the stage from a class file of the document class
Lets say I have 3 MovieClips on the stage(a Circle, a Square and a Triangle)
I have the document class which calls another class that controls the MC on the stage
Example
ActionScript Code:
package {
public class Example extends Sprite {
//Create the instance of the class being called
[Code]....
View 1 Replies
Jan 6, 2011
I have created a class, call it Class1, that has various objects drawn on the stage (drawn in the IDE). It also has a function, called setColour, for changing the colour of those objects. The function works fine if I call it from within Class1.
Now I have another class, call it testClass1, that imports Class1 and calls the setColour function. First of all, none of the stage objects from Class1 are visible. Secondly, when setColour tries to modify the colour of an object, I get the error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
This is the code for testClass1:
ActionScript Code:
package
{
import flash.display.*;
[Code].....
So, what is the problem? Is it possible to change objects that are drawn on the stage of an imported class?
View 3 Replies
Sep 9, 2009
I have a scrollbar that attaches to a movieclip that I want to appear only on one page of my website.When I navitgate to another page, the scrollbar is still there.I would like it only to appear on one page and need either a button event or frame event to remove it when I navigate away from the page.[code]...
View 11 Replies
Jul 30, 2010
So I have a 5 page website, on the home page when I opens you see a video and it automatically plays. When you click to a different page though you can still hear the sound in the background. The video has an instance name of video, I tried using video.stop(); in the code for each button and it works but then it doesn't allow me to navigate when it isn't away from the home page.[code]...
View 2 Replies
Mar 21, 2011
This is my code for playing an .flv video: I am using this code to play a video when a user clicks on a button:
function clicked(event:MouseEvent):void {
var video:Video = new Video();
addChild(video);
var nc:NetConnection = new NetConnection();
nc.connect(null);
[Code] .....
When I got to frame 2 the last frame of the video is still there.... How can I remove the video when the video has finished and gone to frame 2?
View 3 Replies
May 22, 2011
hey, im trying to remove these movie clips from the stage but its not working. Im spawning the movie clip to the stage every time i slide the timeline_slider, which is instance name for a slider component.I manage to put the spawned movie clip in a array using push, but i don't know how to delete them. Because what i want to happen is that every time i slide the slider i only want a certain amount of movie clips on the stage, but what is happening is they spawn on the stage and stay there.for example. if i slide 1 across it spawns 5 mc if i slide again to the second increment it spawn 4 so total number on movie clips on the stage is 9.i want to only spawn the number of movie clips that increment on the slider is set to. i would also like it to work backwards as well, so if im on the second increment it should have 4 movie clips on the stage,and if i go back to the first increment i should only have 5 movie clips on the stage.Even just hiding the movie clips and unhiding the movie clips is fine as well. this is my code for spawning with the slider this is my arrays of the numbers are now many movie clips i want to spawn to the stage.[code]
View 16 Replies
Dec 3, 2010
I am getting a little fustrated with trying to remove a MovieClip from my stage after I am done with it. On loading my frame, I have a little bit of code in a function that creates a piechart.
var piechart:MovieClip = new MovieClip();
stage.addChild(piechart);
//Then a bunch more to draw the pie chart
So that bit of code is NOT on my "Actions" layer. Now I have a button on this frame that navigates to a different frame in the timeline but when I change frames, the piechart remaines. So, how do I remove this piechart from the stage after I am done with it? I have tries stage.removeChild(...) and others but perhapse I am calling it wrong?
View 2 Replies
Apr 11, 2011
I created movie clips that I want to add to the stage (from the library) by the use of buttons. I have a total of six buttons (and six moviclips) but I am trying to get the first two to work before I move on to the next buttons. The problem is I can't seem to remove the movie clip when another button is clicked, or the same button... Like I said I am new at this and I think a created a mess of things... I am getting error 2007 now
import flash.events.MouseEvent;
import flash.display.MovieClip;
mix_btn.addEventListener(MouseEvent.CLICK, addbear);
[Code]....
View 3 Replies
Aug 17, 2011
I create multiple MC's with the following code:[code]Now i'd like to remove a bunch of them from the stage. Is there a way i can do this in AS3?
View 2 Replies
Feb 5, 2012
On the Stage i've a texfield named "text0", when i attempt to remove it throught AS3 writing removeChild(text0), flash give me an error(Error #2025). I always used this syntax for remove MovieClip symbols, why it seems not work for textfields?
View 5 Replies
Feb 16, 2012
It may sound stupid, but how can I remove a definite child from the stage?[code]...
View 5 Replies
Aug 4, 2009
is it possible for a movieclip to say that it wants to remove itself from the stage?i am dynamically adding a bullet (movieclip) to the stage for this "tank-type" game im making.. since it's a bullet, it obviously moves.... so, if the bullet's X position is beyond 550, i would like flash to remove it so that it doesn't take up memory...here is the class of the movieclip:
ActionScript Code:
package
{
[code]............
View 7 Replies
Feb 3, 2010
The normal procedure will be to call the parent to remove the child.
ActionScript Code:
stage.removeChild(temporary_movieclip);
or just
[Code].....
I am highly aware that this is a BAD practice in all logical sense, because the parent SHOULD be in charge of removing its childs because then it can set them to nil and remove all Event Listeners for the garbage collector.
Why iPhone ObjC allows that is beyond me.
Is there a way to get a movieclip to remove itself ?
View 8 Replies
May 5, 2010
I am trying to remove a swf that I import to the stage, but it is not working.
Code:
function btn_cima_3call(clickEvent:MouseEvent):void{
page = 5;
esconder();
content.gotoAndStop(page);
ld.load(new URLRequest("trabalhosV0.swf"));
ld.x = 0;
ld.y = 100;
addChild(ld);
}
So when 1 button is pressed this swf is imported to the stage. but im now trying to remove this when another button is pressed and it isnt working?
Code:
function btn1call(clickEvent:MouseEvent):void{
removeChild(ld);
page = 1;
content.gotoAndStop(page);}
View 0 Replies
Apr 1, 2011
If I add 10 clips like this[code]...
this just results in an error, what are the instance names of my 10 objects then?
View 2 Replies