RemoveChild for movie clip that was added in another function?

Hello everyone.  I have 3 different functions for my preloader.  I have an Event.OPEN, ProgressEvent.PROGRESS, and an Event.COMPLETE.  In the event.OPEN function, I create a new variable that is data typed to the class name of my preloader that I set in it's property dialogue box.  This is just a simple circle animation.  Below is my code for it:
function addPreloader(event:Event):void
    var myPreloader:mcPreloader = new mcPreloader();
    myPreloader.x = stage.stageWidth / 2;
    myPreloader.y = stage.stageHeight / 2;
    myPreloader.width = 75;
    myPreloader.height = 75;
    addChild(myPreloader);
My ProgressEvent.PROGRESS function looks like so:
function preloadImages(event:ProgressEvent):void
    var percent:Number = Math.round(event.bytesLoaded / event.bytesTotal * 100);
    percent_txt.text = percent + "%";
and my Event.COMPLETE function looks like so:
function imageLoaded(event:Event):void
    var myLoadedImage:Loader = Loader(event.target.loader);
    addChild(myLoadedImage);
    new Tween(myLoadedImage, "alpha", Strong.easeIn, 0, 1, 0.5, true);
    event.target.loader.removeEventListener(Event.OPEN, addPreloader);
    event.target.loader.removeEventListener(ProgressEvent.PROGRESS, preloadImages);
    event.target.loader.removeEventListener(Event.COMPLETE, imageLoaded);
The only problem is that when it's done loading, I'd like to remove the myPreloader from the stage.  Since it is declared in the Event.OPEN function, I can't communicate with it via my Event.COMPLETE function.  How can I successfully remove it from the stage after it's done loading?  Thanks!
Jesse

Duh, thanks Kglad.  It's been a long week ;).
Jesse
Date: Thu, 9 Jun 2011 13:47:57 -0600
From: [email protected]
To: [email protected]
Subject: removeChild for movie clip that was added in another function?
var myPreloader:mcPreloader
function addPreloader(event:Event):void
   myPreloader = new mcPreloader();
    myPreloader.x = stage.stageWidth / 2;
    myPreloader.y = stage.stageHeight / 2;
    myPreloader.width = 75;
    myPreloader.height = 75;
    addChild(myPreloader);
My ProgressEvent.PROGRESS function looks like so:
function preloadImages(event:ProgressEvent):void
    var percent:Number = Math.round(event.bytesLoaded / event.bytesTotal * 100);
    percent_txt.text = percent + "%";
and my Event.COMPLETE function looks like so:
function imageLoaded(event:Event):void
removeChild(myPreloader);
myPreloader=null;
    var myLoadedImage:Loader = Loader(event.target.loader);
    addChild(myLoadedImage);
    new Tween(myLoadedImage, "alpha", Strong.easeIn, 0, 1, 0.5, true);
    event.target.loader.removeEventListener(Event.OPEN, addPreloader);
    event.target.loader.removeEventListener(ProgressEvent.PROGRESS, preloadImages);
    event.target.loader.removeEventListener(Event.COMPLETE, imageLoaded);
>

