ActionScript 1/2 :: Removing Movieclips Created At Runtime?
Mar 9, 2009
I'm trying to remove movieclips created at run time using "createEmptyMovieClip" but I'm having a problem calling the "removeMovieClip" function. The difficulty seems to be that the string that I assign as the instance name of the new movie clip doesn't actually refer to the created clip when I try to call"removeMovieClip".
So the "removeMovieClip" function doesn't work if the target name is pulled from the array. My guess is that this has something to do with the values of the array being strings...and it does when I manually type Apple.removeMovieClip(); in because Apple is the movieclip object name. How do call the "removeMovieClip"function using a var as the target?
[URL]I've managed to get it all working though am having trouble extending it more. Basically I've got it set up so that when the used click on another button it loads another xml, basically going to another gallery.It works fine apart from the fact that when i change the gallery, if the previous one has more photos then they are left over in the thumbnails of the new one. So basically what i need to do is remove the created movie clips, when i click on a button then load the new xml file. I can get them using the following code, added onto the end of the tutorial:
Code: image_mcl = new MovieClipLoader(); image_mcl.addListener(tlistener); image_mcl.loadClip(thumbnails[k],"thumbnail_mc.t"+k);
[code]....
Obviously this isn't what I want as it removes them just after they are created, i was just trying to figure out how to remove them! I've made this function global etc and had buttons use the function but it still wont remove them!The Full path to the created clips is contentHold.content2.gallery.thumbnail_mc.t[i], where i is the numer of photos in the gallery.I created another movie clip within the thumbnail_mc clip and could manipulte that so i'm guessing it has something to do with them being created dynamically?
Is there anyway through which we can know that which event listeners are currently active and we can remove them at runtime? I am trying to create drawing board which have different shapes to draw. But I have to add event listener with for every shape and have to remove previous listeners. I want to remove the all active listeners in one go. Is it possible.??
I created a SkinnableContainer runtime because I want to set some style properties to it, then based on some external data I need to create a new SkinnableContainer and add it as children of the first one. This children height can be greater than the parent container.How can I create a SkinnableContainer runtime with some scrollbars?I read in the documentation that I need] to create a new Skin. [code
I do not know how to copy a DisplayObject can anyone can help me on this one? I've downloaded an image from a website at runtime and putting it into a DisplayObject and now I'd like to create a completely separate copy of it so I do not have to make another request to download it again.
After adding an image to the stage, turning it into a Movie clip, and setting linkage in library to Export for Actionscript, I'm now using a timer to add a bunch of roses to the stage as a video plays.How can I get rid of all these clips once the video is over?Do I need to add all of them into an extra container and then just removeChild that container at the end? Or do I need to use something like getNumberOfChildren and then create a loop that removes them one by one?The clips (myRose) are fairly small and do not have any event listeners added to them. I just use TweenMax to move them from top to bottom of the screen.
public function roseTimer():void { MonsterDebugger.trace(this, "in roseTimer");[code]......
im develloping an application for create a layout of advertising newspaper. the user can set the number of pages, and create rectangles represanting the adverts, then drag them and place them into the the representation of the page.the display list is as follow: on the main stage there is inputs textfields and a button that create the pages according to the number that the user typed.Then instances of the pages are created (MC Page in the lybrary exported for AS as Page and i have a class Page as well). Inside this clip Page i have my tools for create the rectangles and drag and place.....As well as the instances of my pages are created, button(1 for each Page) are also created. NOTE that Page and button are in the main stage My probleme is that i want my button to change the depth of is related page for it can be on top or alpha at 100% or the visibilty to true, but my button doesnt find the instance name of the pages at the export because they are not yet created.
Is there a way to obtain a reference name of each item on the stage. A reference name that can be then used to manipulate the object? (and how would one do that if successful in obtaining the name?)
As an example that is not working for me, if I drag to stage two movie clips and dynamically include 5 additional movie clips at runtime, this [code]...
I am having trouble clearing out a shell movie clip that has other mcs dynamically placed inside it. Something like this;
var myShell:shell_mc = new shell_mc;addChild(myShell);// //---obviously these buttons are on stage already---buildBtn_mc.addEventListener(MouseEvent.CLICK, buildFunction);clearBtn_mc.addEventListener(MouseEvent.CLICK,
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?
I have problem with casting custom event currentTarget to component. When I'm trying to removeElement from its parent container i get error. What's the deal?
TypeError: Error #1034: Type Coercion failed: cannot convert mx.events::FlexEvent@8811c41 to com.modultek.pis.itemmachine.search.events.SortEvent. private function sortSelection_removeHandler(event:SortEvent):void { var sortSelection:SortSelection = event.currentTarget as SortSelection; this.removeElement(sortSelection); }
I have two TLF textfileds in my application. The first TLF textfield is on the stage and the second one is created dynamically during runtime. Now I am able to embed the fonts in the first TLF textfield by using "use device fonts" since it is on stage. The flash player the rendering the data absolutely fine. I want to get the same look and feel for the second TLF textfield which is created dynamically during runtime. I tried so many ways.
I ran into the 'fontswf' utility to embed TTF fonts into SWF and I am struggling to load them at runtime from my app. All the examples I find online refer to loading the font via [Embed] but I am actually loading them with a flash.display.Loader and from what I gather, once the Loader.contentLoaderInfo fires an Event.INIT I need to register the font, like so:
public function handleLoaderComplete( event:Event ):void { var FontClass:Class = event.target.applicationDomain.getDefinition( fontName ); Font.registerFont( FontClass ); }
The problem is I don't know what to pass in as fontName. I am generating my SWF through:
$ fontswf -a belshaw -o belshaw.swf belshaw.ttf
But when I try to call getDefinition( 'belshaw' ), I get an error saying 'Variable belshaw is not defined'. Any suggestions on how to accomplish this?The alternative is to generate my on SWF files through templating an .as file and compiling them, but I would rather use a built in tool like fontswf if it's already there.
I need to dynamically bind properties of components created at runtime. In this particular case please assume I need to use bindProperty. I don't quite understand why the following simplistic test is failing (see code). When I click the button, the label text does not change.
I realize that there are simpler ways to go about this particular example using traditional non-dynamic binding, but I need to understand it in terms of using bindProperty.
I am new to ActionScript 3. I found the code to create a setof radio buttons - the problem is that each time I call asubroutine, it seems to create a new set on top of them (hence theyget darker each time someone clicks them. I need to be able toclear them from the stage and start over - basically the codecreates a set of radio buttons, and then a set of radio buttons foreach of the main buttons created. I've tried destroy object -generates compiler errors.
every so often a movieclip is dynamically created using actionscript from the main timeline. It has the instance name of
Code: ["spark" + i]
each time one is created "i" goes up 1. so I end up with spark1, spark2, spark3, spark4 etc. etc.What they need to do is play through an animation (about 4 frames) and then destroy themselves.
I've dynamically created event listeners in the usual sort of way:
Code: myText.addEventListener(MouseEvent.MOUSE_OVER, hover(nameLabel)); function hover(nameLabel):Function {
[Code].....
The problem is how to remove the event listener later in the program as the usual code isn't working. I'm guessing I should have done this in a class but I'd like to understand this problem better.
apply actions to an attached/created movie clip at runtime? I.E. You use attachMovieClip to attach a clip, and then you add a startDrag/stopDrag system to it dynamically.
Does anyone know a way to apply actions to an attached/created movie clip at runtime? I.E. You use attachMovieClip to attach a clip, and then you add a startDrag/stopDrag system to it dynamically. Is it possible?
I have various instances of a movieclip spread across 3D space. The user is able to navigate across the 3D space using the mouse or the arrow keys - I've used a style similar to the old school first person shooter games. Some of the objects on the stage are related so I want to connect them with a line to show their relationship. As all my objects are dynamically created through AS at runtime the relationships also need to be dynamically generated. As the user navigates around the 3D space the line between the objects needs to get redrawn.
In a 2D world I'd use the drawpath or moveTo/LineTo methods to join the movieclips and have a function on the onEnterFrame command of the 3D space to keep redrawing the line.However since this is a 3D world I need to take into account the z location of the movieclips as well as the x and y locations.how I could do this or even point me in the right direction to get started?
I'm trying to create a container movie clip, then inside that, create several other movieclips with an image in each and display them with an offset x.It does the offsetting but only displays the last one at the last x.When i dont put the clips in a container it works fine. but i want them in the container so that i can movie the container around on a press.
Heres the code:
var itemsArray = new Array("pic1.jpg", "pic2.jpg", "pic3.jpg", "pic4.jpg"); var clipArray = new Array(); _root.createEmptyMovieClip("carousel", this.getNextHighestDepth());
I want to use the same movieclips (some are button movieclips) but be able to have a function lay them out at runtime in two (or more) layouts. Just the _x and _y position like in this example:I'd like to layout the mcs with just actionscript. So it can be hardwired into the movie's script with parameters A yielding layout A, et cetera.
code: function loaderCompleteHandler(e:Event):void { var scoreXML:XML=new XML(e.target.data); var playerResult:MovieClip;
[code]....
I have a MovieClip with the linkage name of "playerResult" in the library. For every loop it takes the scores+names from the xml and displays them by creating a new instance of "playerResult" and attaches them one by one under each other.I need to be able to remove this highscore when it's not longer needed, thus (the most important part) freeing up memory. So I can then use the same code to show the scores again without doubling the memory it uses every time.
code: function loaderCompleteHandler(e:Event):void { var scoreXML:XML=new XML(e.target.data); var playerResult:MovieClip;
[code]....
... so I now have a name for each instance (playerResult0, playerResult1...) but still can't come up with a way to remove them.