Closing a swf

I have a swf which is run as a child of another swf.  The child swf has a return button which runs this.parent.parent.removeChild(this.parent); to remove the child swf.  By it's self it runs fine removing the child and leaving the parent.  I want the child swf to fade out before being removed so when I click the return button it runs a function to fade and when the alpha is sufficiently low it runs the function to remove the child swf, close the stream, and event handlers.  The problem is that whenever I run the fade function after the fade I get error messaged  like this:
TypeError: Error #1010: A term is undefined and has no properties.
    at moviesNoComponent_fla:MainTimeline/closeVideo/moviesNoComponent_fla:end()[moviesNoCompone nt_fla.MainTimeline::frame1:145]
    at moviesNoComponent_fla:MainTimeline/closeVideo/moviesNoComponent_fla:fade()[moviesNoCompon ent_fla.MainTimeline::frame1:140]
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
    at flash.display::DisplayObjectContainer/removeChild()
    at moviesNoComponent_fla:MainTimeline/closeVideo/moviesNoComponent_fla:end()[moviesNoCompone nt_fla.MainTimeline::frame1:144]
I think I'm out of scope or something.
As is I can make the child swf fade or I can close it out but I can't do both
the relevent code:
return_btn.addEventListener(MouseEvent.CLICK, closeVideo);
function closeVideo(e:MouseEvent):void {
    addEventListener(Event.ENTER_FRAME, fade);
    function fade(e:Event):void {
        alpha -= .015;
        if (alpha < .01) {
            end();         }
    function end():void {
        stream.close();
        vidContainer.removeChild(vid);
        this.parent.parent.removeChild(this.parent);
        return_btn.removeEventListener(MouseEvent.CLICK, closeVideo);
        removeEventListener(Event.ENTER_FRAME, fade);
        meCombo.removeEventListener(Event.CHANGE, movieSelected);
        vidContainer.removeEventListener(MouseEvent.MOUSE_OUT, playMovie);
        vidContainer.removeEventListener(MouseEvent.MOUSE_OVER, pauseMovie);
        vidContainer.removeEventListener(Event.ENTER_FRAME, resizeMovie);

you can't nest named functions.  you can nest an anonymous function but there's no need in your code for that:
return_btn.addEventListener(MouseEvent.CLICK, closeVideo);
function closeVideo(e:MouseEvent):void {
    addEventListener(Event.ENTER_FRAME, fade);
function fade(e:Event):void {
        alpha -= .015;
        if (alpha < .01) {
            end();         }
function end():void {
        stream.close();
        vidContainer.removeChild(vid);
        this.parent.parent.removeChild(this.parent);
        return_btn.removeEventListener(MouseEvent.CLICK, closeVideo);
        removeEventListener(Event.ENTER_FRAME, fade);
        meCombo.removeEventListener(Event.CHANGE, movieSelected);
        vidContainer.removeEventListener(MouseEvent.MOUSE_OUT, playMovie);
        vidContainer.removeEventListener(MouseEvent.MOUSE_OVER, pauseMovie);
        vidContainer.removeEventListener(Event.ENTER_FRAME, resizeMovie)

Similar Messages

  • Closing a swf file with a button

    I have a flash website that opens another flash website. I
    want my quit button on this new site to close the swf file and
    return back to the first flash site. I know that the quit fs
    command completely closes a document only if it's a projector, but
    I am only using swf files. So far the only way I know how to do
    this is the unload movie script on my quit button for each level
    that there is a movie. This script only unloads each movie in the
    scene and turns the screen the same color as the background. I
    don't know how to completely close the swf player for this movie.
    Its probably very simple but I am stuck on this problem right now.
    Any Suggestions???

    if you are navigating to another html page - then simply use
    the getURL call and load the new page into the current browser
    window - effectively 'closing' the previous swf.
    however - another method would be to use a system wherein the
    'main' html page contains a swf that is solely made for loading
    'other' swf files using the MovieClipLoader class - in this way you
    could simply load a new swf file into the same clip and depth as
    the previous one - this will 'replace' anything that was currently
    loaded at that depth.

  • Listing objects and their instance names (of closed source SWF)

    I have an API for a flash player that I want to use, but it is closed source. I know I could try a decompiler but I need to see what it loads and what it's doing at runtime.
    I'd like to see the objects (and all their info) that it loads and has on stage along with thier instance names. I'd like to see what this SWF has/does so I can write my AS3 code accordingly... maybe add some additional event listeners.
    Is there any was to go about doing this? I know there's some AS3 commands to get this information but I dont know what they are. If you all could give me some hints at which commands would be useful that would be great.

    "I need to see what it loads"
    You can use Fiddles, Charles or Firebug to monitor traffic (what it loads).
    As for the rest of your question - good luck. Although it is possible to decompile swf of course, reverse engineering is an extremely complex time consuming task. In the majority of cases it is easier and faster to replicate functionality from scratch than to try to understand SWF's logic.
    Unless you know packages structure - there is no native way to figure out/access application domain.

  • Start as closed book (swf export related issue) ?

    How do I make it seem like a book is starting from its closed form? Currently the starting page is to the right of the screen with empty space on the left. I want it to get an effect like its closed and then when I start flipping the pages, the whole screen area needs to get used.
    Any pointers will be welcome, thanks in advance.

    You said you want your PDFs... are you making PDF or SWF? You can set your PDFs to open with single coverpage in the spread by changin initial view from Acrobats File>Preferences....
    If you are making SWF, simply draw a gray rectangle to left side of your coverpage. Make it touch to coverpage, small amount, like 0,1" is enough. Then export your swf and you will have your cover´s left side gray...
    Even better option IMHO is re-create that html-page with for instance free SWF-object tool. I have wrote a post about that somewhere here, I add a link if I find that old thread.

  • Is there a way to restore a movie clip after you have closed the swf

    Can you restore the state of a movie clip after you have closed it?

    Could you explain more about what you mean by "assign component parameters" because I dont understand. Is this something I would do before it closed? Maybe I failed to explain clearly. i really need some help on this because i have no idea where to start. I have created an app, but I want a user to be able to reopen the app after close and pick up where they left off, or be able to change one thing and not have to start from the begining. I have searched around and cant find information on what i need so Im starting to wonder if that is possible using as3?

  • TestRunner Hangs or ExecutionException: java.lang.NumberFormatException

    I'm attempting to get my unit tests setup to run automatically with my Ant build and take one path or the other if they fail or not. I used the SampleCIProject as an example and got it to run just fine. However, when I recreate the structure in my project I am getting some weird behavior that I have wasted a lot of time trying to figure out. When I duplicate the SampleTest.as class my Ant build runs as expected. However if I throw an [Ignore] tag above the first test I get the java exception telling me it is expecting a number and getting "NaN'. It seems to be hit or miss depending on where I put the [Ignore] lines and the resulting exception. Also I find that if I put in only one test and [Ignore] it, when FlexUnit task executes and the TestRunner.swf pops up it stays up and hangs the process. It does not shut down automatically. Upon closing the swf the process does nto complete, just sits there in this hung state.
    I'm not creating my own TestRunner.mxml as it seems to be automatically created. I did try creating my own but I notice that the resulting TestRunner.mxml in the dist folder is the one that is automatically generated vs the one I created.
    I'm using the 4.1.0-beta2.19-sdk3.5.0.12683 build if that helps.  Does anyone have any idea what's going on? If not, does anyone know how I can set myself up to debug the ant task and FlexUnit code so I can try to find out what's going on? I can't seem to even find if/where the java exception being thrown has a full stack trace sent to a log somewhere.

    This sounds like an error in the CIListener to me. I will need to confirm, but the quick guess is that the Ignore is probably trying to output the time since the last test execution. Since it is the first one causing the problem, my guess is that the variable holding the time has not been initialized and is null. I am guessing the code concatenates that into some weird mess and probably sends it over to Java, which freaks out trying to interpret it into a number.
    I won't be able to check for an hour or two, but if you want to verify yourself, I would look in the CIListener and look for ramifications of the testIgnored() method being called before whatever variable holds the time is initialized.
    Another quick and dirty way to test would be to change the CIListener. It has a method, something like testTimeStr() which returns the time represented as a string. Just make it always return '0' and see if the problem goes away.
    Mike

  • Flash CS4 crashes on 2nd publish preview (v10 and 10.0.2)

    I've seen this problem for so long, I've become desensitized to it.  In flash 8, flash CS3, and flash CS4 (with and without the 10.0.2 patch), the program crashes and burns about 75% of the time when I
    publish preview,
    leave the playing swf open, and
    publish preview again.
    I would think in this case flash should just close the playing swf from the first publish preview before opening the second one, but most of the time it crashes instead.  I've gotten used to closing the swf manually before I publish preview a second time - I guess it's just one of flash's "endearing" little quirks.  Does this happen to anyone else, and does anyone know how to fix it?  Does adobe know?

    The second publish is doing a simulate download, so it's a different thing happening - but of course it shouldn't crash Flash. Is this 75% of the time with a particular file, or in general with all of your files? Have you done this with the Task Manager open and is the memory going way up when you go into simulate download mode?

  • CS6 Cloud.  Can't connect to debugers

    Hi,
    I upgraded from CS4 to CS6 Cloud.  I can no longer launch ANY APP in the debugger.
    File > New > AS3
    create an actions layer.
    in frame 1 add trace("hello world");
    click debug movie -> in Flash Pro Professional   (or ctrl-shift-enter "Debug").
    The app runs fine.  Output says:
    Attempting to launch and connect to Player using URL C:\Users\Sean\AppData\Local\Temp\Untitled-1.swf
    No debugger ever starts. No Trace messages display anywhere.
    Closing the swf window produces the popup error:
    Debugger lauch failed.  Debug session terminated.
    Googling provides many instanaces of the problem, but no fixes.
    I have tried:
    Uninstall/Removing CS4.
    Uninstall/Removing CS6.
    Uninstall/Remove EVERY ADOBE PRODUCT.
    Delete EVERY  "ADOBE" tree in the registry
    Reinstall the Adobe App Manager.
    Reinstall CS6.
    NO CHANGE.
    I dont care if I have to sacrafice a chicken.  I need to see my trace messages at a minimum.
    PLEASE HELP.

    Thanks for the response Ned.  Unfortunately, I can't find any way to contact Adobe Support.  The only links I can find point here.  Please share.
    Sorry still a nnob to Adobe Development.
    Thanks again,
    Sean Devoy

  • Need some help with Flash + Captivate (ActionScript in Flash)

    I have what I think is a fairly simple question.... I have an SWF File embedded in a Captivate 4 Presentation. The SWF requires the user to click on a variety of items, after they have gone through all the required items a "FINISH" button appears... I want the finish button to "close" the SWF file.
    I'll add this info to in case it helps with the "right" answer....
    The reason I am doing this is because Captivate automatically rolls from one "slide" to the next. The only way to stop this is to add a "pause" button to the slide, I want the user to have to finish the SWF before they can see the "next" button in the captivate file...So I was thinking, put the "swf" over the "next" button... then have the "complete" button close the swf revealing the covered "next" button in captivate....
    The short version of what I need is information on closing an SWF file via a button click. Is there a "swf.visible=false" or anything like that?

    Need some help with putting a folder in users directoryI recomend using System.getProperty( "user.home" ) not a hard-coded value.
    This will use the users home folder ( C:\My Documents ) on Win9X (I guess), C:\Documents and Settings\<current user> on Win2K +, and ~ on Unix-a-likes.

  • ShowModalDialog in IE 10 hides Flash content

    We have a product that is IE only.  We launch a window using showModalDialog that contains a swf written in Flex.  The most recent update to IE 10 causes the swf to disappear.  When the window is closed the swf displays right before the window closes.  Does anyone know of a workaround for this?  Unfortunately the way our code was written we can't easily change to "window.open()" which shows the swf but breaks other functionality.
    Kevin

    Same thing is happening with me......
      Faulting application name: IEXPLORE.EXE, version: 10.0.9200.16686, time stamp: 0x52058cf0
    Faulting module name: Flash32_11_9_900_117.ocx, version: 11.9.900.117, time stamp: 0x5244d34f
    Exception code: 0xc0000417
    Fault offset: 0x00791537
    Faulting process id: 0x73c
    Faulting application start time: 0x01cecf3d61a1cc56
    Faulting application path: C:\Program Files (x86)\Internet Explorer\IEXPLORE.EXE
    Faulting module path: C:\Windows\SysWOW64\Macromed\Flash\Flash32_11_9_900_117.ocx
    Report Id: 9f877836-3b30-11e3-a48a-005056c00008
    Thoughts?

  • Need help with maintaining variable choices in new session

    I have a flash app. set up with several variables. Is there a
    simple action script that will allow the user to maintain their
    choices after closing the .swf and re-launching it?
    Thanks in advance for your help.

    how are you checking if those components have been checked or
    ticked. actually, i probably don't want to know that.
    you really should be using a listener to detect when your
    components have changed and then you can use the changed method to
    set your variables and update your sharedobject.

  • Multiply Masks to one Layer question.

    1. Can I use another mask in this code type?
    2. It is possible that the location of the mask remains even after closing the swf file?
    3. Why disappears circle soft outline?
    Thanks!

    yes, but you can't mask a mask and have it do what you would expect, you can't mask more than 1 object with the same mask and you can't assign more than 1 mask property to a displayobject at any one time.
    if you want to apply mask1, mask2,.., maskN to bane_mc, you would use something like:
    var parent_mask:Sprite=new Sprite();
    for(var i:int=1;i<=N;i++){
    parent_mask.addChild(this["mask"+i]);
    bane_mc.mask=parent_mask.

  • Importing swf file with skin and closed captioning problems

    I created a flv file in Preimere and I pulled it into flash to create close captioning.  When I publish it, it creates a swf file that I can open up on its own and it has the skin with the button to push to show the closed caption.  When I try to bring that file into captivate, it doesnt bring in the skin and it just automatically shows the captions.  How do I get it to bring the skin in with it?

    Are you seeing this problem when you preview you project. or only after you publish it? If it is when you publish, is it in both the local version and/or in the web version?
    Also, which version of Flash Catalyst? 1.0 or 5.5.?
    Chris

  • CP4-SWF starts a Website by closing in a PDF-File

    Hi,
    I let run several SWF-Files in PDF's - works great, but by closing the file it's trying to open a website - and i don't now where to cancel this.
    This happens only in Adobe Reader-Files.
    I use CP 4 and Acrobat 9 ext.
    Has anyone a idea?
    Thanks a lot for any help.
    Greatings Wolvo

    Hi there
    There's another thread running where the user is attempting to coax Captivate's Exit button to close a floating window from Acrobat Reader.
    So where are you seeing this behavior?
    * When you close the Captivate inside the PDF? (If so, how are you doing that?)
    * When you close the PDF viewer showing the Captivate content
    Chers... Rick
    Click here for Adobe Certified Captivate and RoboHelp HTML Training
    Click here for the SorcerStone Blog
    Click here for RoboHelp and Captivate eBooks

  • Closed captioning won't display in html/swf

    I have embedded a swf file in html. The closed captioning displays when I view the .swf file and when I view the Flash published html. However, when I view the fully created Web page, the closed captioning won't display. Does anyone have any ideas?
    Specs:
    The video was created with Captivate 4, published as an .avi and then as an .f4v with Adobe Media Encoder CS4
    The .f4v is imported into a Flash CS4 framework.
    The closed captioning file was created with MAGpie and exported to a dfxp file.
    The .swf file containing all of the necessary files above is embedded in a Web site created with Macromedia Dreamweaver 8.

    Oddly enough, I played with the placement of the captioning file to get this to work. While all the other resource files associated with this project needed to remain in the original locations when I embedded my Flash within the html, this file needed to be in the same folder as the base html code for some reason. I hope this helps someone else down the road.

Maybe you are looking for

  • Bells out of tune

    I am not sure what's going on but the last mix is okay and this version sounds wrong and awful. I loaded the tuner and played the String Bell on the other track checking the tuning on the other track. The tuning was really off. A3, B and E plays 40 c

  • Exporting Pages PDF - My Pages Shift?

    Does anyone know how to prevent shifting of text after exporting out of Pages? Everytime I export as a pdf out of Pages, my margins shift and the document is not centered on the page. I hope this is clear. Thanks if you can help any. Lawrence iMac Po

  • How to hold the government's stock under our location

    Hi All, We have a scenario where in we need to hold the stock of some government's material in our plant /warehouse. The government agrees to pay for the storage for whatever period of time we need to . What I want to know is 1. Though the stock is a

  • Using AIR for a modern HTML5 app

    Hello We're in the process of planning out an app that would end up being a 'packaged' app that can run on mobile (iOS + Android) and desktop (Mac and Windows). HTML5/CSS/Javascript is our natural choice for developing a responsive UI that looks good

  • "really fast" - fast forward ?

    Hello ! When listening to audiobooks, one file might have a total playing-time of around 7 hours.. the pre-market steps are around 1,5 hours apart, which still leaves quite a large time gap one has to put behind to reach certain points within the rep