Add/removeChild

Hi,
I have a child (an external swf) that I'm adding on frame 2 of my main timeline. It will load, but I have another issue. My timeline navigation is designed as such that the viewer can return to frame 1 after viewing frame 2. I don't want the child to be visible on frame 1 ever. Obviously, I can't simply use removeChild, because I haven't yet added it when frame 1 is reached and so I get a null object reference. I've also tried playing around with the visibility property of the child, but with no luck. I feel like I'm missing an obvious solution here. What should I do?
Thanks!

Hi Ned,
For some reason the movie still won't load into the container. It loads on the wrong place in the stage.
What's going on here? The code dealing with the swf is pasted below:
var req:URLRequest = new URLRequest("lakefillpreloader.swf");
var loader:Loader = new Loader;
loader.load(req);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, addIt);
function addIt(event:Event):void
          trace("hit");
          container_mc.addChild(loader);
home2_btn.addEventListener(MouseEvent.CLICK, closeIt);
function closeIt(event:MouseEvent):void
          trace("removed");
          container_mc.removeChild(loader);
          gotoAndStop(1);

Similar Messages

  • Garbage Collector Questions

    Howdy all,
    I've got a few questions about flash's garbage collector.  I'm building a  game and have all elements in a container sprite called _gameContainer.
    _gameConatiners contains other sprites such as _hudContainer which  contains more containers such as _gameoverContainer, _menuContainer,  etc.  So there's a whole hierarchy of containers that are all contained  in _gameContainer which is added directly to the document class (not the  stage btw).
    So the whole thing should basically be Stage -> Document Class -> _gameContainer -> etc.
    When the player loses or wants to restart the game, I'm removing all  event listeners (which are defined as weak, but still rather make sure  there's no loose ends), stopping all music/sounds, removing  _gameContainer from the stage, and then setting _gameContainer to null.   From there I am re-calling my init function which creates everything  (_gameContainer, and everything inside of it, as well as creating all the  standard eventlisteners).
    Am I doing everything upside down?  Is this *a* proper way of restarting  a game?  Mind you I dont say "the" proper way since I'm sure there's a  hundred different ways to do this.
    Also, on a separate note... If I have something such as an enemy, I keep all  enemy logic contained in the class linked to the movieclip on the  stage.  Who should be calling add/removechild?  Should I be using a  factory method that takes care of all this, or should I have the engine  create the enemy, and then have the enemy remove itself from stage?   Currently I'm using a mix of both, but generally I'll have a function in  the engine/caller add it to stage, then have the class have an  ADDED_TO_STAGE event listener.  When it comes time to remove the class, I  have it call it's own removeself function such as: (_container is a  reference to it's container as mentioned above such as _hudContainer)
    protected function removeSelf():void
        if(_container.contains(this)) {
            _container.removeChild(this);
        _container.parent.parent.dispatchEvent(new Event(Engine.START_GAME));
    Thanks!

    Wonderful question Travisism.
    The garbage collection is strange.  First I'm curious why you lump displayObjects into _gameConatiners.  Does _gameConatiners get added to the stage at any point?  Why not just add the proper hud at the point its required?
    Anyhow.  By removing listeners ,removeChild(_gameConatiners), and setting _gameConatiners=null does not mean these classes are killed.  null only marks the memory locations as having no more references to them.  When this occurs these objects may be removed from memory.  Why do I say may, that is because it takes a specific amount of memory utilized to trigger the garbage collection.
    Now just merely setting _gameConatiners=null may not ever kill your objects off.  You would be required to profile this and make sure they are dieing properly.  From the sounds of it you have a lot of inner children.
    There is reason to believe that in some cases, when an object is removed from the main stacks that its children will be removed as well.  Though, if the inner workings are so large, often the objects within referencing each other effects the way the garbace collection is stating they are still in use.  Thus keeping these objects alive.
    Its always best to kill off every reference being used.  You can do this by ensuring each object in your movieClip class declared a kill method, and continue trickeling down each object.  This ensures each object will be properly marked.
    As far as your movieClips a factory method is only for the creation of objects, never for the removal.
    You're best bet is to have an object that holds all objects on the stage in a collection.  When you destroy the game. Itterate through this collection and remove them from the stage there.
    This would fit into your engine concept.  There is no reason to use a displayObject for that since its just an object.  Better Yet use a Vector.<DisplayObject> to optimize this.
    Back to your question is this *a* proper way to reset.
    Yeah and No.  The asnwer is based on the memory usage your application eats, and the amount of time to rebuild all objects.  Ideally you should Pool any resources that can be reused versus having to rebuild.
    For example.  If you have a screen that says Game Over.  why would you have to rebuild it on a reset?  There is no information that was changed.   Each clip instantiation takes memory allocated and time.
    Unfortunately without seeing what you have its difficult to say.  But init methods are good and it can be wise to rebuild objects to being again, but as i said it depends.
    Lastly, your line:
    _container.parent.parent.dispatchEvent(new Event(Engine.START_GAME));
    Should not have parent.parent references within.  If you are creating a new Event, at least fall back on eventBubbling to allow the event to travel to the parent.parent.
    You should never target parents like that in a class.  Best practices is to pass in parent.parent as a reference to the class.
    What if you were to add one more layer of parents to the _container.  Then you would have to continue modifying parent.parent.parent.  At least if you bubble the event you dont have to be concerend at all about who listens to it.

  • CacheAsBitmapMatrix for multiframe MovieClips?

    Alright, so I've been running performance tests all day to try and suss out what is the best way to package flash assets for iPhone deployment.
    So far I've created several benchmarks of different methods, with a simple app I wrote to run on my iPhone 4, and I've got solutions for most situations...except for a good way to handle multi-frame MovieClips.
    For single frame MovieClips, simply toggling on 'cacheAsBitmap' and setting 'cacheAsBitmapMatrix' yields pretty good results, allowing translating/scaling/rotating at pretty fast rates (100 constantly translating/scaling/rotating MCs yield about 30fps).  In fact for these single-frame scenarios I'd rather use a 'Sprite' but the 'cacheAsBitmapMatrix' option seems to only be implemented in the MovieClip class, even though the documentation states that it is implemented at 'DisplayObject' level...but that's another discussion I suspect.
    So...single frame rotating/scaling/translating MovieClips are do-able with GPU acceleration, but multi frame MovieClips are not for some reason.  Logically, cacheAsBitmapMatrix does NOT work for these, because it seems to cache the 'top level' MovieClip, so as the frames advance the old frame is discarded and the new frame is re-cached to the GPU... which means all the cost with none of the benefit.  What I would like to be able to do, is to have a multi-frame movieclip that intelligently caches ALL the frames (as though 'cacheAsBitmapMatrix' was set ON EACH FRAME, rather than at the parent 'MovieClip' level) and then uses those GPU-optimized cached versions OF EACH FRAME for repetitions of the same movieclip, or even for repetitions of all instances of the same movie clip on the stage at a given time.
    So I suppose what I'm interested in hearing is:  Has anyone else found a good way to handle this scenario, either through some trick that I am just not aware of, or an entirely different method?
    If anyone from Adobe wants to chime in, I've got a few questions that maybe you could help out with:
    Will 'cacheAsBitmapMatrix' be implemented at the DisplayObject level in the future to match what the documentation indicates? (<- that would be super, as I'd love to use a more lightweight class for just showing a single Shape in a GPU optimized way) 
    Will Flash CS5 allow a 'cacheAsBitmapMatrix' option in the UI, or will AS3 code remain the only way to turn this option on for the forseeable future? 
    Is there, or will there be, some way to make 'cacheAsBitmapMatrix' behave in the way I've described for multi-frame MovieClips? This of course relies on the assumption that Movieclips that would be used this way would not have Actionscript attached to the timeline that might change the frame content as the playhead marches forward.  I saw that note made in some documentation I was reading in my studies here, and it makes sense for one particular use-case, but leaves a more simplistic 'MovieClip as a frame buffer' use-case high and dry.
    I hope this had made at least a small amount of sense, and If I'm overlooking a simple solution to this problem I'd love to hear it

    sorry i wrote too much and you already went over some of this, hopfully this is relavant here it goes....
    I have done some Air/Android stuff, but not iOS packager yet.
    If i understand correctly, iOS in GPU mode should now render the same as android Gpu mode already has been.
    Here is some info i have found in my testings on android, i think it should apply for iOS in GPU mode.(but note sure)
    All display objects (vector or bitmap) get cached automatically once they are visible on stage, including movieclip timelines.
    Duplicate instances of each display object will automatically blit from those cached pixel buffers.
    There is no need to cacheAsBitmap or with matrix, its basically already doing this for you.
    Furthermore if you DO cacheAsBitmap=true, it will re-cache every time its removed/added again. No one wants that
    With this "auto cache" it stays cached until garbage collection takes it. so you can add/removeChild at will, it will not discard the cache like cacheAsBitmap does.
    As a test, create a movieClip with a few frames of hand drawn vector lines.
    When you add this movieclip to the stage, it will stutter as its first caches each frame(must allow it to loop once to cache each frame if i remember correctly).
    When completed, you can now create add/remove multiple instances of that same movieClip type, and you will see its instant because its blitting from the same pixel buffer, which is already cached from the first instance.
    At present time there is no way to tell it to autoCache, you must add it to stage, however i'm pretty sure that is a new feature available in flash cs5.5
    things that will prevent it from "auto caching" when added to display list:
    visible=false;
    coordinates are off stage.
    Basically flash needs to try and render it, if it has no pixel buffer yet it will create one, else it will blit from it.
    Here is what i do:
    -draw black rectangle with graphics api (stageWidth and height)
    -add Splash screen graphic with "Loading" text
    -loop threw all needed display objects and add to stage (behind loading screen of course)
    -Timer for 6 seconds, then remove all children and load my content as needed... now all your items are cached and  no one saw the stutter. I pool objects, but like i said if you do need to create new instances, its not a problem as long as 1 instance has attempted to display before hand there will be no caching stutter.
    danio_39, a few posts up you mentioned this blog, but did you see part2 to that post? If not take a look
    http://www.yeahbutisitflash.com/?p=2447
    Chris Caleb does a great job at pointing this out. Performance of timeline animations in GPU are about the same as blitting in CPU mode. Basically GPU will autocache and blit for you and you get the added benefit of being able to rotate/scale.
    (focus on the android info, at the time of that post iOS packager did not use GPU_VECTOR, but now it does so results now should be similar to the android findings i hope).
    A few things i have noticed with android/GPU mode:
    scaling an instance has no hit on performance, however scaling an instance more than 50% in either direction will cause it to recache.
    For instance create/addChild 10 instances of a movieClip, all is well, but create only 2 instances and do this:
    var instance1:Player= new Player();//base class MovieClip
    var instance2:Player= new Player();
    instance1.scaleX=.4;
    instance2.scaleX=1;
    Remember they pull from the same source, if these are both added to stage fps will DIE because they bounce back and forth each re-writng the pixel buffer because its more than a 50% change when it goes to render.
    example:
    this will work fine because it renders within a 50% scale of the pixel buffer
    instance1.scaleX=.4;
    instance2.scaleX=.1;
    instance3.scaleX=.3;
    instance4.scaleX=.2;
    instance5.scaleX=.3;
    OR
    instance1.scaleX=.9;
    instance2.scaleX=1;
    instance3.scaleX=1.1;
    instance4.scaleX=.6;
    instance5.scaleX=.7;
    Also it does NOT auto cache drawings created with the graphics API.
    This is the only time i have ever seen performance enhancements by calling cacheAsBitmap when in GPU mode.
    In general the graphics API is very fast, but for example if you draw something with tons of lines, it is now that cacheAsBitmap will help.
    (keeping in mind the cache will invalidate once removed from stage)
    ...if you were to hand draw that same vector graphic in flash IDE it will be autocached when it goes to display and no need to cacheAsBitmap
    Draw on the fly with the graphics API is great for two reasons:
    -no need to worrying about auto caching/storing another memory chunk
    -there is no stutter because it is not going to cache...unless you tell it to
    So I do not know if all this apply's to iOS, i think it should now that it uses the same render mode as us android nerds(GPU_VECTOR), but again I have never used iOS yet. All specific tests on my part were with air 2.5 runtime but i'm sure this is all still valid because my performance has only gotten better with Air 2.6.
    So bottom line, on android GPU mode normal movieclip timelines (if done correctly) perform just as well as blitting in CPU mode. However i think the CPU mode/code blitting route is more stable as you know what to expect. GPU performance can be tough and varies on android devices. I am really interested to see how iOS handles normal movieClip timelines in GPU mode, so far i haven't seen anyone explicitly benchmark timeline animations with the new iOS GPU mode like Chris Caleb had done with the older GPU_BLEND on iOS.
    One other thing i will mention because i don't know if this is a GPU issue or what...I made a game like this for android, normal movieClip timelines, "pre-cache" everything behind a fake loading screen, it performs perfect...for a while. I can play the game, leave it paused, minimize it,exit, re-open, whatever. But if my phone is on for a few days. It performs poorly(even the simplest of air apps do actually) I need to reboot the phone to get performance back. I have a free app on my phone called "memory boost lite". When this issue occurs i will notice my game is using less memory than normal. It seems like something on my phone is garbage collecting my cached items causing it to keep rewiting to memory/stutter, i have yet to figure it out but i wonder if its my phone specific or a GPU drawback. I am not explicitly telling it to cache so i wonder if it makes a week reference or something? I will be posting another thread about this with more detail sometime soon but its weird because when this is happening i can open up angry birds which takes a massive 77MB of memory and it has no problem staying smooth.

  • A better way to do this -- add/remove multiple childs

    I have 6 movieClips on stage.  When I roll over any one of them, I want to:
    A) removeChild the remaining 5 movieClips and then
    B) bring a new movieClip onto stage that would hold a description and possible button links
    Upon rollOut, I want to fire a 3 second delay, removeChild the description movieClip and then addChild the original 5 (removed) movieClips.
    Make sense?
    I started typing away and came to the impression that I might be going about this the LONG way.  Any shorter/smarter ideas would be appreciated.
    Here's the code:
    package{
        import flash.display.*;
        import flash.events.*;
        public class mainAS extends MovieClip{
            public var backgroundImage:imageMap2_mc = new imageMap2_mc();
            public var holder1:holder_mc = new holder_mc();
            public var holder2:holder_mc = new holder_mc();
            public var holder3:holder_mc = new holder_mc();
            public var holder4:holder_mc = new holder_mc();
            public var holder5:holder_mc = new holder_mc();
            public var holder6:holder_mc = new holder_mc();
            public function mainAS():void{
                //background image
                backgroundImage.x = 0;
                backgroundImage.y = 0;
                addChild(backgroundImage);
                // holder 1
                holder1.x = 50;
                holder1.y = 30;
                addChild(holder1);
                holder1.addEventListener(MouseEvent.ROLL_OVER, holder1Fire)
                // holder 2
                holder2.x = 250;
                holder2.y = 30;
                addChild(holder2);
                holder2.addEventListener(MouseEvent.ROLL_OVER, holder2Fire)
                // holder 3
                holder3.x = 450;
                holder3.y = 30;
                addChild(holder3);
                holder3.addEventListener(MouseEvent.ROLL_OVER, holder3Fire)
                // holder 4
                holder4.x = 50;
                holder4.y = 225;
                addChild(holder4);
                holder4.addEventListener(MouseEvent.ROLL_OVER, holder4Fire)
                // holder 5
                holder5.x = 250;
                holder5.y = 225;
                addChild(holder5);
                holder5.addEventListener(MouseEvent.ROLL_OVER, holder5Fire)
                // holder 6
                holder6.x = 450;
                holder6.y = 225;
                addChild(holder6);
                holder6.addEventListener(MouseEvent.ROLL_OVER, holder6Fire)
            //Fire away
            private function holder1Fire(e:Event):void{
                trace("holder 1");
                //removeChild all remaining
               //addChild description MovieClip
              // description_mc.addEventListner(function to include rollOff Listener -- fire timer -- remove description + add original mc's)
            private function holder2Fire(e:Event):void{
                trace("holder 2");
                //removeChild
            private function holder3Fire(e:Event):void{
                trace("holder 3");
                //removeChild
            private function holder4Fire(e:Event):void{
                trace("holder 4");
                //removeChild
            private function holder5Fire(e:Event):void{
                trace("holder 5");
                //removeChild
            private function holder6Fire(e:Event):void{
                trace("holder 6");
                //removeChild

    If the main reason for adding and removing is so that only one is visible, then you can just use the visible property along with a reduction in code.  Here's a few thoughts along those lines, though not the whole deal...
    Create a function that turns all of the object visible/invisible using a loop...
    function showAll(truefalse:Boolean){
         for(var i=1; i<7; i++){
              this["holder"+String(i)].visible = truefalse;
    Then have all your object share the same rollover function....
    holder1.addEventListener(MouseEvent.ROLL_OVER, clickHolder);
    holder2.addEventListener(MouseEvent.ROLL_OVER, clickHolder);
    holder3.addEventListener(MouseEvent.ROLL_OVER, clickHolder);
    etc...
    function clickHolder(evt:MouseEvent):void {
         showAll(false);  // hide all first
         evt.currentTarget.visible = true;  // show the one being hovered
         // store the name of the description mc with the clip and call it...
         this[evt.currentTarget.desc].visible = true;

  • How to add new increase the pool rather then trowing a error.

    Im trying to build a game and after many attempts and hours of thinking i did manage to create something that looks like a game.The problem now is that there are so many objects that are constantly creating and removing from the stage. that the game is starting to slow down(it is laggy.).So i have searched the net and understood that i will have to use a "Object pooling Method" rather than creating and removing the objects after i dont have any use of them any more, if i want to make the game more memory friendly.
    At first i didnt want to use this method (object pooling) ,but after a while i understood that i dont have a lot of options.So i started to search how and why and how.
    Yet in this example im just trying this for the bullets (for now) cause if i can do it for them, i can manage to do it for other objects and projects (it will be simple for me to understand what is happening ., what am i doing , when do i add an existing object from the pool and when im creating a new one(when there are non left, things like this)
    i did copy some part of this code from a tutorial that i found in the net but , from then i dont know how to increase the pool rather than throwing this error. I did try to create a new object or to increase the pool length but .... it is not working so im sure that im not doing something the way it must be done.
    so i have this so far :
    its a "simple" pool that calls a simple shape class (circle dot) and gives that to the main stage when the "SPACE" button is pressed
    package
              import flash.display.Sprite;
              import flash.events.Event;
              import flash.display.Bitmap;
              import flash.display.BitmapData;
              import flash.display.Shape;
              public class Bullet extends Sprite{
                        public var  rectangle:Shape = new Shape();
                        public function Bullet(){
                                  super();
                                  addEventListener(Event.ADDED_TO_STAGE, init);
                                  graphics.beginFill(0xFF0000);
                                  graphics.drawRect(-5, -5, 10,10);
                                  graphics.endFill();
                        private function init(event:Event):void{
    the SpritePool where i cant figure out how to replace the throw new error with some new code that will increase the pool
    package {
              import flash.display.DisplayObject;
              public class SpritePool {
                        private var pool:Array;
                        private var counter:int;
                        public function SpritePool(type:Class, len:int) {
                                  pool = new Array();
                                  counter = len;
                                  var i:int = len;
                                  while (--i > -1) {
                                            pool[i] = new type();
                        public function getSprite():DisplayObject {
                                  if (counter > 0) {
                                            return pool[--counter];
                                  } else {
                                            throw new Error("You exhausted the pool!");
                        public function returnSprite(s:DisplayObject):void {
                                  pool[counter++] = s;
    and the Game class (the documents class)
    package {
              import flash.ui.Keyboard;
              import flash.display.Sprite;
              import flash.events.Event;
              import flash.events.KeyboardEvent;
              import flash.display.Bitmap;
              import flash.display.BitmapData;
              import flash.display.Shape;
              public class Game extends Sprite {
                        private var ship:Shape;
                        private var bullets:Array;
                        private var pool:SpritePool;
                        public function Game() {
                                  Assets.init();
                                  addEventListener(Event.ADDED_TO_STAGE, init);
                        private function init(event:Event):void {
                                  pool = new SpritePool(Bullet,10);
                                  bullets = new Array();
                                  ship = new Shape();
                                  ship.graphics.beginFill(0xFF00FF);
                                  ship.graphics.drawRect(0,0, 60, 60);
                                  ship.graphics.endFill();
                                  ship.x = stage.stageWidth / 2 - ship.width / 2;
                                  ship.y = stage.stageHeight - ship.height;
                                  addChild(ship);
                                  stage.addEventListener(KeyboardEvent.KEY_DOWN, onDown);
                                  addEventListener(Event.ENTER_FRAME, loop);
                        private function onDown(event:KeyboardEvent):void {
                                  if (event.keyCode == Keyboard.SPACE) {
                                            var b:Bullet = pool.getSprite() as Bullet;
                                            b.x = ship.x + ship.width / 2;
                                            b.y = ship.y;
                                            addChild(b);
                                            bullets.push(b);
                                            trace("Bullet fired");
                        private function loop(event:Event):void {
                                  for (var i:int=bullets.length-1; i>=0; i--) {
                                            var b:Bullet = bullets[i];
                                            b.y -=  10;
                                            if (b.y < 0) {
                                                      bullets.splice(i, 1);
                                                      removeChild(b);
                                                      pool.returnSprite(b);
                                                      trace("Bullet disposed");
    any suggestions/help how to do it

    To put you on the path (the errors/events needs formalization), here would be a quick example. Your pool class:
    package
              import flash.display.DisplayObject;
              public class SpritePool
                        private var pool:Array;
                        private var counter:int;
                        private var classRef:Class;
                        // public get to know what's left in the pool
                        public function get availableObjects():int
                                  return counter;
                        public function SpritePool(type:Class, len:int)
                                  classRef = type;
                                  pool = new Array();
                                  counter = len;
                                  var i:int = len;
                                  while (--i > -1)
                                            pool[i] = new classRef();
                        public function getSprite():DisplayObject
                                  if (counter > 0)
                                            return pool[--counter];
                                  else
                                            throw new Error("PoolExhausted");
                        public function returnSprite(s:DisplayObject):void
                                  pool[counter++] = s;
                        public function increasePool(amount:int):void
                                  counter += amount;
                                  while (--amount > -1)
                                            pool.push(new classRef());
                        public function decreasePool(amount:int):void
                                  if (counter >= amount)
                                            counter -= amount;
                                            pool.splice(counter - amount,amount);
                                  else
                                            throw new Error("PoolDecreaseFail");
    Now you'd need to be catching those errors. Again, the errors should be formalized or you could use events by extending IEventDispatcher. I kept it simple.
    Here would be the simple Bullet class I'm using:
    package
              import flash.display.Sprite;
              public class Bullet extends Sprite
                        private var bullet:Sprite;
                        public function Bullet():void
                                  var bullet:Sprite = new Sprite();
                                  bullet.graphics.beginFill(0xFF0000,1);
                                  bullet.graphics.drawCircle(-5,-5,10);
                                  bullet.graphics.endFill();
                                  addChild(bullet);
    Just draws a red circle just to visualize it..
    Here would be a full example of using it. It will import both of these classes (saved as SpritePool.as and Bullet.as in the same folder). Paste this in the actions panel on frame 1:
    import SpritePool;
    import Bullet; // a simple red 10px circle
    import flash.display.Sprite;
    import flash.utils.setTimeout;
    // fill the pool, swim trunks optional
    var pool:SpritePool = new SpritePool(Bullet, 10);
    // grab some objects from the pool
    // array of currently held objects
    var myBullets:Array = new Array();
    while (pool.availableObjects > 0)
              myBullets.push(pool.getSprite());
    // display in random positions
    for (var i:int = 0; i < myBullets.length; i++)
              addChild(myBullets[i]);
              // position
              myBullets[i].x = int(Math.random()*stage.stageWidth);
              myBullets[i].y = int(Math.random()*stage.stageHeight);
    trace("myBullets has " + myBullets.length + " bullets! pool has " + pool.availableObjects + " left.");
    // now I want one more, but I should check for errors
    try
              // fail, none left!
              myBullets.push(pool.getSprite());
    catch (e:*)
              // this should be a custom event, but for speed, quick and dirty
              if (e == 'Error: PoolExhausted')
                        trace("D'oh no more bullets! I need more!");
                        pool.increasePool(10);
                        trace("Added 10 more, now available in pool " + pool.availableObjects);
    // try to reduce the pool by 15, which should error
    try
              pool.decreasePool(15);
    catch (e:*)
              // again should be a formal error
              if (e == 'Error: PoolDecreaseFail')
                        trace("Oops, can't reduce pool by 15! Let's trim all extras, available is " + pool.availableObjects);
                        // we know it'll work, no error checking
                        pool.decreasePool(pool.availableObjects);
                        trace("Left in pool: " + pool.availableObjects);
    // now lets wait 5 seconds and remove it all back to the pool
    setTimeout(ReturnToPool,5000);
    function ReturnToPool():void
              // now let's just return all the objects to the pool
              while (myBullets.length > 0)
                        removeChild(myBullets[myBullets.length - 1]);
                        pool.returnSprite(myBullets.pop());
              // now check the pool, should have 10
              trace("Amount of bullets in use " + myBullets.length + ", in pool " + pool.availableObjects);
    For ease you can just download my example source (saved down to CS5).
    Anything from here is just symantics. For example instead of throwing an error because the pool is too small you could simply increase the pool by a fixed amount yourself and return the objects requested.
    To keep objects as low as possible you could use a timer to measure the amount of objects in use over a duration and reduce the pool appropriately, knowing the pool will grow as it needs.
    All of this is just to avoid unnecessary object creation.
    BTW here's my trace which should match yours:
    myBullets has 10 bullets! pool has 0 left.
    D'oh no more bullets! I need more!
    Added 10 more, now available in pool 10
    Oops, can't reduce pool by 15! Let's trim all extras, available is 10
    Left in pool: 0
    (after 5 seconds)
    Amount of bullets in use 0, in pool 10

  • Target movieclip from an AS3 class file - remove/add Child

    Halo.
    I have a very simple question  (for those who use external class files).
    Assuming that I have a MovieClip manually added to Stage and I want to access it from inside my class definiton.
    So the code would be:
    MovieClip(root).MyMovieClip
    But I can't figure out how to use remove/add Child in that kind of situation.
    I will appreciate any advice.
    Thanks

    if you can reference using that, you can remove using:
    MovieClip(root).MyMovieClip.parent.removeChild(MovieClip(root).MyMovieClip);
    and you can add to any displayobjectcontainer.

  • Using variables to add and subtract a number in a text field?

    The adding bit works fine:
    // get this pconn count
    var this_p_conn:Number = Object(this).parent.p_conn;
    // get current pconn total
    var c_this_p_conn:Number = Object(root).part_count.p_conn_count.text    
    // add this pconn count to total pconn
    var v_this_p_conn:Number = Number(this_p_conn+c_this_p_conn);
    // Update total pconn with new value
    Object(root).part_count.p_conn_count.text = String(v_this_p_conn)
    Removing a value from the total is another story, this looks like it should work but it does not:
    // get this pconn count
    var count_p_conn:Number = Object(this).parent.p_conn;
    // get current pconn total
    var total_p_conn:Number = Object(root).part_count.p_conn_count.text;
    // subtract this pconn count from total pconn
    var new_p_conn:Number = Number(total_p_conn-count_p_conn);
    // Update total pconn with new value
    Object(root).part_count.p_conn_count.text = String(new_p_conn);
    Any ideas or suggestions? My eyes are a bit blurry from looking at code, maybe I missed something obvious. Thanks in advance!

    Never mind, I got it worked out now.
    I had the subtraction code firing AFTER my remove self code, so the player never got to fire the subtract code:
    var b:MovieClip = Object(this).parent;
    Object(this).parent.parent.removeChild(b);
    I placed the subtract code before the above code and now it works fine... I think I need powernap...
    The lesson here is that apparently code fires from the top to the bottom, mind the order of how your code is stacked.
    Sorry for the fuss! Carry on.

  • How do I do to add and remove Shape3D objects dynamically from TransfGroup?

    Hi, everyone,
    How do I do to add and remove Shape3D objects dynamically from TransformGroup?
    I have added two Shape3D objects in the TransformGroup and I wanted to remove one of it to add another. But, the following exception occurs when I try to use �removeChild� :
    �Exception in thread "AWT-EventQueue-0" javax.media.j3d.RestrictedAccessException: Group: only a BranchGroup node may be removed at javax.media.j3d.Group.removeChild(Group.java:345)�.
    Why can I add Shape3D objects and I can�t remove them? Do I need to add Shape3D object in the BranchGroup and work only with the BranchGroup? If I do, I think this isn�t a good solution for the scene graph, because for each Shape3D object I will always have to use an associated BranchGroup.
    Below, following the code:
    // The constructor �
    Shape3D shapeA = new Shape3D(geometry, appearance);
    shapeA.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
    shapeA.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
    shapeA.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
    shapeA.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
    Shape3D shapeB = new Shape3D(geometry, appearance);
    shapeB.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
    shapeB.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
    shapeB.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
    shapeB.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
    BranchGroup bg = new BranchGroup();
    bg.setCapability(ALLOW_CHILDREN_READ);
    bg.setCapability(ALLOW_CHILDREN_WRITE);
    bg.setCapability(ALLOW_CHILDREN_EXTEND);
    TransformGroup tg = new TransformGroup();
    tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    tg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
    tg.setCapability(TransformGroup.ALLOW_CHILDREN_READ);
    tg.setCapability(TransformGroup.ALLOW_CHILDREN_WRITE);
    bg.addChild(tg);
    tg.addChild(shapeA);
    tg.addChild(shapeB);
    // The method that removes the shapeB and adds a new shapeC �
    Shape3D shapeC = new Shape3D(geometry, appearance);
    shapeC.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
    shapeC.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
    shapeC.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
    shapeC.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
    tg.removeChild(shapeB);
    tg.addChild(shapeC);Thanks a lot.
    aads

    �Exception in thread "AWT-EventQueue-0"
    javax.media.j3d.RestrictedAccessException: Group:
    only a BranchGroup node may be removed I would think that this would give you your answer -
    Put a branch group between the transform and the shape. Then it can be removed.
    Another thing you could try: This doesn't actually remove the shape, but at least causes it to hide. If you set the capabilities, I think you can write the appearance of the shapes. So, when you want to remove one of them, write an invisible appearance to it.

  • Action script 3 question: addChild and removeChild on same button??

    I'm trying to make a button that when u click once, the movieclip will be removed and second time back on stage and so forth....
    somehow i get this error
    ==================================
    ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
    at flash.display:DisplayObjectContainer/removeChild()
    at sample_fla::MainTimeline/btnClick()
    ==================================
    Anyone can help me with this, since I'm doing an interactive web for client and the deadline is near..... thanks in advance.
    these are my code:
    stop();
    var swf:MovieClip;
    var loader:Loader= new Loader();
    var defaultswf:URLRequest= new URLRequest("./newSwfImport.swf");
    //default swf when loaded
    loader.load(defaultswf);
    //add to stage
    allSwfLoadHere.addChild(loader);
    var boolean:Boolean = true ;
    function btnClick(event:MouseEvent):void {
    if(boolean == true){
    allSwfLoadHere.removeChild(loader);
    boolean == false
    if(boolean ==false){
    allSwfLoadHere.addChild(loader);
    boolean == true
    newSwfImport.addEventListener(MouseEvent.CLICK,btnClick);

    you have, at least, two errors:
    1.  you failed to use an if-else and
    2.  when trying to re-assign your boolean, you tested.  ie, you used == when you should use =.  so, your boolean remains true.  then when you execute the 2nd time, you try and remove something that's already been removed.
    use:
    var swf:MovieClip;
    var loader:Loader= new Loader();
    var defaultswf:URLRequest= new URLRequest("./newSwfImport.swf");
    //default swf when loaded
    loader.load(defaultswf);
    //add to stage
    allSwfLoadHere.addChild(loader);
    var boolean:Boolean = true ;
    function btnClick(event:MouseEvent):void {
    if(boolean){
    allSwfLoadHere.removeChild(loader);
    } else {
    allSwfLoadHere.addChild(loader);
    boolean=!boolean;
    newSwfImport.addEventListener(MouseEvent.CLICK,btnClick);

  • RemoveChild issue

    Hi All,
    Got this code loading thumbs, and when their clicked loads a
    bigger image etc...
    function xmlLoaded (e:Event):void {
    xml = XML(e.target.data);
    images = xml.image;
    for(var i:uint=0; i<images.length();i++){
    var thumb:MovieClip = new MovieClip();
    var thumbLoader:Loader = new Loader();
    thumb.x = 65*i + spacing;
    thumb.y = 370;
    thumb.src = images[counter].@url;
    thumb.mouseChildren = false;
    thumb.buttonMode = true;
    thumbLoader.load(new URLRequest(images[counter].@thumb));
    addChild(thumb);
    thumb.alpha = 0;
    TweenMax.to(thumb, 1, {alpha:1, ease:Sine.easeIn});
    thumb.addChild(thumbLoader);
    thumbLoader.x = 24;
    thumbLoader.y = -14;
    thumb.addEventListener(MouseEvent.CLICK, clickedThumb);
    counter++;
    loader.load(new URLRequest(images[0].@url));
    Problem happens with the following code - I go into
    fullScreen and want to either hide the thumb etc... or remove it:
    masker.addEventListener(MouseEvent.CLICK, fullScreen);
    function fullScreen(MouseEvent):void
    thumb.visible = false; // do not work
    removeChild(thumb); // do not work
    stage.displayState = StageDisplayState.FULL_SCREEN;
    masker.x=0;
    masker.y=0;
    masker.width=stage.stageWidth;
    masker.height=stage.stageHeight;
    StageScaleMode.NO_SCALE;
    stage.align = StageAlign.TOP_LEFT;
    masker.buttonMode = true;
    Hope someone can provide an answer to this, as it's driving
    me BONKERS ;) It's got to be down to how I am referring to it, the
    path.
    Kind Regards,
    Boxing Boom

    I can see a few possible problems. One is that if you want to
    reference a variable you create from multiple functions it needs to
    be declared outside both functions. Such as reference 1 below.
    Another is if you are creating many objects creating the same
    variable you should add them to an array to be able to access them
    later as below in reference 2.
    Note sure if these may help, but thought I would throw them
    out there.

  • Weird add/remove child layout behavior

    I'm trying to build an an app that allows the user to toggle
    certain panels on and off. These panels are in Divider containers.
    It seems that at startup, when I remove and add a panel flex
    doesn't properly validate layout. For example 2 panels are added to
    a VDivided container. I then call removeChild on the second panel
    (at the bottom of the container), and the first panel then properly
    occupies all the visible space. When I add the second panel back,
    it is re-added but has not retained its original size and is
    instead compressed at the bottom. If I then remove the top panel
    and add it again, then remove the bottom panel and add it,
    everything works as I expect. It's almost like their is a one-time
    initialization not occurring somewhere. Here is the code sample I
    am using to demonstrate the problem:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute" width="1000" height="800">
    <mx:VBox height="100%" top="0" left="0" right="0">
    <mx:ApplicationControlBar x="0" y="0" width="100%"
    height="58">
    <mx:CheckBox label="Panel 1" id="panel1CheckBox"
    selected="true" click="modifyViewPanel1()"/>
    <mx:CheckBox label="Panel 2" id="panel2CheckBox"
    selected="true" click="modifyViewPanel2()"/>
    </mx:ApplicationControlBar>
    <mx:VDividedBox x="0" y="0" width="100%" height="90%"
    id="vDivideBox">
    <mx:Panel width="100%" height="50%" layout="vertical"
    title="Panel 1" id="panel1">
    </mx:Panel>
    <mx:Panel width="100%" height="50%" layout="vertical"
    id="panel2" title="Panel 2">
    </mx:Panel>
    </mx:VDividedBox>
    </mx:VBox>
    <mx:Script>
    <![CDATA[
    private function modifyViewPanel1():void {
    trace("modifyView...");
    if (panel1.parent) panel1.parent.removeChild(panel1);
    if (panel1CheckBox.selected) {
    vDivideBox.addChildAt(panel1, 0);
    private function modifyViewPanel2():void {
    trace("modifyView...");
    if (panel2.parent) panel2.parent.removeChild(panel2);
    if (panel2CheckBox.selected) {
    vDivideBox.addChildAt(panel2,
    vDivideBox.getChildren().length);
    ]]>
    </mx:Script>
    </mx:Application>

    The properties you set with MXML tags are the initial values,
    they aren't used to reset the controls. They would have to be
    dynamic properties like width="{comp1.width/2}" for them to change
    as the program runs. Setting a component's width to "50%" just
    means it will initially be calculated to have 50% of the width of
    its parent. As the program runs the component's width can change
    which it what's happened.
    Removing a child only removes the component from the parent's
    display list. The component still exists and adding it back causes
    the parent to recalculate its layout. This means it may change the
    size of the children.
    You have a couple of choices. You can give the Panel a
    minHeight and the Divider will respect that. Or you can calculate
    the Panel's height, set it to that value, then add it back to the
    Divider.

  • Clone Rows - Tabular form - Client side add rows

    Hello all,
    I feel in love with this particular Tabular form, http://htmldb.oracle.com/pls/otn/f?p=24317:49 because of the Capabilities it has to create a "clone row".
    a very advance feature I like a lot.
    The trouble is when I go under >Report> and select which columns I would like to view, some will be hidden with default values.
    the default values I would like to keep hidden are: a Time Stamp, and :APP_USER.
    So when the user decides to clone a row the first original row will stay intact with all the information including the hidden values, but as for the cloned rows the hidden values are missing.
    Is there something missing in the javascript that permits this from happening?
    Please Help.
    <script type="text/javascript">
    var g_this;
    function fn_delete(pThis)
    var l_tr=$x_UpTill(pThis,'TR');
    l_tr.parentNode.removeChild(l_tr);
    function fn_CloneRow(pThis){
    g_this=pThis;
    l_tr=$x_UpTill(pThis,'TR');
    l_table=$x_UpTill(l_tr,'TABLE');
    l_tbody=$x_UpTill(l_tr,'TBODY');
    l_clone=l_tr.cloneNode(true);
    html_RowHighlight(l_clone,"D0D0E0");
    l_inputs=l_clone.getElementsByTagName('input');
    for (var j=0;j<l_inputs.length;j++) {
    l_this=l_inputs[j];
    if (l_this.type=="hidden") l_this.value="";
    if (l_this.name=="fcs") l_this.value="zzzz";
    if (l_this.type=="checkbox") l_this.parentNode.removeChild(l_this);
    // Change Clone functionality to Delete
    var l_img=l_clone.getElementsByTagName('img')[0];
    l_img.src="/i/delete.gif";
    if (document.all) l_img.onclick=function(){fn_delete(this)};
    else l_img.setAttribute("onclick","fn_delete(this)");
    l_tbody.insertBefore(l_clone,l_tr.nextSibling?l_tr.nextSibling:l_tr);
    </script>

    I have't looked at the specific clone-row sample code you mentioned in your post, but just wanted to point out that we've introduced client-side add-row functionality in APEX 4.0, so if you're using this code to add new rows on the client-side, then using the built-in functionality might be easier. Of course if you actually want to get a copy of an existing row, that might not be sufficient. As for the MRU process, the way APEX identifies new rows is by looking at the primary key or ROWID column value, which needs to be NULL. APEX also looks at the apex_application.g_fcud array, which holds information for each row on whether to do an create, update or delete. This array was introduced in APEX 4.0, and that's what could potentially be causing your example to fail after the upgrade.
    Regards,
    Marc

  • Help with removeChild or another solution

    I am a beginner to actionscript 3 and I've been working on a portfolio gallery in Flash that swaps XML images on click of a thumbnail.  Currently everything works well but the images stack on each other and I want them to switch on click.  I have searched all over the Internet trying to troubleshoot but the typical fix of
    if(lArtLoader)
    {artImageL.removeChild(lArtLoader)}
    doesn't work.
    Can someone please guide me in the right direction? Below is my code. Thank you so much for any help.
    var artTitle:Array = new Array();
    var artDescription:Array = new Array();
    var artLargeImage:Array = new Array();
    var artThumbnailImage:Array = new Array();
    var artImageNum:Number = 0;
    var maxImages:Number;
    //LOAD XML
    var artXMLURLLoader:URLLoader = new URLLoader();
    artXMLURLLoader.load(new URLRequest("portfolio/art.xml"));
    artXMLURLLoader.addEventListener(Event.COMPLETE, artProcessXML);
    function artProcessXML(event:Event):void
         var artXMLData:XML = new XML(artXMLURLLoader.data);
         maxImages = artXMLData.title.length();
         for (var i:Number = 0; i < maxImages; i++)
              artTitle.push(artXMLData.title[i]);
              artDescription.push(artXMLData.description[i]);
              artLargeImage.push(artXMLData.largeImage[i]);
              artThumbnailImage.push(artXMLData.thumbImage[i]);
         loadArtThumb();
    artThumbSrol.source = artThumbBox;
    //LOAD THUMBNAILS
    function loadArtThumb():void
         var sArtLoader:Loader = new Loader();
         sArtLoader.load(new URLRequest(artThumbnailImage[artImageNum]));
         sArtLoader.x = 137 * artImageNum;
         //STORE INFO IN THUMBNAILS
         var lArtLoader:Loader = new Loader();
         lArtLoader.load(new URLRequest(artLargeImage[artImageNum]));
         var thisTitle:String = artTitle[artImageNum];
         var thisDescription:String = artDescription[artImageNum];
         sArtLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, artThumbLoaded);
         function artThumbLoaded(event:Event):void
              //ADD THUMBNAIL
              artThumbBox.addChild(sArtLoader);
              artThumbBox.buttonMode = true;
              artThumbSrol.update();
              sArtLoader.addEventListener(MouseEvent.CLICK, artLoadMainImage);
              function artLoadMainImage(event:MouseEvent):void
                   //ADD LARGE IMAGE AND TEXT, SHOULD SWAP ON THUMBNAIL CLICK
                   artImageL.addChild(lArtLoader);
                   artHeadL.text = thisTitle;
                   artTextL.htmlText = thisDescription;
                   artTextL.wordWrap = true;
         artImageNum++;
         if (artImageNum < maxImages)
              loadArtThumb();

    In this function:
    function artLoadMainImage(event:MouseEvent):void
                   //ADD LARGE IMAGE AND TEXT, SHOULD SWAP ON THUMBNAIL CLICK
                   artImageL.addChild(lArtLoader);
                   artHeadL.text = thisTitle;
                   artTextL.htmlText = thisDescription;
                   artTextL.wordWrap = true;
    you are taking whatever is in lArtLoader and adding it to artImageL as a new child object. So with every new click you are slapping down a new image on top of whatever is already there. To get rid of any existing child objects just look at what's in artImageL and toss it out before you put in anything new. It might look something like this:
    function artLoadMainImage(event:MouseEvent):void
                   //ADD LARGE IMAGE AND TEXT, SHOULD SWAP ON THUMBNAIL CLICK
                   if(artImageL.numChildren > 0) {
                        artImageL.removeChildAt(0);
                   artImageL.addChild(lArtLoader);
                   artHeadL.text = thisTitle;
                   artTextL.htmlText = thisDescription;
                   artTextL.wordWrap = true;

  • HOW TO remove nodes add nodes dynamically create objects branchgroup

    After much trial and error, frustration and reading this forum I have come across a good way to dynamically add/remove objects. This is working in my model with 1.3 and jdk 1.4.1_02 Sorry if its sloppy.
    Here goes:
    Adding objects (cap bits may not be optimised):
    (A)
    BranchGroup newDynObj = null;
    switch (workerType)
    case 1: //create a rawEntry BranchGroup
    newDynObj = new RawEntry();
    break;
    case 2: //create a Finshed Node
    newDynObj = new FinishedNode();
    break;
    default:
    newDynObj.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND);
    newDynObj.setCapability(BranchGroup.ALLOW_DETACH);
    newDynObj.setCapability(Group.ALLOW_CHILDREN_READ);
    newDynObj.setCapability(Group.ALLOW_CHILDREN_WRITE);
    Transform3D t = new Transform3D();
    t.set(scale, new Vector3d(xpos, ypos, zpos));
    TransformGroup objTrans2 = new TransformGroup(t);
    objTrans2.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    objTrans2.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
    objTrans2.setCapability(TransformGroup.ALLOW_CHILDREN_READ);
    objTrans2.setCapability(TransformGroup.ALLOW_CHILDREN_WRITE);
    objTrans2.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND);
    Sphere obj = new Sphere(1.0f, Sphere.GENERATE_NORMALS | Sphere.GENERATE_TEXTURE_COORDS,
    5, app);
    //add to scene graph
    objTrans2.addChild(obj);
    newDynObj.addChild(objTrans2);
    newDynObj.compile();
    return newDynObj;
    call this ftn with:
    Space3DPanel.objTrans.addChild(createObject(createAppearance(workerType), 0.04, x, y, z, 2)); where objTrans is your tansformGroup
    Removing branchgroup:
    Its easy to add. But the trick is to delete/remove these !?! Detach doesnt seem to do anything. The method/pattern that works for me is to..
    1. make a new class subclassing BranchGroup like this:
    public class FinishedEntry extends BranchGroup
    { private String type;
    public FinishedEntry(){  }
    public FinishedEntry(String type)
    { this.type = type; }
    and
    public class RawEntry extends BranchGroup
    private String type;
    public RawEntry(){  }
    public RawEntry(String type)
    { this.type = type;}
    2. To when adding the BG to the TG of the parent (objTrans)
    add a BG of the type you subclassed.
    see (A) above.
    3. Now scan through the children of the TG that you have been adding these children to. Like this:
    static synchronized public void removeNodeFromModel(int workerType)
    try {
    switch (workerType)
    case 1: //raw Entry
    for (int i = 0; i < Space3DPanel.objTrans.numChildren(); i++)
    if (Space3DPanel.objTrans.getChild(i) instanceof RawEntry)
    Space3DPanel.objTrans.removeChild(i);
    break;
    break;
    case 2: //result Entry
    for (int i = 0; i < Space3DPanel.objTrans.numChildren(); i++)
    if (Space3DPanel.objTrans.getChild(i) instanceof FinishedNode)
    Space3DPanel.objTrans.removeChild(i);
    break;
    } //end for
    break;
    default:
    } catch (Exception e) { e.printStackTrace(); }
    The main idea is to use instanceof !! then use removeChild (see above).. Also, you can compile your BGs using this method.
    Thanks for the great forum!
    Jacob Pyrett
    [email protected]

    First, to add child nodes to a branch group, you must follow two rules:
    (1) The child you are adding to the branch group is also a BranchGroup
    (2) The BranchGroup.ALLOW_CHILDREN_EXTEND capability is set
    From here, you are able to add children on the fly.
    To remove a child from the branch group was harder to figure out, but I eventually got it to work. To accomplish this you must do the following:
    (1) have the capability BranchGroup.ALLOW_DETACH) set on the child BranchGroup you wish to remove.
    (2) call the child's detach() method rather than calling the parent's removeChild()
    Hope this helps.

  • Trouble unloading jpeg with unload() or removeChild()

    Hi Everyone,
    I'm working on a project that is like a jigsaw puzzle.  The use can select from a few different puzzles that have different piece arrangements.  Once the puzzle swf file is loaded, the user can select images from a gallery to place in the pieces to make a custom puzzle where the puzzle piece movie clip that was selected masks the image that was selected.
    So the puzzle swf loads fine and I add it to the stage with:
    addChild(puzzle);
    The jpegs also load and get masked correctly.  When I add the jpeg image, I add it to the puzzle object and the addChild looks like this:
    puzzle.addChild(imageJPEGLoader);
    imageJPEGLoader.load(new URLRequest(imageJPEGName));
    imageJPEGLoader.x = 0;
    imageJPEGLoader.y = 0;
    imageJPEGLoader.mask = puzzle.maskPiece1_mc;
    Where imageJPEGLoader is the loader I use to get the jpeg image.
    Everything works great.  However, if the user wants to change the image used, I want to remove the child (right?).
    I thought this would work:
    puzzle.removeChild(imageJPEGLoader);
    but it doesn't.  I get the following error:
    ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
    at flash.display::DisplayObjectContainer/removeChild()
    at puzzle.fla::MainTimeline/getImage()
    I think I'm obviously not understanding the parent/child relationship fully.  I thought if imageJPEGLoader was inside puzzle, that the dot syntax would get me to the object I needed.  Everything works fine in this file except for putting a new jpeg on a piece that already had a jpeg masked.
    Can someone please point me in the right direction?

    Can you show all of the relevant code as it is arranged in your file (functions, etc)?

Maybe you are looking for

  • One apple ID could install how many computer?

    If i purchase new mountian, Could I install 4 computers - all belong to same family.

  • No RFC Authorization for user

    Hi I am trying to develop a report, with screeen painter, using 4.6c version. when i click on Layout editor , it doesnt show the screen from where I can drag and drop......and gives the message No RFC autorization for user. I havent worked on 4.6c. d

  • Is there a way to get a digest mode of this forum?

    I was curious.. I see more traffic on here lately than flex coders (I think), and i like to see the topics as they come through (in case I can pick up new knowledge, etc). So there is the option to subscribe to all (to come in via email), but I was w

  • When are we getting the latest update?

    Just like any update there isn't an specific release date for each country/network http://www.sonymobile.com/global-en/software/phones/xperia-z1-compact/ Latest available software You may already have the latest software, depending on the date of pur

  • Segments in a file

    Hi all, What do you mean by Segments in a file  ? What is the difference Between Record and  a Segment ? General definition of a File is : file is a group of records and Record is a group of  fields.....right ? Thanks in advance Krish...