Similar Messages

  • AS3: Checking if movie clip chiled is added

    hey,
    I have few movie clips that are added and removed automaticly by users choice. The problam is I can't find a correct "if" condition that will check if the movie clip exists before I remove it. This is the part of the code:
    function removeAnimation():void {
        if(Boolean(getChildByName('wheelChair'))){
            removeChild(wheelChair);
            chairTimer.stop();
    I tryed getChildByName and everything I could find in google and came up empty.
    Any help will be appriciated.

    Just on the chance that it might apply, since you do use the wheelChair as an instance name in one line, try the following...
    function removeAnimation():void {
        if(contains(wheelChair)){
            removeChild(wheelChair);
            chairTimer.stop();

  • How to build a custom movie clip that will be used as a cell renderer for column in a grid ?

    i want to build a datagrid that shows a picture and underneath it a name.
    the problem is i dont want to see all of the pictures, but all the pictures that have certain requirements, so i cant just make one movie clip that includes all the pictures and names.
    so my question is how do i build a movie clip that contains photo and text?.

    You do not create movieclips on the timeline using code, though you can create them and add them as children of something that has been manually placed in the timeline.
    To create a MovieClip using code you use: 
        var mc:MovieClip = new MovieClip();
    If you need to add an image, then however you intend to acquire the image, after it has been acquired, you add it to the MovieClip using:  
        mc.addChild(img); 
    where img is the instance of whatever form of object the image takes (Bitmap, Loader)
    If you need to add a TextField to the MovieClip then you use: 
        var tf:TextField = new TextField();
        mc.addChild(tf);
    and you can set up properties for the textfield such as the font and color and position as well after it has been instantiated (the first line).

  • [svn] 1418: Remove the optimization that was added as part of the fix for BLZ-133.

    Revision: 1418
    Author: [email protected]
    Date: 2008-04-25 11:16:16 -0700 (Fri, 25 Apr 2008)
    Log Message:
    Remove the optimization that was added as part of the fix for BLZ-133. We cannot depend on isRequestedSessionIdFromCookie reliably, instead we should rely on the fact that encodeURL returns the same url when cookies are enabled.
    Ticket Links:
    http://bugs.adobe.com/jira/browse/BLZ-133
    Modified Paths:
    blazeds/branches/3.0.x/modules/core/src/java/flex/messaging/endpoints/amf/SessionFilter.j ava

    This indicates corrupt files.  A restore should resolve.

  • IMovie HD refuses to import .MOV clips that it used to import.

    I've got an odd problem. Doing a search didn't turn up anything relevant to my situation so I'm gonna try to pick some brains on here.
    My Problem: My version of iMovie(5.0.2) no longer recognizes .mov clips that it used to. Meaning that when I try to import clips using settings that worked previously, I am now confronted with an Error during import message that reads "The file could not be imported: Unknown Error". Two things have changed since I last made a project.
    1.) I have added a microphone that now allows me to record stereo audio. I don't think this is the culprit.
    2.) I updated to 10.6.6 Recently. I think this may be what messed things up.
    After trying to Drag and also import clips through the menu with no success, I tried to import clips that I have used before under the exact same conditions and was greeted with the same error. This is importing using the HDV 720p setting. If I try to import new or old clips using the standard DV (16:9) setting then everything works.
    These same clips are able to be imported into iMovie '09 with no trouble but I am uncomfortable with that interface. Is there anything I can do to continue to work in iMovie HD or would I just be better off with getting used to iMovie 09?
    Thank you for any replies.

    I have Mac 10.6.6 and use iMovie 05 transferring it to iDVD 08. It is getting less easy to do, but usually i make the movie in 05, complete with chapter marking and press the export to DVD.
    The file for the Movie I have made is saved automatically in the Movie folder on my owner/home page. To get it out to iDVD 08 open 08 and select create new project and click save This puts a small file into Documents, However to get your work into the new DVD select import>video and when the screen opens for you to find it go to your movie folder in your owners area and click to open the file. It works, but there is usually a problem somewhere along the line. Usually a different one each time, occasionally it goes like clockwork. It won't work if you try the drop down 'open' option.
    This last time I got so irritated that I've downloaded the last set of film clips to 05 and then transferred them to 08 to compare the results. I still feel that the later versions are less good (?dumbed down) and await to be converted.

  • I imported a video I make in another program and I played it back in the video editor and I like the pan and zoom that was added by the program how do I save a copy with the effect of Premiere elements 12

    I imported a video I make in movie maker program and I played it back in the premiere video editor and I like the pan and zoom that was added by the program how do I save a copy with the effect of Premiere elements 12
    all I did was played it back how do I save that and make a new version of the video beacause when I save a copy the effect look I was trying to save was not there.
    Rodney
    [personal information removed... Mod - https://forums.adobe.com/docs/DOC-3731]
    [This is an open forum, not Adobe support, please do not post personal information]
    [If you are posting using email, please turn your 'sig file' function OFF for posting]

    silkman1
    I would be glad for the opportunity to customize a Premiere Elements 12 answer to your Premiere Elements 12 issue.
    But, I want to make sure that we are together on the details. This is my understanding of what you have written. Please review and let me
    know if I am misinterpreting anything that you have written.
    You have a video created in Windows Movie Maker.
    How did you output the video from Windows Movie Maker...wmv or mp4, what was the frame size and frame rate of that export?
    Next you import that video into Premiere Elements 12 (can we assume that this is on Windows 7, 8, or 8.1 64 bit?)
    From what you wrote, you have applied a pan and zoom effect to your video in Premiere Elements.
    Now you go to export the Premiere Elements 12 Timeline content with your video with the pan and zoom applied.
    But, the pan and zoom effect is not seen in playback of the export.
    Is all of the above correct so far?
    If so....we are going to need some more details from you...
    a. What is the project preset that you or the project are setting to match the properties of the video coming from Movie maker? See Edit Menu/Project Settings/General and the readings for Editing Mode, Timebase, Frame Rate, and Pixel Aspect Ratio even if the fields look grayed out.
    b. Are you applying the pan and zoom effect with the Pan and Zoom Tool, fx Effects Presets, or keyframing the Scale (for Zoom) and
    Position (for Pan) in the Motion Panel expanded?
    c. What are you selecting as your export in Publish+Share/. Please give details...are you using default settings or customizing the export
    setting under the Advanced Button/Video Tab and Audio Tab of the preset selected?
    I am suspecting some sort of mismatch of your project settings or some problems with working with the Pan and Zoom tool. I need
    your answers to help me help you. If I have written anything that you do not understand, please let me know. I will re-write if necessary
    so that we are in sync to resolve the issue.
    Thanks.
    ATR

  • How can I load an external SWF into a movie clip that's inside other movie clip?

    Hi.
    I creating my first flash (actionscript 3.0) website but I'm
    stuck with a visual effect I want to create.
    I have a window on my website called contentWindow. Every
    time you click a button this window is supposed to leave the stage,
    load the requested content and return to the stage.
    The sliding window is a movie clip with 83 frames, 21 to
    enter the stage, 21 to leave the stage again, 20 for nothing (its
    just to simulate the loading time) and 21 to return to the stage.
    Now my goal is, when the user clicks on a navigation button,
    the window exits the stage, loads an external SWF with the content,
    and then returns to the stage.
    I've the "window" movie clip with an instance name of
    "contentWindow". Inside there is another movie clip with an
    instance name of "contentLoader". The content that the user
    requested should appear inside the "contentLoader".
    Now, when the contentWindow leaves the stage, I get this
    error message:
    quote:
    TypeError: Error #1009: Cannot access a property or method of
    a null object reference.
    at rwd_fla::MainTimeline/trigger()
    If I switch
    "contentWindow.contentLoader.addChild(navLoader);" for
    "contentWindow.addChild(navLoader);" it works fine, but the
    external SWF doesn't move with the window.
    How can I load an external SWF into a movie clip that's
    inside other movie clip?

    Hi,
    Recently, I have been putting together a flash presentation.
    And I am just wondering if the following might help you, in your
    communication with the said swf file:
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE,
    onComplete);
    function onComplete(event:Event):void
    event.target.content.thinggy_mc.y -= 100;
    Not the best example, but this allows you to target a mc
    within an external swf file. I think if you look up this code, you
    will have an answer ;)
    Kind Regards,
    Boxing Boom

  • How do I create a play button for movie clip using AS3

    Hello.
    Bit new to this and have been searching the adobe forums and google. I am trying to create a button that will play an imported MovieClip.
    I have a movie clip that I've imported into it's own layer (Layer1) Frame 1.  I've given the MovieClip an instance name of foundationMovie.
    I've created a button and have that on its own layer(Layer2) above layer1, it is also in Frame 1.
    I've added a
    stop (); action to layer2
    The video is not set to autoplay.
    I want the video to start playing when the viewer clicks the button.  I know I've got to put some kind of event listener using AS3 in my timeline somewhere.
    I've found some code and I've been trying to work with it.  I'm sure I've mutilated it beyond usability but this is what I've got.
    stop ();
    player.addEventListener(MouseEvent.CLICK,play);
    function play(event:MouseEvent)
    gotoAndPlay("foundationMovie");
    If someone could point me the right direction or help me with my code I would really appreciate it.  Thanks.

    First, you need to clear up what you are working with... a movieclip and a video are usually entirely different things.
    Next, your code may get you started on your way with some changes.   You shouldn't use "play" as a function name due to there already being a play() method/function in Flash.
    If the movieclip is a movieclip and has an instance name of "foundationMovie", and your button has an instance name of "player" then the following adjusted code would normally work...
    stop ();
    player.addEventListener(MouseEvent.CLICK,playMovie);
    function playMovie(event:MouseEvent)
         foundationMovie.play();

  • How do you get a refund for an app that was purchased through the new App Catalog for a WebOS app!

    Hi,
    I just purchased a Dictionary app from Palm's App Catalog, the product is listed as: English Dictionary and Thesarus by Ultralingua, Inc. and it was not something that was advertised correctly and hence is not something that I want.
    It costs a whopping $9.99 and if it was as advertised, it would have been worth the money but it is not.
    I've had Dictionaries on my Palm Devices so when I saw the first directory for the WebOs for use on Pre, I immediately got it.
    However, unlike my old Palm dictionaries, this dictionary requires you to have a network connection.  Something that is not useful for me.  I sometimes like to look up word while on the subway to work (I live in NYC) where this is no network connection.
    There was nothing in the description that said it 'required' a network connection, and considering that all of the dictionaries I have gotten in the past did not require a network connection, I assumed (since it didn't state anything) that I could use it off-line.
    Heck, since you are required to use this dictionary online, I might as well use google to lookup a word and that is free!
    So I believe I was tricked into getting this app, and I want a refund!
    And there doesn't seem to be a way to get a refund for an app that did not disclose it's requirements before I made my purchase.
    Thanks for you help in finding out how to get a refund when its needed!
    Rob
    Post relates to: Pre p100eww (Sprint)

    Palm does have the ability to remove apps remotely, that was added in the last update.
    I knew that would be Palm's response, but I earn you now, Palm better make sure they put a better description on these apps.  And in this case its Palm's fault for not disclosing that this app required network support in order to work.
    They should at least make that part of a feature description.
    This is the second app that I purchased that was not advertised correctly.  So I far I have spent good money on crap only because the descriptions did not contain the right info.
    I see the only solution is to make all apps have at least a one hour free trail, or whatever free trial you want.
    I and I'm sure I'm not alone can't keep purchasing stuff that either doesn't work as advertised or is misleading in the description.
    I mean really Palm, you approved a dictionary app that just does a google in the background and displays the definition.
    I can do that same thing by typing it on my Pre and hitting Google?
    I still feel cheated and ripped off.
    I signed up for Palm and WebOS because I wanted to give you a second chance but that love only goes so far.  I think Andriod will be in my life soon.  I can't stand by and let myself be taken advantage of.
    I just can't believe how angry and upset I AM over this.
    Rob

  • I have numerous music movie clips that I have not purchased through iTunes, can I stream these "home" movies to apple TV? And if this is not possible, is there another complete program available that I can purchase to have my music movie clips stream to a

    I have numerous music movie clips that I have not purchased through iTunes, Is it possible to stream these "home" movies using iTunes to apple TV?
    And if iTunes will not allow it, is there another complete program available that I can purchase to have my music movie clips stream to a TV and/or another computer?
    Any help would be appreciated. Thanks

    Thanks, Winston C, I've actually tried everything you suggested. I'm thinking now that the Home Sharing problem likely is related to Bonjour--I've seen several people mention this with similar (but not identical) problems. The solution that seems to work for some people is to uninstall and reinstall Bonjour. Frankly, I don't want to go through the trouble given that the iOS 7 release is imminent.
    One thing that I haven't tried is resetting the ATV to factory settings. I'll give that whirl.
    Thanks for your advice!

  • Can i assign a child state to a movie clip that is already placed on stage

    Hello
    Is it possible to add a child state to a movie clip that is
    already placed on stage,
    i need to do this so i can move the movieclip to the top of
    the display list.
    thanks for the help
    mt

    "The objects i want it to appear above are loaded swf's onto
    the same main stage."
    Aha, this is where things can get confusing. The terminology
    between the Flash Authoring tool and ActionScript is not
    consistent.
    In ActionScript, the Stage is the top most DisplayObject. You
    probably get that.
    In Flash, the canvas that is often referred to as "the stage"
    is not the Stage object of ActionScript, rather the Flash stage is
    a DisplayObject class called MainTimeline (or if you assign a
    document class, it's that class), which is the first and only child
    of the ActionScript Stage object. It's the only child unless, of
    course, you add something else to the ActionScript Stage object at
    runtime... like a loaded swf. ;)
    So in other words, if you are doing anything like this:
    stage.addChild(myLoadedSWF)
    You are actually putting myLoadedSWF above the MainTimeline
    object, which is the entire Flash timeline. There's nothing wrong
    with that, but in this case it means changing the depth of things
    inside the MainTimeline is not going to change the fact that the
    MainTimeline itself is below myLoadedSWF.
    Most likely the simplest solution is to add your loaded SWFs
    to the property "root", not stage. root can refer to different
    things in different places, but most of the time it refers to the
    MainTimeline, and if I had to guess I would say it almost certainly
    does in your case. Note that the "root" property is typed as a
    DisplayObject, not a DisplayObjectContainer, so addChild (which is
    a DisplayObjectContainer method) will not be recognized unless you
    typecast to DisplayObjectContainer or a subclass of
    DisplayObjectContainer, like Sprite or MovieClip:
    MovieClip(root).addChild(myLoadedSWF)
    Also note that, unlike AS2, in AS3 it's very easy to simply
    add your loaded SWF below existing objects you create in Flash. You
    can use addChildAt(obj,0) for instance to add it to the very
    bottom.

  • How do I clear a persona that was added accidentally by my child?

    I need to clear a persona that was added accidentally to my foxfire at work. It is very hard for me to concentrate with this on. I just want it blank again. How do I do that.?
    == This happened ==
    Every time Firefox opened
    == It was accidentally added when an update was added

    '''Use default theme'''
    1. On top of Firefox, on the menu bar, select Tools
    2. In the drop-down menu, select <u>Add-ons==
    3. Select the Themes Panel
    4. Click on the default theme. Select Use theme
    5. OK
    </u> Uninstall Themes:===
    1. In the add-ons window, select the '''Themes Panel'''
    2. Select the theme you want to uninstall
    3. Click Uninstall. Again when prompted

  • [svn:fx-trunk] 10201: Removing special case Container opaqueBackground logic that was added recently as it is no longer required .

    Revision: 10201
    Author:   [email protected]
    Date:     2009-09-12 13:23:35 -0700 (Sat, 12 Sep 2009)
    Log Message:
    Removing special case Container opaqueBackground logic that was added recently as it is no longer required.
    QE notes: None
    Doc notes: None
    Bugs: SDK-23129
    Reviewer: Glenn
    Tests run: V_H_Box, Canvas mustella tests.
    Is noteworthy for integration: No
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-23129
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/framework/src/mx/core/Container.as

    Remember that Arch Arm is a different distribution, but we try to bend the rules and provide limited support for them.  This may or may not be unique to Arch Arm, so you might try asking on their forums as well.

  • Boundary for movie clips following the mouse

    here's my AS...
    myInterval = setInterval(KBMOglobal,15);
    function KBMOglobal () {
    KBMOglobal1._x -= (KBMOglobal1._x - _xmouse)/10;
    KBMOglobal1._y -= (KBMOglobal1._y - _ymouse)/10-2;
    ok, so my movie clip follows the mouse around, with a small
    delay and the y axis is slightly lowered. the stage of my movie is
    380 x 640. does anyone have any suggestions on how to create a
    boundary, equal to the size of my stage, that does not let the
    movie clips that follow the mouse extend past? does that even make
    any sense? essentially, i would like the movie clips to follow the
    mouse, the entire movie clip stay visible on the stage. because of
    the positioning of the items on the stage that initiate this
    function, i only have to consider the width of each movie clip,
    which luckily is a constant = 200. does that make any sense? let me
    try this all again....
    how do adjust the above function so that the movie clip,
    KBMOglobal1 (which has a width of 200) stay within the horizontal
    limits of the stage (which is 380)?
    thanks for your time and to everyone in this forum that has
    been so very helpful with all my questions in this project so far,
    yall rock!

    quote:
    Originally posted by:
    NickTheNameless
    this is almost working perfectly, however i need to adjust
    the boundary of the x axis. for some reason, the movie clip stops
    following the mouse when it reaches half way across stage,
    horizontally.
    would you please be so kind to explain what your script is
    doing? because i'm not a total idiot, i realize i could probably
    replace 380 with 760 (double the width of the stage) and it would
    work as expected. however, if you could spare the time to explain
    what the following two lines are doing, step by step....i'll give
    you my first born.....
    KBMOglobalGeneralCancelDispatch._x<0?KBMOglobalGeneralCancelDispatch._x=0:KBMOglobalGenera lCancelDispatch._x;
    KBMOglobalGeneralCancelDispatch._x>380-KBMOglobalGeneralCancelDispatch._width?KBMOglobalG eneralCancelDispatch._x=380-KBMOglobalGeneralCancelDispatch._width:KBMOglobalGeneralCancel Dispatch._x;
    thanks again for your time!
    do you know ?: operator? it is like if...else... statements,
    when we say:
    somethingIsTrue ? do1() : do2();
    it is exactly same meaning like:
    if (somethingIsTrue) {
    do1();
    } else {
    do2();
    Now, we look at this line:
    KBMOglobalGeneralCancelDispatch._x<0?
    KBMOglobalGeneralCancelDispatch._x=0:
    KBMOglobalGeneralCancelDispatch._x;
    it is same like
    if (KBMOglobalGeneralCancelDispatch._x<0) {
    KBMOglobalGeneralCancelDispatch._x=0
    } else {
    KBMOglobalGeneralCancelDispatch._x

  • Check for movie clips with AS?

    Is it possible to check if a frame contain a movie clip with
    AS, and then if movie clip is found run a function? Like a global
    "event handler " for movie clips.

    I want a function that automaticly can detect and fade in any
    movie clip found in any keyframe in the main timeline. So i don't
    have to make
    In the first keyframe in the main timeline
    on (ohh here i found a movie clip)
    //let's run a nice fade function on that movie clip
    mx.transitions.TransitionManager.start
    (eval(TheClip),
    {type:mx.transitions.Fade,
    direction:0,
    duration:1,
    easing:mx.transitions.easing.None.easeNone,
    param1:empty,
    param2:empty
    Something like that

Maybe you are looking for

  • How to submit a concurrent request from Discoverer report.

    I would like to know If any one has tried submitting a concurrent request from Discoverer Report?_ This is no stupid question, but our team here finally decided with a solution to our long pending issues with few of the discoverer report. To Proceed

  • ITunes exits everytime I try to access music store!

    Everytime I try to access the music store, iTunes exits. No error message, no nothing. I am running iTunes 7.0.1.8 and I have no fire wall. Can anyone please help me figure out what the problem is? Thanks, Anthony

  • Error on export from Flash CC to Javascript/HTML5

    I am trying to convert a Flash CC project to HTML5. I continually get this error: An unexpected error occurred during export. [NOSYMB (innerWheel)] innerWheel is a movieClip that contains 784 frames of frame by frame animation. The elements that anim

  • How to create custom action

    Hi, how to create custom action for Assemble permission for CMS. we have CMS.transport action which gives permission to Assemble & also to other activities. I want to know if there is a possiblity to just give that assemble permission instead of Cms.

  • My itunes got deleted off my old computer

    i got a new lap top and now that i want to download music i cant..and it says like this isn't your primary library, and it gives me an option of deleting all my songs or something else..and i dont know what to do!