Checking to see if a Child has been added, before adding

Hey folks,
I'm working on building a gallery, but I've run into a slight snag. The full-size images are not all the same size, so they will overlap when loaded. In the showPicture function, is there a way for it to check to make sure there isn't a full-size image already loaded, and if there is, to remove it before adding the new one? Any help would be appreciated. Thanks!
var imageLoader:Loader;
var xml:XML;
//parse XML data as an array
var xmlList:XMLList;
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.load(new URLRequest("data/gallery.xml"));
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
function xmlLoaded(event:Event):void {
    xml = XML(event.target.data);
    //parse the nodes in the XML file
    xmlList = xml.children();
    //count the number of nodes in the XML file via XMLList
    trace(xmlList.length());
    //loop to load all of the thumbnails, based on the number of nodes in XMLList
    for(var i:int = 0; i < xmlList.length(); i++) {
        imageLoader = new Loader();
        imageLoader.load(new URLRequest(xmlList[i].attribute("thumb")));
        //position thumbs horizontally across stage
        imageLoader.x = i * 110 + 10; //thumbs are 100 x 100 so, +10 to the width, plus +10 from left edge
        imageLoader.y = 10;
        imageLoader.name = xmlList[i].attribute("source");
        addChild(imageLoader);
        //set up thumbs to load primary image on click
        imageLoader.addEventListener(MouseEvent.CLICK, showPicture);
function showPicture(event:MouseEvent):void {
    imageLoader = new Loader();
    imageLoader.load(new URLRequest(event.target.name));
    //position full image below the row of thumbs
    imageLoader.x = 110;
    imageLoader.y = 130;
    addChild(imageLoader);

Oy..I'm an idiot. I realized that all I needed was a second loader to handle the full-size images and simply unload it prior to pulling in the new image. Here's the completed and fixed code:
import flash.display.*;
var imageLoader:Loader;
var fullLoader:Loader = new Loader;
var xml:XML;
//parse XML data as an array
var xmlList:XMLList;
var xmlLoader:URLLoader = new URLLoader();
var imgFrame:MovieClip = new MovieClip();
xmlLoader.load(new URLRequest("data/gallery.xml"));
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
function xmlLoaded(event:Event):void {
    xml = XML(event.target.data);
    //parse the nodes in the XML file
    xmlList = xml.children();
    //count the number of nodes in the XML file via XMLList
    trace(xmlList.length());
    //loop to load all of the thumbnails, based on the number of nodes in XMLList
    for (var i:int = 0; i < xmlList.length(); i++) {
        imageLoader = new Loader();
        imageLoader.load(new URLRequest(xmlList[i].attribute("thumb")));
        //position of thumbs (horizontally across stage)
        imageLoader.x = i * 110 + 10;//thumbs are 100 x 100 so, +10 to the width, plus +10 from left edge
        imageLoader.y = 10;
        imageLoader.name = xmlList[i].attribute("source");
        //add thumbnails to stage
        addChild(imageLoader);
        //set up thumbs to load primary image
        imageLoader.addEventListener(MouseEvent.CLICK, showPicture);
function showPicture(event:MouseEvent):void {
    fullLoader.unload();
    fullLoader.load(new URLRequest(event.target.name));
    //position full image below the row of thumbs and center to stage
    imgFrame.x = (stage.stageWidth - imgFrame.width) * 0.5;
    imgFrame.y = (stage.stageHeight - imgFrame.height) * 0.5 + 130;
    imgFrame.addChild(fullLoader);
    addChild(imgFrame);

Similar Messages

  • Is there a way to check to see if an IMEI has been submitted for unlock?

    I wanted to ask is there is any way to check IMEI numbers to see whether or not they have been submitted to Apple for an unlock??
    I have two phones I need to check, and iPhone 4 which is my daughters and was a birthday present, and an iPhone 5 which is mine. Both are NOT blacklisted, barred, reported lost or stolen, both are legitimate phones.
    The iPhone 4 was paid for in full 3 weeks ago, and is locked to VODAFONE UK. The company told me 1-3 days, three weeks later, nothing, and all I get from them now is "we will email you when its been done"
    The iPhone 5 is locked to Orange/EE UK, this again was done three weeks ago, but directly through ORANGE, who tell me the unlock request has been submitted, and it is imminent but then they have me a "HOW TO" of how to unlock it, and told me this has to be done this way or it wont work??
    Here is what they told me I had to do they sent this via email
    Please find the process for unlocking your Apple handset:- 
    Before attempting the procedure, please take a moment to read the following information. Please make sure that your iphone is up to date the latest software version. This can be checked by connecting your device to iTunes via a PC/Mac/Laptop.
    Please be aware that if you have used an unauthorised unlock on your Apple device then Orange cannot be held responsible for any errors that may occur, as this procedure will not only be unsuccessful, it may damage the device. If you have modified the software please update with the latest Apple approved version.
    Apple devices differ from all other manufacturers in that there is no code required to enter into your device to unlock it. However Orange have requested on your behalf to Apple that your device be prepared for unlock and the procedure below advises how you can complete this process. Only handset’s that have been requested to be unlocked viaOrange or other networks can be unlocked this way and the below instruction will not work another Apple devices.
    Apple Unlock Procedure
    1)Insert a non-T-mobile 3G SIM card. This must be a network provider who also supplies the iphone/ipad.
    2)Switch ON the handset.
    3)Connect to iTunes using USB cable
    4)Use the “restore” option within iTunes (located at the bottom of iTunes not the top)
    5)The handset may then display: USB cable and iTunes icon.
    6)Disconnect from USB then re-connect
    7)Synchronise device with iTunes
    8)Once synchronised a message will appear on iTunes stating “Congratulations, your iPhone has been unlocked” If using IOS5 this message will not show
    9)Follow on screen set up instructions to enable new carrier settings
    Your handset should now be successfully unlocked
    Should this not show, please keep other network 3G sim in the iphone and restore the iphone via iTunes making sure all data is backed up first.
    You can also get some self help tips, please put the following into Google and search; support.apple.com/kb/TS3198
    Regards
    If anyone has any idea, please let me know, its driving me mad lol, two iphones, both not working

    Unfortunately, many carriers "drag their feet" when it comes to processing iPhone unlock requests. All Apple does is add the phone's IMEI number to the officially unlocked database, and Apple does this immediately. The breakdown is with your carrier.
    You can call AppleCare, they'll be able to tell you whether the IMEI number is in the database or not.

  • How can I check to see if my software has been registered?

    After a recent hardware replacement I am unable to find my Aperture 2 download. I never used it anyway so i'm not concerned but would like to be able to pass it on if it can be, is this possible? How can I check to see if I even registered it? I have the original packaging and all contents including Serial numbers, support ID, and four software coupons for updates. I am a bit technophobe, sorry!
    So,
    1. How can I check to see if it was registered correctly?
    2. Can someone else use the software?
    Hope someone can help.

    You don't need to check registration. In the Apple world registering software really doesn't have much of a purpose.
    If the software was bought on DVD and you have the serial number you are free to give it or sell it to anyone you wish.  Just keep in mind that Aperture 2 is very old and while it (sort of) works on the newer OS's it really isn;t a good solution for anyone serious about using Aperture. 
    It would be OK for someone with older hardware that is unable to upgrade past Snow Leopard but for anyone with newer hardware it would be a mistake to use.

  • CP5 Checking to see if a slide has been viewed between projects

    Honestly, I'm not the one thinking of some of my questions......
    Here is the scenario.  We have a course made up of lessons that have been aggregated together.  This course has an Intro, X number of lessons and a Completion.  In the Intro there is a legal disclaimer.  In each of the lessons there is the same legal disclaimer incase they are ever used individually used somewhere else.  The question is, is there some advanced action that can be written that says if the student has viewed the disclaimer in the intro then it won't be visible in the lessons that are aggregated with that Intro.  If the lessons are used elsewhere the disclaimer is visible.
    Well I hope that is clearer than mud.
    Thank you,
    Susan

    Susan,
    Bit late and I'm still struggling with jetlag. Some ideas: you'll have to transfer information from one file to another (user variable), in this case from the intro file to all the others. Michael Lund (cpguru) has a Save&Load Data widget that could be used for that case. Once you have the variable in the file you can use a conditional action to jump over the disclaimer if the variable is set to 'viewed' (or to what you want) in each of the other files.
    Lilybiri

  • Is it possible to check to see if a sequence has been called, or is run by a user?

    I'd like a subsequence to be called, but I'd like the Sequence to run differently if it is called versus run by a user.
    What statement should I use and is this even possible?
    Thanks.

    How would the user run the sequence by itself?  Are talking about interactive mode?
    If Runstate.Caller returns NULL, or Nothing in TestStand.  Then you have an interactive execution, i.e. the sequence was not called by anything.
    Thanks,
    jigg
    CTA, CLA
    teststandhelp.com
    ~Will work for kudos and/or BBQ~

  • Checking to see if a document has a digital signature

    Hello,
    I have created a stand alone static PDF document using the Designer 7.0.
    I have some code that checks the document to ensure the proper data fields have been filled out before the user can sign the form. After signing the form the, the user is supposed to click a submit button where 2 things happen, first the data is sent for processing (do not the the digital signature info here) and second a copy of the PDF is save for archiving purposes (with digital signature).
    What I need to know is how do I verify the digital signature field is not null or empty?
    If I check its raw value, before and after are the same (null or empty even thought I can see that the form has been signed by looking at the screen). If I used the signatureInfo functions available in professional, I get a security violation error. The form is filled out using Adobe Reader and the forms have digital signature right added via the Reader Extensions v6.0.
    Any help is greatly appreciated.
    Thanks
    Ben

    Hi Ben, First advice is upgrade to designer 7.1. There are major improvements in the stability of designer. 7.0 kept crashing on me constantly.
    I created a little function which should help you out.
    function isSigned(sigField){
    var oState = event.target.getField(sigField).signatureInfo().status;
    /* if (oState == -1)
    //app.alert("Not a signturefield");
    else if (oState == 0)
    //app.alert("Signature is Blank");
    else if (oState == 1)
    //app.alert("Unknown Status");
    else if (oState == 2)
    //app.alert("Signature is invalid");
    else if (oState == 3)
    //app.alert("Sig of Document is valid, identity of signer could not be verified");
    else if (oState == 4)
    //app.alert("Sig of Document is valid, identity of signer is valid");
    else
    //app.alert("Value was " + oState); */
    return oState;
    You need to pass this function the fully qualified SOM so if the signature field is in form.subform.page1.sigField you would call it like this isSigned("form[0].subform[0].page1[0].sigField[0]").
    Good luck.

  • Is there a way to find out how long my child has been playing with my ipad

    Is there a way to find out how long my child has been playing with my ipad???  He has been getting up before me in the morning and in the evening he is super tired and I'm wondering how early he has been getting up????

    No way to see exactly how long the iPad has been used but you may want to consider using parental controls.
    iOS: Understanding Restrictions (parental controls)

  • HT2397 How can I check what region my Macbook pro has been set at.

    How can I check what region my Macbook pro has been set at?

    It will have been set for the region in which it was purchased.
    http://support.apple.com/kb/HT2397
    Once you have set the region in DVD Player five times it cannot be changed. However see tis also:
    http://support.apple.com/kb/TA25416?viewlocale=en_US&locale=en_US
    Instead, use VLC to view videos from different regions:
    http://www.videolan.org/vlc/download-macosx.html

  • I am having trouble with the email that is confirming my security questions, it says it has sent it to my gmail but i have checked the email account and nothing has been sent, i have waited 24 hours for it and still nothing

    i am having trouble with the email that is confirming my security questions, it says it has sent it to my gmail but i have checked the email account and nothing has been sent, i have waited 24 hours for it and still nothing.

    Hi Cara154,
    If you are having issues receiving the email verification for your security questions, you may find the following article helpful:
    When you provide a rescue email address during Apple ID creation, you will receive an email from Apple to verify that the email address provided is accurate. If you don't see an email from Apple asking you to verify your rescue email address, you may want to check your SPAM folder. If you still haven't received the email from Apple, you can sign in to My Apple ID (appleid.apple.com) to resend your rescue email address. To resend your verification email, click on Password & Security. Then, click the Resend link located in the Rescue Email Address section.
    Apple Support: Rescue email address and how to reset Apple ID security questions
    http://support.apple.com/kb/ht5312
    Regards,
    - Brenden

  • How do I check to see if my mac has spyware

    How do I check to see if my mac has spyware?

    Macs are not currently affected by Spyware, they have excellent security built into them. However there has been a recent Trojan attack. If you are running 10.6.7 run Software Update. I'd also recommend reading Viruses by Thomas Reed.

  • How can I see that a file has been sent for workflow?

    How can I see that a file has been sent for workflow?
    During the workflow phase, the file is locked for workflow. But when the file has been approved (or denied) it will have the same status as it did before the workflow process (unless you trigger the workflow by changing its location).
    You can see the workflow history in the "My Request" view, but this way of determining whether a file has been approved seems complicated.
    Best regards
    Magnus

    Hi,
    Thanks for the transaction code, but my question is not answered yet.
    For example, I use STMS_IMPORT in the Development environement to see the list of the transport that has been made in that environement.
    I now have a list of these transports, with a status. But I wanna know if that transport that has been created in the Development environement has been moved to the Sandbox environement.
    STMS_IMPORT shows me only the list of transports that has been created in that environement. It doesn't tell me if a transport in DVL has been moved in the QAS, SANDBOX or PRODUCTION environment.
    Thanks again,
    Julien

  • How do I get to a second and subsequent pages of this forum so I can check to see if my question as been answered?

    How do I get to a second and subsequent pages of this forum so I can check to see if my question as been answered?  Or will a recent reply (if any) appear at or near the top of a new page when I open the site?

    Click on 'Your Stuff' above; this will provide quick access to your profile and other information.
    (75885)

  • How to check the last time a package has been compiled?

    How to check the last time a package has been compiled from sqlplus?

    LAST_DDL_TIME column in DBA_OBJECTS.

  • I downloaded the latest version of Adobe Reader (11.0.07) and installed it. Message said install successful. But APEX learning software does a check to see if my system has Adobe Reader and it says I still need to install it. What's up? This has happened

    I downloaded the latest version of Adobe Reader (11.0.07) and installed it. Message said install successful. But APEX learning software does a check to see if my system has Adobe Reader and it says I still need to install it. What's up? This has happened to me numerous times throughout the years. I need to get to the bottom of this problem. Thanks for your help.

    You still don't give us the message you are receiving.  My guess: you are trying to open a PDF in a browser that uses its own PDF viewer, not the Adobe Reader plugin: http://helpx.adobe.com/acrobat/kb/pdf-browser-plugin-configuration.html

  • Checking if a movie clip mask has been removed

    Hi,
    I am creating a scratch card type effect and would like to know hen the user has completed scratching off the top layer.
    Currently i am using movieclip.mask and assiging it a sprite and using
                   mask_mc.graphics.beginFill(0x000000,1);
                    mask_mc.graphics.drawCircle(mouseX, mouseY, 50);
                    mask_mc.graphics.endFill();
    to remove the mask. I would like to know if there is a way i can check what percentage of the mask has been removed.
    Is there a way to do this?
    I was looking of properties of mask or graphics that might help but could not find any suitable.
    Any help would be appreciated.
    Emma

    glad that worked out for you. Yes trace is your friend.
    BTW you need to use the array notation for everything and it is generally not such a great idea to use _root -- just in case you later load content into another swf the _root will change.
    So if this were me....
    var sp:ScrollPane=quiltpane
    var myContent:MovieClip=sp.spContentHolder.quilt;
    And then later
    myContent["square"+loopcount];
    Easier to read, easier to type. You can give those different names that are more meaningful for you. Also you will get code hinting since the variables are typed -- you won't get that with the array notation. You could even do something like:
    for(var loopcount=0;i<numSquares;i++){
    var curSquare:MovieClip=myContent["square"+loopcount];
    curSquare._alpha=blah blah
    blah blah blah.

Maybe you are looking for