Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Detect If MovieClip Is On Stage And Remove It



Folks, I need a simple way to detect if a movie clip is on the stage. The stage scales so, it cannot be done by set dims.

I'll click a button, it should check if a list of movie clips is on stage (only one will be at a time). If one in the list is on stage, a function will run that tweens it off while another function tweens in another.

So, question is: What is the easiest way to determine if a movieclip is on the stage?



FlashKit > Flash Help > Flash ActionScript
Posted on: 07-30-2008, 01:59 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

How To Detect A Movieclip Move Out Of The Stage?
How to detect a movieclip move out of the stage ? Just using the stage and movieclip properties instead of creating another movieclip or border..





























Edited: 08/22/2007 at 12:19:29 AM by lokat

How To Detect When A Movieclip Leaves The Stage Completely?
I have a dynamic text field that scrolls like movie credits. The autosize is set to true so that the field will conform to the content that loads into it.

I want to put in a function that clears the motion interval once the movieclip containing the dynamic textfield leaves the stage.

What's the easiest way to do it?

Remove Movieclip Form Stage Compeletly
I need to remove the moveclip from stage...

Remove A Movieclip Off The Stage When I Click A Button.
I dragged a movieclip onto the stage, gave it an instance name but want to know how to remove it when I click a button.


Code:
Startup.visible = false;
??

Remove BlurFilter On Stage OnUnload Movieclip
i have called movieclip and set stage filter to blurFilter and show that mc only.
now i want to fire event on closebutton of that mc to remove blurFilter applied on stage.

can anyone guide me how would i do that?

i am closing that MC on closebutton clip and i also want to remove blurFilter on that button onRelease.

please urgent help me.

