Professional :: Removing Movieclip When Another Is Loaded?
May 27, 2010
I have random buttons on the stage that I have set up so each one, when clicked, will load different movieclip.These movieclips load directly on top of each other in the exact same place.The problem I'm having is the previous movieclip does not clear off the stage when the the next button is clicked.I need to set up a condition that will remove the current movieclip when another button is selected to load the next movieclip.Below is part of my code that needs editing. I've been researching switch, else, and other conditional statements but can't figure out how to make this happen.I have the fla or swf file for viewing, let me know.
// Event Listenershempelbtn.addEventListener(MouseEvent.CLICK,btnActions);fourtyonebtn.addEventListener(MouseEvent.CLICK,btnActions);draycottbtn.addEventListener(MouseEvent.CLICK,btnActions);eg
[code].....
View 5 Replies
Similar Posts:
Aug 25, 2011
I'm loading assets from a swc and I need to loop through every frame of the movieclip and find a certain instance so I can colorize it. Is this possible? It seems that with a swc I loose the ability to control the movieclips playback. It just plays and repeats no matter what I do.
View 4 Replies
Mar 4, 2010
I have a movieclip that gets loaded into another container. The movieclip reads the mouse x & y position to resize a circle according to the mouse position - it works fine on its own, but when the movieclip is loaded into a container I think the actionscript is reading the container's x & y, not from the mc itself.
The code I'm using to read the mouse x & y is:
d = Math.sqrt(Math.abs(_root._xmouse-this._x)*Math.abs(_root._xmouse-this ._x)+Math.abs(_root._ymouse-this._y)*Math.abs(_root._ymouse-this._y));
It works out the distance of the mouse from the central point (centre of the circle movieclip.)
Like I say, it works fine on its own, but when in another container the _root is causing the x & y to be displaced.I've tried _lockroot, but that stops other stuff working properly in the movieclip (drag and drop.) Is there another way I can directly access the x & y properties of the main movieclip without using _root?
View 2 Replies
Mar 29, 2010
I'm working with several videos each inside their own movieclips. When I click my forward button to jump to the next video I get the second video playing over the first one especially towards the end part of the first video. I can play and stop the movies just fine but it's the gotoAndPlay that's causing me problems right now with forwarding and rewinding clips.
Hope my explanation was clear cause I'm just starting out with AS3
[Code]...
View 1 Replies
Sep 18, 2008
I've loaded a swf into a MovieClip and I want it to be removed when I hit a button. My attempt to do so is like this:
swfContainer.removeChild(swfLoader);
At first it seem to work but since the loaded swf contains sounds and music the music continues to play.
Anyway heres the code for loading the swf:
View 4 Replies
Mar 29, 2011
I am trying to load an external .SWF into my current .SWF. I have managed to get it loading onto my application, but then once the animation has finished and i click onto another button, i.e. 'gallery' or 'contact' i want the swf to be removed, i know i need to add a remove child somewhere but i dont know how. this is my code.
[Code]...
View 1 Replies
Jan 18, 2010
I'm trying to make a flash feature, slideshow, news thing. I think I have ait all done apart from I'm loading images from xml as the background (different one for each story). The problem is I used a tutorial and the code seems to simply add an image on top of the old instead of replacing it. I'm using an alpha transition when the image changes so the image behind is visible for a short time, which isn't the desired effect.Is there a way to either replace the image instead or at least remove the old image?This is the code to load the image url from the xml
Code:
function loadImage(url:String):void
{
imageLoader = new Loader();
imageLoader.load(new URLRequest(url));
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
}
...and this code simply sets the imageArea MC to the loaded image
Code:
function imageLoaded(e:Event):void
{
imageArea.addChild(imageLoader);
}
View 1 Replies
Jan 28, 2009
I'm loading 31 SWFs in total. For example, the first one shows and it has a 'Next' button. When Next is clicked, then it loads the second SWF; and so on until reach a total of 31 SWFs.
No problem here, but thing is that while more SWFs I'm loading, heavier gets the file and little by little it's being taking longer to load. Because when I reach the 31 SWFs, I got a total of 31 childs loaded one after another.
I've been thinking in the posibility of removing the SWFs once they are no longer seen but can't find how to do it...
This is what I'm doing:
ActionScript Code:
import flash.events.MouseEvent;
import flash.display.Loader;
import flash.net.URLRequest;
[Code]....
It basically does this in every one of the 31 FLAs, so, as you can see, it goes loading and loading SWFs. Problem, as I said, while bigger the amount of SWFs loaded, slower the process gets. I'm using e.target.parent.addChild because all this is inside a MovieClip called mc.
How to remove the ones I'm no longer using?
View 4 Replies
Oct 10, 2009
I am loading external swfs into a MC on the stage. I noticed they are stacking up and not being removed or replaced. How can Iremove the previous loaded swf?
Code:
package {
import flash.display.MovieClip;
import flash.display.SimpleButton;
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.MouseEvent;
[Code] .....
View 3 Replies
Nov 24, 2010
Currently I'm working on a flash application that will be used for presentation purpose. The application loads external swf files which are exported from powerpoint. This way people can make there own powerpoint presentation, export with a plugin as swf files included with animations, video or audio.
The presentation itself is a 3D carousel containing icons which represent chapters. Once a chapter is clicked, a page slider opens and loads all external swf files needed for that chapter.When someone is done with that chapter, you can close the pageslider. To make sure the application keeps it performance, it will remove all event listeners, free display objects hold in arrays and get rid of all what won't be used again. This works fine, the memory use goes back to original state and no problem.
Now when I take a closer look at the fps of the application which is set to 60fps, and load AVM2 content, nothing goes wrong whatever I do or close. As soon as I load AVM1 content and display it, the fps stays steady at 60. But as soon I close the pageslider and free up memory, the fps is stuck at 30. As soon I open a chapter with another AVM1 content, the fps restores to 60.Now I thought maybe it's because I did something wrong when I free some memory, so I turned that function off which gets rid of all the stuff. Then I tried again, but again when I load AVM1 content I got 60fps but when I don't display the content my fps goes back to 30. But this problem doesn't exist when I load AVM2 content or even just png's instead of swf files.But when I turn this free memory function on and not display the AVM1 content and which doesn't exists at all on the background anymore, the fps is still 30.
Now I thought about a fix to just restore the framerate afther the pageslider is closed. But as soon I use "stage.frameRate=60" the player crashes completely. how can AVM1 content on display let the application run 60fps, but when removed from memory and not displayed set the fps to 30 and get to 60 again as soon new AVM1 content is displayed? But AVM2 content it's all just fine.
The reason I load AVM1 content is because the powerpoint -> swf exporter can only export AVM1 content.I also checked if the fps of the exported swf is set to maybe 30, but that's not the issue, and besides that it theoretically would use the main swf it's fps.I could set the main application fps to 30 and no one would notice, but I just can't sleep why i can't figure out the issue.Btw when I set the main fps to 30 it won't be reduced to 15fps.
View 3 Replies
May 31, 2010
Is this at all possible? I just finished re-building my entire portfolio site in AS3 because I can't change the frame rate for loaded content in AS2. Now I find out after completely rebuilding this thing that AS2 content gets stuck in Flash Player 9's memory and won't erase on Loader.unload. All my work from years back is in AS2.
View 0 Replies
Apr 21, 2009
I managed to load in an external swf file okay however, I need to be able to remove it when the user clicks a link to go back to the homepage. Below is my code:
Code: Select allstop();
var imageRequest:URLRequest = new URLRequest("gallery.swf");
var imageLoader:Loader = new Loader();
imageLoader.load(imageRequest);
addChild(imageLoader);
home_link_btn.addEventListener(MouseEvent.CLICK, homeLink);
[Code] .....
I assumed it was as simple as removing the child but it still remains. I get no compile errors or anything.
View 2 Replies
Feb 19, 2012
having trouble removing loaded child object b4 loading a new one i can load a child object with this script if button is pressed:
[Code]...
but having difficulty unloading child object when just that mc_char.btn_darkangel button is pressed. Cause otherwise it just adds another instance then another and another and the different instances kinda pile ontop of each other my question is how can i incorporate removeChild script so that mc_char.btn_darkangel doesn't just pile instances of image ontop of each other
View 2 Replies
Jan 21, 2009
I've created a drop down list and populated it with dynamic buttons. (I made a DropDown_btn class with a dynamic text field in it and then filled the button text from an xml file). On rollover I tint the button blue and then set the tint back to black on rollout. When you click on the button I'd like it to stay blue until a different button is clicked.
I thought on CLICK I'd run a function like this:
ActionScript Code:
function removeRollover(evt:MouseEvent):void {
evt.target.transform.colorTransform=c;
evt.target.removeEventListener(MouseEvent.ROLL_OUT, btnOut);
evt.target.removeEventListener(MouseEvent.ROLL_OVER, btnOver);
}
...and then I need to addEventListeners back to any button that doesn't have them and set that button back to black. I could do this by looping through an array of the buttons but I can't figure out how to access them as objects.
I also gave them each a property of "buttonValue" when I loaded them so I can access event.currentTarget.buttonValue (which in this case is a number from 1-5) but once again I can't figure out how I might leverage this information.
View 2 Replies
Mar 25, 2011
How do I make visible a movie clip in the main movie from another movie clip when it loads? Not using addchild since the movie clip is on stage.
[Code]....
View 3 Replies
May 21, 2009
Is there a way to remove a class linked to a movieclip? For instance, I've got a ball (e.g. ball0_mc) that's placed in a target. The way the ball is dragged and dropped into a target is by using a class called Ball. What I would like to do is remove the Ball class from ball0_mc once it's been placed in a target so that it can't be dragged or dropped anymore.
View 2 Replies
May 16, 2010
Allright, this is what my code looks like:
ActionScript Code:
public function onRequestStart(navigationEvent:NavigationEvent):void
{
playScreen = new ZombieHorde();
[Code]....
When I do removeChild on playScreen, the movieclip just becomes invisible, it doesn't actually get REMOVED. Is it possible to delete a movieclip that you've created just like that?
View 3 Replies
Mar 14, 2007
im creating a game where when the spacebar is pressed the character attacks with a sword.the sword is an animated movieclip and at the end of the movieclip i have a his.parent.removeChild(this); to remove the movie clip but i get an errorCode:TypeError: Error #1009: Cannot access a property or method of a null object reference.
View 1 Replies
Oct 24, 2010
ok so im trying to use
stop();
addEventListener(Event.ENTER_FRAME,myFunction);
function myFunction(event:Event) {
[code]....
View 3 Replies
Sep 24, 2009
I have 5 movieClip buttons. I want the GALLERY button to stay on the stage at all times, "which it does" but i want when the user clicks on 1 of the other 4 buttons for the remaining 3 to disappear. Example...when the user clicks on the KIDS button, the COUPLES, PORTRAITS AND BELLIES buttons disappear, or when the user clicks on COUPLES, for the KIDS, PORTRAITS AND BELLIES buttons to disappear, and so on.
Code:
import fl.transitions.Tween;
import fl.transitions.easing.*;
[code]......
View 16 Replies
May 10, 2010
I have 5 movieClip buttons. I want the GALLERY button to stay on the stage at all times, "which it does" but i want when the user clicks on 1 of the other 4 buttons for the remaining 3 to disappear. when the user clicks on the KIDS button, the COUPLES, PORTRAITS AND BELLIES buttons disappear, or when the user clicks on COUPLES, for the KIDS, PORTRAITS AND BELLIES buttons to disappear, and so on.
Code:
import fl.transitions.Tween;
import fl.transitions.easing.*;
var currentPage:MovieClip = gallery_mc
[code].....
View 1 Replies
Feb 2, 2009
I have a MovieClip that I dynamically add other MCs as children to. Now I'd like to have a function that removes ALL children at once. I tried a loop with (i < mc.numChildren) but somehow it will only remove even-numbered children, the odd ones stay on stage?
View 12 Replies
Dec 21, 2011
I placed a movieclip on the stage, what functions are there to remove it?
removeMovieClip(target);
Only seems to work on MCs which have been attached to the stage E.g.
attachMovieClip();
The _visible property keeps the movieclip there just keeps it invisible. What completely removes it? It is called tankCPU.
View 6 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
Jan 28, 2009
In my .fla file, I have a MovieClip (we'll call it Clip1) linked to a corresponding class defined in a separate .as file.There's a case where I want to create a new MovieClip (Clip2) where Clip1 is, then remove Clip1. This case is dealt with by a function in Clip1's class.So, when I get to removing I do:ActionScript Code:this.parent.removeChild(this)Now, if the DocumentClass created Clip1 and placed it on the screen, this goes fine. But if Clip1 was placed on the stage in the .fla file (by dragging and dropping), it looks like Clip1 is not removed. I think it does get removed, but for some reason it gets recreated. This is the problem.
View 9 Replies
Nov 30, 2009
i am having trouble with removing a movieclip off the stage, i am using removechild but i get an error:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display:isplayObjectContainer/removeChild()
at agptest_fla::MainTimeline/removeArrow()
here is my script
ActionScript Code:
var aLeft:MovieClip = new arrowLeft();
var n1:Number = 0;
[code]....
View 1 Replies
Jan 11, 2011
I have a function called changeMovie which is supposed to load a new movie/swf into a already established container.I can get the new movie to load (all these movies have sound embedded in them) but I can not figure out how to get the old movieclip out of memory.I can foresee an instance of memory overload in my application down the line.I am using Flash CS3 with AS3.[code]As it stands now, I can get the new movie to play and be shown but the old movie clip still continues to play "in the background - along with its sound".
View 9 Replies
Apr 25, 2011
I've currently got an array made up of Movie Clips, and a variable to tell us how long that array is. It looks like this:
ActionScript Code:
var coinArray:Array = [coin1, coin2]; //an array which contains all of the coins
var numCoinArray:int = coinArray.length; //how many objects are in the coinArray
I've got a function called collisionTest which tests a collision between two objects.
So, I've got a loop set-up so if my character and a coin collides, it removes the coin it collided with from an array. It looks like this:
ActionScript Code:
function coinCollect(evt:Event)
{
for (var i:int = 0; i < numCoinArray; i++)
{
[Code].....
Is this trying to reference my objects as something other than MovieClips and is finding them and not recognizing them? I'm completely lost on this and can't understand why it doesn't work.
View 8 Replies
Feb 1, 2003
I've seem to have hit a snafu in a small animation I am creating for my next tutorial. What I have, is a movie clip that gets duplicated when the space bar is pressed. The movieclip has actions setup so that when the movieclip reaches a certain y value, it will remove itself via this.removeMovieClip()
The problem is, every movie clip that is duplicated does remove itself like it is supposed to. The exception is the original movie clip that I duplicate from. That movie clip seems to want to stay and cause problems (it is not removing itself because it isn't duplicated via attachmovie or the duplicateMovieClip method).
View 6 Replies
Apr 5, 2007
i have this function that everytime i click the screen a box appears.
function box () {
_root.onMouseDown = function(){
movie = _root.attachMovie("mcBox", "mcBox", _root.getNextHighestDepth());
[code].....
View 3 Replies