[F8] Remove From Stage?
http://img373.imageshack.us/my.php?i...shootergo2.swf
(sorry for using such a bad site...the .fla is too big .


my game is far from done, but i want to iron out the bugs as i go...if you test the game...

1. wait for the bullets to reach 40
2. repeatedly keep pressing fire key for one ship (D or left arrow)so bullets
come out: - - - - - -

once one ship is destroyed the bullets continue to move...i want them to unload themselves once one ship is destroyed.

this would be easy if i had an extra frame, but the 'you win/you lose' and the 'play again' button are just invisible when the game loads and once the ship death animation starts to play the objects are made visible. all on one frame.
i have tried everything i can think of, but its got me no where.

Remove From Stage
i have this code that creates some items on stage

Code:
for (n=1; n<=_root.appetizer.total; n++) {
attachMovie("menuitem", n, n);
this[n]._y = (n-1)*60;
this[n].name = _root.appetizer[n].name;
this[n].description = _root.appetizer[n].description;
}
how can i remove those items?

Detect Mouse Off Stage
I have a movie clip button that fills the stage - therefore the problem I have is that when I mouse off the button, the movie clip does not trigger the rollOut event.

I have been told I can either some as3 script for this or javascript - I just have no idea how. Can anyone help me to write this code?

Thanks

Kit

Detect Mouse Off Stage
I have a movie clip button that fills the stage - therefore the problem I have is that when I mouse off the button, the movie clip does not trigger the rollOut event.

I have been told I can either some as3 script for this or javascript - I just have no idea how. Can anyone help me to write this code?

Thanks

Kit

Detect MouseUp Outside Stage..?
Hi everyone, I've really search alot to find an answer to this one, but couldn't find anything... The thing is, I've got a draggable MC (a scroller, to scroll content..), the user drags it to scroll up/down, then release, and it stops dragging...

The problem is if the user release outside the stage (in another frameset for example..) and comes back in the stage, Flash didn't detect the mouseUp, and keeps dragging....

I've tried to put a button on my stage border, to detect it.. No good... I tried to put another MC around my stage, and detect the cursor going over it (while going out of the stage, or when coming back in..) but it doesn't detect the hittest because it THINKS it's still dragging.... As soon, as I click somewhere, to trigger the mouseUp (even if it was already up) the hittest then works...

But it doesn't while I'm actually dragging, or when Flash thinks I'm still dragging (released outside stage...)

Any ideas on how to work around this...??? I've heard people talk about detecting the mouse movement outside the Flash with javascript... Any ideas on how to do that..? And if it is reliable...??

Many thanks...

Need To Detect When The Cursor Is Outside Of The Stage
I need to detect when the cursor is outside of the stage. I have tried hitTest() but this doesn't seem to work. Someone must have a good solution to this one.

Detect Stage Edge, Right?
I'm setting a full screen, non-scalable layout. All base layout will remain fixed in position and scale. Certain elements will enter stage right, essentially off-screen (out of browser view), regardless of the browser window size. I've read through how to full screen the movie and tile a background. What I haven't determined is how to position the hidden objects (movie clips) just off-screen when the user changes their browser window, thus altering the width dim of the movie.

How To Detect Mouseclick On Stage Only?
Greetings,

I have a couple of movieclips dynamically created and positioned on the stage. Each one has an onRelease-event attached to them like so:


Code:


for (var i = 1; i<10; i++) {
myMC['item' + i].onRelease = function() {
// custom Zoom-function here
}
}


I was wondering if there´s a way to detect mouse clicks on the Stage only, and if so reset the movieclips that have been pressed/activated? Looping through the movieclips is easy, but can´t for my life figure out how to do the mouseclick-detection. A stageListener of some kind perhaps?

Thanks in advance!

How Can I Remove Eventlistener From The Stage?
Hi,

I have a main swf file which loads another swf file.
From the loaded swf file I add a keyboard event listener to the stage.

When I remove the loaded SWF from the main file the keyboard event listener is still active on the stage.

How can I remove the event listener from the stage within the main swf file?

Thank you.

Bullet Off Stage - Remove
Hi,

I want to remove bullets when they go off stage.
MoveBullet is my function that animates the bullet.


Code:
if(e.target.x > stage.stageWidth){
e.target.removeListener(Event.ENTER_FRAME, moveBullet);
removeChild(MovieClip(e.target));
trace("out");
}
My error output:

TypeError: Error #1006: removeListener is not a function.
at shooting_fla::MainTimeline/moveBullet()


if I comment away the "removeListener line" I get the following error:

ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display:isplayObjectContainer/removeChild()
at shooting_fla::MainTimeline/moveBullet()


What could be the problem?

/S-fish

Dynamically Remove A Mc On The Stage?
I'm embarrassed even asking this, but I'm blanking out.

What is the trick to dynamically remove a MC that is physically on the stage at design time? If I remember right I have to swap it into a certain depth or something?

Getting A Loaded MC To Remove Itself From Stage?
Hi

I'm creating an image gallery. I've got thumbnails at the bottom of the movie, which when clicked load the image into a loader ('imgLoader') above the thumbnails. I've then created a button on top of 'imgLoader' that loads up an external swf (containing a larger version of the image) into a new loader 'bigLoader' in front of the whole movie. This swf then contains a 'close' button that I want to use to remove 'bigLoader' from the stage so that is returns the user to the gallery.

Here's the code for the loaded swf:


ActionScript Code:
close_btn.addEventListener(MouseEvent.CLICK, closeClick);

function closeClick(myevent:Event):void {
    stage.removeChild(bigLoader);
}

But when I export this, I get an error saying:

"1120: Access of undefined property bigLoader.

So, I understand the error - flash cannot find bigLoader because it is in the main movie & not the external swf (where the above code is), so I just wondered if anyone knew of a way for the movie in the loader to remove itself from the stage? If the call to remove it comes from within itself?

Many thanks in advance.

Best Way To Put A MC From Library Onto Stage And Then Remove It?
I've seen a number of variations, many that end up with a problem of removeChild(movie) not getting rid of the movie.

So what is the best solution? I've just started to switch from AS2 to AS3 and I'm totally lost!

Remove A Clip From The Stage
Hello, how do i remove a movie clip from the stage that is on the stage from authoring? i know removeMovieClip works for attached or created clips... but not clips that are already on the stage.

thanks!

How To Remove Carousel From Stage?
i want to put 2 buttons on the stage, one for attaching the carousel (from tutorial) and one for deleting it.

all i can manage to remove is the tooltips!

i know its easy but i cant seem to manage it

any suggestions?


thanks

cressa

Detect Mouse Outside Of Stage Area
For a Flash navigation bar to be built into an HTML page, I've created a submenu system that appears on rollOver and disappears on rollOut. Problem is: Flash is not detecting the rollOut when the mouse is moved outside of the stage area (or out of the SWF and into the HTML area that surrounds it). How can I detect mousing out of the SWF and tell my menu to close?

I've tried each of the following, with incomplete success:
1. a mouseListener checking for the mouse position within stage,
2. a simple action loop checking for the mouse position within stage,
3. attaching an invisible MC to the cursor, then using hitTest to detect when it is not overlapping with a stage-sized MC,
and
4.
stageSized_mc.onRollOut= function (){
closeMenu();

This site does it wrong -- the menu stays open when the mouse has rolled out of the nav bar area. Can you help me do it right? Thanks...

Detect Where A Moveable Object Is On Stage?
Hi guys, i have a moveable man in a game. I was wondering how i would detect where he was on the stage. I have tried using hittest with an invisible object but i can't get it to work.

Any ideas?

p.s the stage is split into a grid of 4, i want to detect which part of the grid he is in.

Thanks alot, Dave.

Detect If Child Is Outside Parent's Stage
this.createEmptyMovieClip("caption_mc", 999);
loadMovie(_parent.captionClip, caption_mc);

The size of the clip that gets loaded is variable and more often than not part of it will be offstage. I need a way to detect if it's offstage and, if so, adjust x/y & redetect.

Many thankx
--steve...

Best Way To Detect Which Button Pressed On Stage?
In my main timeline, I attach multiple button_mc's with attachMovie. What's the most efficient way to detect when a button is pressed and which one?

I've tried a couple of things, right now I'm thinking of having a global boolean: certainTypeOfButtonPressed, and then onRelease, it sets the boolean and returns the button_mc id. Then on every mouseUp, the main checks the boolean performs the action I want associated with the button_mc id. It would be easy if there was some way to stick the code in the button_mc directly, but I've got too many objects that need to pass variable in the main timeline. Is there a more efficient way to do this? What are your thoughts?

And as always, thank you in advance for your time.

Detect Movie Clip On Stage
I have a number of movie clips in my library that get played depending on what button is clicked on in a menu. In a different menu, I want to be able to detect which movie clip is currently present on the stage. Does anybody know how to do this? Any help would be greatly appreciated. Thank you.

Rich

Detect The Mouse Pointer On The Stage Or Not
Is there a way in flash to detect if the mouse pointer is on the stage. If the pointer is on the stage then perform an action, i.e show buttons else if the pointer is off the stage perform an action hide buttons.

I know there is a way using a hit state, but its not a button I require but rather just the detection of the mouse in the flash scene.

Any help?

Cheers

Trev

Detect Mouse Outside Of Stage Area
For a Flash navigation bar to be built into an HTML page, I've created a submenu system that appears on rollOver and disappears on rollOut. Problem is: Flash is not detecting the rollOut when the mouse is moved outside of the stage area (or out of the SWF and into the HTML area that surrounds it). How can I detect mousing out of the SWF and tell my menu to close?

I've tried each of the following, with incomplete success:
1. a mouseListener checking for the mouse position within stage,
2. a simple action loop checking for the mouse position within stage,
3. attaching an invisible MC to the cursor, then using hitTest to detect when it is not overlapping with a stage-sized MC,
and
4.

ActionScript Code:
stageSized_mc.onRollOut= function (){
closeMenu();
}


This site does it wrong -- the menu stays open when the mouse has rolled out of the nav bar area. Can you help me do it right? Thanks...

Is It Possible To Remove The Stage To Allow Click Throughs?
I want to create a flash widget that sits on top of an html page similar to a TV Banner ad in the lower right hand corner (you know, those annoying pop ups on tv). Anyway, I want it to randomly appear but I would like to be able to click the content underneath when it is hidden. Is this an actionscript function, or a javascript thingy, or would it be better to trigger a javascript/css call and just hide the DIV. Just looking for the best solution.

How To Remove Completely My Xml Mp3 Player From Stage?
Hello

I have in the stage one moviclip called main, that is a xml mp3 player

that mp3 player has one buttom called close


what i want is:

when i click in the buttom close, i want the moviclip main to close


how do i do that?

i´m new in as3

Scene 3 Goes Beyond Stage Shows Everything How Can I Remove That?
My scene 3 is going off the stage can someone help me, I onlly want whats on the stage to be display?

Remove Array Elements From Stage
Hey Guys and Gals. I have the following code that duplicates a movie clip on my stage. At the end of my web banner I am having trouble making the movie clips disappear. It's an online banner so when the banner loops I don't want the duplicated clips to stay on the stage I just want them to clear off and have it start from scratch again. I've tried popping them through a function and the removeChild statement. Just stuck at the moment. Thanks!

//This array will hold all the rectangles on the stage
var rectangles:Array = new Array();


//In this loop, we'll create 50 rectangles
for (var i = 0; i < 25; i++) {

//Create one rectangle
var rectangle:Rectangle = new Rectangle();

//Assign a random position
rectangle.x = 15;
rectangle.y = 85;

//Add the rectangle on to the stage
addChild (rectangle);

//Add the rectangle to the array
rectangles.push (rectangle);

}

//The timer will call the "shakeRectangles" function every 0.02 seconds
var timer:Timer = new Timer(20, 100000000);
timer.addEventListener (TimerEvent.TIMER, shakeRectangles);
timer.start ();

//This function is responsible for animating the shake
function shakeRectangles (e:Event):void {

//Loop through the array
for (var i = 0; i < 25; i++) {

//Rotate the rectangle a random amount (from -4 to 4)
rectangles[i].rotation += Math.random() * 1 - 0.5;

//Assign a new random position
rectangles[i].x += Math.random() * 2 - 1;
rectangles[i].y += Math.random() * 2 - 1;
}
}

Remove Child From MC Thats Not Even Attached To Stage {AS2}
Is it possible to remove an MC from an MC if its not even attached to the stage?

Button When Clicked,, Must Be Remove On The Stage

 hello,
 just want to ask, how do i removed button on the stage?

 what i did for now..when clicked is I set the _alpha to zero 0..but it still active and it overlaps the other button on the next layer underneath.

 can you help me how to remove the current button on the stage when press.

 thanks a lot.

How To Remove Radio Buttons Off The Stage
Last edited by conspirisi : 2007-04-11 at 07:51.
























I'm building a multiple choice quiz.

the code below simply creates 3 radio buttons and labels them. The code that creates the radio buttons is nested in the makeRadio() function.

On occasion my application needs to remove the radio buttons on stage in order to replace them. This is the changing question part of the quiz.

I want to call the makeRadio function again after the stage has been cleared. I've tried creating empty movieclips on the already occupied layers by calling the clear function off a reset button. However the makeRadio() function does not put the radio buttons on the stage as before.

How do I clear the radio components off the stage?



ActionScript Code:
import mx.controls.RadioButton;
makeRadio();
function makeRadio() {
    this.createClassObject(RadioButton, "rb_1", 10, {label:"option 1", groupName:"myrbGroup"});
    this.createClassObject(RadioButton, "rb_2", 20, {label:"option 2", groupName:"myrbGroup"});
    this.createClassObject(RadioButton, "rb_3", 30, {label:"option 3", groupName:"myrbGroup"});
    //
    for (i=0; i<4; i++) {
        this["rb_"+i]._x = 65;
        this["rb_"+i]._y = (i*20);
    }
    // Create listener object.
    var rbListener:Object = new Object();
    rbListener.click = function(evt_obj:Object) {
    };
    // Add listener.ll
    myrbGroup.addEventListener("click", rbListener);
}
resetBtn.onRelease = function() {
    clear();
    makeRadio();
};
function clear() {
    for (i=0; i<4; i++) {
        this.createEmptyMovieClip("", i*10);
    }
}


if you try my code (it should all work if you cut and paste it) do remember to put a radio component on stage and then delete it

How To Remove The Duplicatedmovie Clip From Stage?
Hi all
I am duplicating movie clip from libary with below script on frame 10
I have timer on frame 10 which jump to frame 11 after 5 seconds

when in frame 11 I want to clear off the screen...how???

I tried with:
removeMovieClip("_root.raster");
didn`t work

----------------------------------------------------------------------
movieclip.prototype.klonSpezial = function(spalten, reihen, vertX, vertY, posKX, posKY, iWert, jWert, objekt) {
for (i=0; i<spalten; i=i+iWert) {
for (j=1; j<=reihen; j=j+jWert) {
z++;
attachMovie(objekt, objekt+z, z);
with (this[objekt+z]) {
_x = posKX+(i*vertX);
_y = posKY+(j*vertY);
}
}
}
};
klonspezial(5, 4, 160, 100, 1, 1, 1, 1, "raster");
----------------------------------------------------------------------

AS To Detect Screen Size And Change Stage?
Is it possible to create a .swf that will detect a users screens size and then adjust the stage size to match? I don't need to change my boxes, text, or anything else.

This is of course to be used on the web. So, when a users clicks on my website, my swf file will recognize that users screen size and adjust the stage size to match. Can this be done?

-Scott

Having A Child Detect When The Mouse Leaves The Stage
I'm using the following to detect when the mouse leaves the stage, which is working fine until I try to add my movie as a child inside another swf when preloading. Then it breaks with a runtime error. I've tried playing around with adding the eventlistener to the parent stage, but can't see to get it to work.

Any advice?

Thanks.



Code:
stage.addEventListener(Event.MOUSE_LEAVE, hideMe);

Detect Mouse Leaving Stage Area
hey guys,

looked through the forum and couldn't find quite what i was looking for..
i am draggin a couple movie clips all over the place, problem is when the mouse leaves the stage (or flash player if you will) it still drags the clip, regardless that the left button is let up.  is there a sure and simple way to say "if the mouse leaves flash player" or something?

cheers
paul


Can't Seem To Detect Borders Past The Flash Stage.
Say you do a 100 % x 100% Unstretched flash site. say I have 4 boxes I want to stay on (or just past) the browser window's edge. Regardless of resizing. I have tried to use xMin yMax and the like and I can't seem to trace anything more than the boundries for the initial stage. So if I create the file with a stage of say...1024x768, then test it, only my window is 1600 x 1200 the boxes only move themselves to the original stages boundries. Make sense? it's killing me. How do I detect a windows TRUE boundries? I want to be able to trace what the actual dimentions of the flash file are at anygiven time and move objects to the outer most pixel on resize.even if their negative.

Delete Sprite -- Or Remove Instance From Stage
I often create a function disengage() and call it when I want a certain component to leave the stage. Usually in the function I make the MC/Sprite's x=-100000; or something just so it's not visible, and doesn't obstruct anything else on the stage.

Now I was thinking instead just to delete that Sprite, and create it when I want to see it again. Is that a good idea?

If so, when I use delete.this in the class instance, I get no errors, but it doesn't remove the class instance (which is a sprite, with a bunch of children--Textfields, & shapes).

What's the best way to do this?

Remove Clips From Stage In Random Order
Hello,
I have 6 letters accross the stage on layer 1. I then attach 6 instances of a movie clip from the library accross the stage to cover them using a for statement, so far so good.

Now I want to randomly remove them 1 by one. Any ideas? Here is what I have so far..


ActionScript Code:
var main:MovieClip = this;
var numOfLetters:Number = 6;
var nInterval:Number;
var randomRemoval:Number;
//attach 6 instances to the stage 50 px apart to cover letters//
for (i=0; i<numOfLetters; i++) {
    cover = main.attachMovie("cover", "cover"+i, i);
    cover._y = 50;
    cover._x = i*50;
}
//remove the 6 cover instances 1 at a time from the stage//
nInterval = setInterval(remove, 1000);
function remove() {
    randomRemoval = Math.round(Math.random()*numOfLetters);
    cover/*??*/.removeMovieClip();
}

cheers for any suggestions in advance.

---

F8 Movieclip Change On Stage Causes The Entire Stage To Dissapear
I have my stage with a background picture.

On stage left are buttons, and on stage right I have a movieclip (mc_Preview).

When the user puts his mouse over each button I would like the movieclip to move to a different frame.

the problem is when the mouse moves over a button, i see the movieclip move but then the entire stage dissappears and turns a few shades of gray.

Does this sound familiar to anyone?
Any help would be greatly appreciated!

Collision Detect: Stopping A Movie From Moving On The Stage
Hey everyone,

I have multiple stationary movies on the stage (they dont move around on the stage) and I have a movie that is moved by the arrow keys (on the keyboard). How can I make it so that when the movable movie comes in contact with one of those statinary movies, they don't overlap each other?

(e.g. When Pac-Man hits a wall, he stops moving until the user gives another direction. Also, attempting to move in the blocked direction repeatedly doesn't allow you to pass through)

Thanks!!!

- OneMrBean

Detect/list Instances On Stage, Create Menu
Hi there, for a project i need to have a script checking which instances are on the stage and then make a list of this (or populate a menu in my case). So i have multiple instances (called module1, module2 etc) and when exporting i need a menu to be generated with buttons that have the same name/text as the instances; module1 module2 etc.

Could you do something like: for every instance of moduleclass create menuitem populate textbox with samename. ?
Or do i need something else?.. helpp im freakin out

Detect Broken Image Links Before Loading On Stage
I've just finished a flash projector for my company's lobby that displays all members of the staff in a dynamically generated grid with a page for each department. Flash reads an xml file generated from our Active Directory using php.

I've just discovered a bug. We have several employees that don't wish to have their images displayed; the autogenerated path to their images are therefore false. When the screen loads, a blank space appears where the movieclip is supposed to load.

How do I detect that the image link is bad (must be simple as flash gives out debug errors)? I would like to load an alternate image for staff with missing images.

Here's a snippet of where the movie clips are generated:

Code:
for (i=0;i<nodes.length;i++) {
attachMovie("container", "new"+i, i, {_x:xPos, _y:yPos});

//load the image from the xml nodes array
this["new"+i].photo.loadMovie("images/staff/"+nodes[i].attributes.photo);
}

Detect/list Instances On Stage, Create Menu
Hi there, for a project i need to have a script checking which instances are on the stage and then make a list of this (or populate a menu in my case). So i have multiple instances (called module1, module2 etc) and when exporting i need a menu to be generated with buttons that have the same name/text as the instances; module1 module2 etc.

Could you do something like: for every instance of moduleclass create menuitem populate textbox with samename. ?
Or do i need something else?.. helpp im freakin out

[F8] Remove Dynamically Created Movis Clips From Stage
i am needed some help with this one.

i have dynamically created movie clips through action script to make a small image viewer for a site that i am working on. the problem that i am having is, if a user goes to one of the image viewers and looks at the images there then moves onto the next page with images the movie clips are replaced by the new ones. if the user then goes to a page with no images viewer on it i am left with a black box on the screen where the thumbnails were held for the image viewer.

i have used this code to remove the movie clips but it does not seem to be working.


Code:
removeMovieClip(this.container_mc);
any help on this would be great.

Flash 8 - Remove Warning Text From Stage.fullscreen
Hi there,

Is it possible in flash 8 to remove or manipulate da warning text from flash
9 Stage.fullscreen?

Thanks

Detect Load(ed)Movie Stage Dimensions And Tell Flash Player?
Here's one for you Flashers.

See this site:
http://www.webbersurfboards.com/deploy/swf/shell.html

Anyone know how he is getting the load(ed)Movie to increase the size of the Flash Player in the browser, thereby being able to load different size swfs using 'loadMovie'...so the div it sits in allows a browser scroll when it's needed (and a table below with the html copyright.

Has anyone done this before, or know where I can find a tutorial?

Thanks
{Dilution}

Copyright © 2005-08 www.BigResource.com, All rights reserved