AttachMovie from a loaded SWF

I'm trying to attach a movie from the library of an SWF I
loaded... from what I've read on on the forums, this is possible,
however I can't seem to get it to work. My setup for the test files
is as follows:
CONTAINER.SWF (parent file)
- creates empty_mc to hold child.swf
- loads child swf into empty_mc
- when child.swf is loaded, it calls:
_root.attachMovie("test_mc","myParentTest_mc",50);
CHILD.SWF (child clip)
(insde is a clip "test_mc" with a linkID to match)
Any help on syntax or what I might be doing wrong would be
appreciated. If this setup won't work, could it work the other way?
(CHILD.SWF attaches a symbol from the CONTAINER.SWF???)

Thank-you for the response, I thought of that... In my
situation, I need to be able to select one of many large files, and
attach assets from it as needed. In order for me to use attach
movie, using shared library assets, they first need to be placed on
the stage before the linkID is properly initialized. If I have to
do this for each "large file" it causes a jump in memory on file
startup. See my other post in the Flash General Discussion:
External
Assets and Memory Jump

Similar Messages

  • Controlling a Movie Clip on the Main Timeline from a loaded SWF?

    Is it possible to control a MovieClip on the main timelne from another loaded clip?
    I see posts that control loaded clips, but most are all from the loader in the main timeline.  I have a moviclip on the main timeline that I want to make visible or invisible depending on what keyframe is playing in another loaded swf.
    If I try to call the movieClip from the loaded SWF I get "error #1119.  Access of possibly undefined property...." because it doesn't exist in the loaded SWF, just the main timeline. 
    The old AS2 way just used "_root".  Since "_root" doesn't exist any more, how do you control items on the main TimeLine from a loaded SWF?

    I am not clear what you mean because you are saying you are trying to target a movieclip that does not exist where you are trying to target it.
    Try using a trace to see what you are targeting when you you target the MovieClip(parent.parent)....
    trace(MovieClip(parent.parent));
    The other approach I mentioned earlier is the more OOP-correct approach if you would rather try that way.  Here's a rough outline of it...
    AS3 - Dispatch Event
    http://forums.adobe.com/thread/470135?tstart=120
    Example:
    Add something to trigger the event in the child (your loaded swf):
    dispatchEvent(new Event("eventTriggered")); (
    if dispatchEvent problem, see: http://www.kirupa.com/forum/showthread.php?p=1899603#post1899603)
    In your loading/parent swf, listen for the complete event on the Loader.contentLoaderInfo.  In the complete event handler, add a listener for the event on the loaded swf.
    // event handler triggered when external swf is loaded
    function loaderCompleteHandler(event:Event) {
        MovieClip(event.currentTarget.content).addEventListener("eventTriggered", eventHandler);
    function eventHandler(event:Event):void {
        trace("event dispatched in loaded swf");
       // this is where your main file can set the visible property of your movieclip

  • Calling a function in the main movie from a loaded swf

    I realize this is probably a very basic question, but I have
    loaded a SWF file into another movie. I now want to call a function
    in the main SWF. Is there a way to do that? Alternatively, I have a
    custom class where I could put the function, but I haven't been
    able to figure out how to call it from the loaded SWF either. Do I
    somehow need to associate the class with the main movie,
    or...?

    Never mind - I was doing something very stupid and wasn't
    calling the function as a method of a movie clip. I was simply
    calling checkTarget(event) rather than
    event.currentTarget.checkTarget(event); which seems to work.

  • Calling a function in a flex app from a loaded SWF

    How can I call a function in a flex application from a loaded
    swf file?

    Two ways:
    Application.application returns a reference to the top-level
    application scope. You can access any public member, var, function,
    component, etc through that reference.
    Dispatch an event event form the loaded swf and use a event
    handler in the main app. All the gurus advise this as best
    practice, to ensure "loose coupling" It is also pretty easy,
    especially if you use a bubbling event.
    Tracy

  • Can't target main stage from dynamically loaded swf...

    A part of the Flash app. I'm working on right now does the following -
    Main stage loads an external swf using the following function:
    function loadAsset(evt:String):void{
    var assetName:String = evt;
    if (assetName != null){
      var assetLdr:Loader = new Loader(); 
      var assetURL:String = assetName; 
      var assetURLReq:URLRequest = new URLRequest(assetURL); 
      assetLdr.load(assetURLReq); 
      assetLdr.contentLoaderInfo.addEventListener( Event.INIT , loaded) 
      assetLdr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, displayAssetLoaderProgress);  
      function loaded(event:Event):void { 
       var targetLoader:Loader = Loader(event.target.loader); 
       assetWindow.addChild(targetLoader);
    The externally loaded swf loads another external swf into itself using the following function:
    function loadQuiz(evt:String):void{   
    var quizName:String = evt;
    if (quizName != null){
      var quizLdr:Loader = new Loader();
      var quizURL:String = quizName;
      var quizURLReq:URLRequest = new URLRequest(quizURL);
      quizLdr.load(quizURLReq);
      quizLdr.contentLoaderInfo.addEventListener( Event.INIT , loaded)       
      quizLdr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, displayQuizLoaderProgress); 
      function loaded(event:Event):void {
       var targetLoader:Loader = Loader(event.target.loader);
       quizWindow.assetLoader.addChild(targetLoader);     
    Everything loads fine, but from the quizWindow.assetLoader.addChild(targetLoader) level, I want to send a message/fill in a dynamic text box on the Main Stage. I have been "parenting" my brains out and I'm not sure how to communicate with that level.
    can anyone show me the proper path or method based off the above, or have a suggestion?
    Cheers,
    ~Chipleh

    Andrei1,
    Thanks again for your help. I was finally able to get the solution you posted below to work for me.
    Much appreciation,
    ~Chipleh
    "In your loaded movie write:
    function traceMyself(e:MouseEvent):void{
         dispatchEvent(new Event("I_WANT_TEXT"));
    function writeText(text:String):void {
         xmlFileName1.text = text;
    In the top movie that loads external swfs something like that:
    loadedSwf.addEventListener("I_WANT_TEXT", onTextRequest, true);
    function onTextRequest(e:Event):void {
         Object(e.target).writeText(tQuizXmlFile1.theQuizXmlFile.text);
    This way these two entities are independent and, most importantly, don't care who is the parent or grandparent."

  • Listening to Events from inside loaded swf

    In Flash Builder 4 I have a swfLoader with which I load swf files. The swf files that get loaded get created in Flash Pro, and I would like to be able to listen for events from the level that they get loaded from. What would I have to specify in the Flash file for the path? Can't seem to be able to specify the right path.
    Thanks a lot for any help!

    I wouldnt say this is elegant but we have been having issues gaining direct access to the SWF's loaded in via OSMF. However I have done setups where I dispatch an event from a SWF and have it bubble up and catch it on the MediaContainer level. Not elegant but works- otherwise may need to make a custom MediaElement and bypass the SWFElement to gain tighter control - seems like there should be a better way, but I havnt found it.

  • Passing events from externally-loaded SWFs

    Hi,
    We have an externally-loaded swf that acts as a kind-of-a slide show.  After a user selects a particular subject from a mxml-based "menu" application, they push "buttons" in the SWF to go through a presentation, then on the last frame of the swf, I'd like to unload the swf and replace it with another "mxml" application.  How can this be done?  I have not tried to pass/capture events "up" from an externally-loaded swf before.
    Thanks,
    Doug

    Do you own those SWFs?  If so, they should dispatch an event from a known
    place like a SlideShowManager or something like that.
    Other folks "cheat" and bubble events or dispatch off of the systemManager
    and/or top-level application.

  • Accessing a class from a loaded SWF

    In Flash Professional, I drew a shape, converted it to symbol, linked it to class Symbol1 (extends MovieClip) which is generated at run-time, and saved the SWF file as shape.swf.
    Now my main application wants to load shape.swf and create multiple instances of Symbol1 but I get ReferenceError when trying to access the class Symbol1.
    Below is my main application's code. Errors thrown are mentioned in comments.
    public class MovieClipTest extends Sprite
        public function MovieClipTest()
            var url:String = 'shapes.swf';
            var l:Loader = new Loader();
            l.contentLoaderInfo.addEventListener(Event.COMPLETE, f);
            l.load(new URLRequest(url), new LoaderContext(false, ApplicationDomain.currentDomain));
        private function f(event:Event):void
            var content:Sprite = (event.currentTarget as LoaderInfo).content as Sprite;
            trace(getQualifiedClassName(content.getChildAt(0))); // output: Symbol1
            trace(ApplicationDomain.currentDomain.getDefinition('Symbol1')); // throws Error #1065: Variable Symbol1 is not defined.
            trace(getDefinitionByName('Symbol1')); // throws Error #1065: Variable Symbol1 is not defined.

    Your "Symbol" is obviously not in the current ApplicationDomain, but in the loaded SWF's domain:
    var symbolClass:Class = event.target.applicationDomain.getDefinition("Symbol") as Class;
    var symbolInstance:MovieClip = new symbolClass() as MovieClip;
    Also because you're loading a SWF, the content of the Loader is a MovieClip, not a Sprite.
    Kenneth Kawamoto
    http://www.materiaprima.co.uk/

  • Control the property of an object in main stage from a loaded swf timeline

    please someone help me here, im loosing my mind
    i have a UILoader that loads an image from an xml list when you click its thumbnail ( in its thumbnails mc on mainstage aswell)
    thing is, i have another UILoader on the layer above that loads in a swf ( a slideshow that fades in and out the pictures when they change to the next,
    with all the coding on frame 1, frame 2 only has a stop and some code for when the mouse is idle for 5 secs it goes back to frame 1)
    so when you go to "portraits" it takes you to frame "x" where the slideshow ( loaded external swf ) starts playing automaticly right,
    if i click any thumbnail the slideshow goes to frame 2 ( wich is perfect and the mouse idle thing i wanted works great ) the ONLY THING IS
    after the slideshow runs by default for the first time ( i enter the category portraits )
    and i click any thumbnail ( moving slideshow swf to frame 2 enabling mouse idle event )
    and the mouse is idle ( so it does the event and starts playing the slideshow again ( goes back to frame 1 ) )
    I CANT MAKE THE UILOADER OF THE THUMBS IMAGE TO DISSAPPEAR!!!
    i have tried everything i can think of and everything i have read trying to adapt it with what i know,
    im no guru at this i reeeeally need some help
    THANK YOU  SO VERY MUCH ! 

    and where would i put the remove.simpleScreen ( simpleScreen is the loader i would want to remove )
    would it be on the external swf on frame 1 where the slideshow plays?
    or in the main timeline's category's frame?
    the problem ( that i see ) is that both loaders are on the same frame ( different layers tho )
    so if i put a the remove simplescreen there it wont show me the pictures when i click the thumbs
    or could i make it so that it removes it BECAUSE its playing on frame 1 ?

  • Moving the timeline from a loaded swf file

    Hi,
    I have been at this problem for awhile now.
    I have a two swf files, whic are loaded using ths code as an example:
    stop();
    var req:URLRequest = new URLRequest("Enchilada_A.swf");
    var loader:Loader = new Loader();
    function imageLoaded(event:Event):void {
        ldContainerB.addChild(loader);
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
    loader.load(req);
    The first one is triggerrd by a MC button that is on the timeline.
    That first swf loads fine.
    At the end of that file(which is short animation)
    I have code that says:
    MovieClip(parent).gotoAndStop("frameThree");
    I have also tried:
    MovieClip(root) and
    if (movie Clip is parent) {
    MovieClip(parent).gotoAndStop("frameThree");
    and/MovieClip(parent).nextFrame();
    I have also tried placing this. or root. into the code.
    I am not talking to the timeline from this swf file.
    Once the timeline moves to the next Frame the new swf file can load.
    My solution was to combine both swf files into one, which loads from the timeline button.
    It works and I can gt by but I really woud like to learn how to load a swf and talk to the timeline fro more flexibilty.
    I'm out of strategies.
    Is my code in the wrong place(at the last frame of the animation?
    Should it be written on the timeline by creating a new var that has a function once the animation is completed.
    Any suggestions and/or commens would be greatly appreciated.
    Thanks.

    Thanks,
    I finally had a chance to get back to this project and used your suggestions, whichare definitiley helpful. I also, created a new and very basic version of the project so I could easily see what was happening.
    This is the code that works:
    stop();
    MovieClip(parent.parent).nextFrame();
    trace(container_mc);
    I'm still trying to understand how the child parent relationship is working but this will get me going in the right direction.

  • Accessing events from externally loaded swf file

    hello,
    I have an swf file developed in flash 8. After loading that
    file into SWF Loader control in flex builder 3, how can we access
    the controls and events present in that particular file ?

    "surya_dhul" <[email protected]> wrote in
    message
    news:gg84e2$slm$[email protected]..
    > hello,
    > I have an swf file developed in flash 8. After loading
    > that
    > file into SWF Loader control in flex builder 3, how can
    we access the
    > controls
    > and events present in that particular file ?
    I think you'll need to use localConnection.

  • Can I Capture Javascript Calls from a Loaded SWF?

    My scenario:
    My main movie (SWF A) loads another movie (SWF B) and plays it.
    SWF B is legacy content - I can't modify it.
    SWF A is AS3. SWF B might be AS2 or AS3
    SWF B makes several calls to a javascript function that would normally reside in the hosting web page.
    The javascript calls might use ExternalInterface, or they might use getURL(javascript: xxx) or they might even use fscommand.
    My questions:
    Is there any way I can intercept the javascript call in movie A? I don't want to have to resort to the browser, so simply using ExternalInterface or similar to pipe the request back into the movie won't work.
    If there is a way, how does it vary across the different versions (ie. what's the difference between the child movie being AS2 or AS3, and what's the difference between the various means of calling js?
    I'm working on a web deployment, using Flex 4.0. I would be interested also in whether this is possible in Air, or Air Mobile.
    Many thanks in advance for any replies.
    JcFx
    http://www.jcfx.eu

    no, not with all those constraints.

  • Trying to call a root level function from within a loaded swf

    I'm not very familiar with AS3... I'm trying to have a loaded swf file call a function from the parent to unload itself when it comes to the end (on the timeline, not as a button). I'm assuming I need to be calling the function (that is used for the close button) from the loaded swf (perhaps I'm mistaken though?).
    Here's the code from one of my buttons that loads an swf. I'm guessing I need to call the closeSWF function from the timeline of my loaded movie but having no luck figuring out how to do that.
    Any help would be appreciated.
    // 01 ------------------------------------------------------
    function loadWeaving(ev:MouseEvent):void {
      // load SWF
      var movieClip:MovieClip = new holder_mc;
      //add it to the stage
      addChild(holderSWF);
      holderSWF.x=0;
      holderSWF.y=0;
      var requestEN:URLRequest = new URLRequest("WhatIsWeaving_Eng.swf"); // english
      holderSWF.load(requestEN);
      close_bt.addEventListener(MouseEvent.CLICK, closeSWF);
      function closeSWF(infoObject:Object):void {
      trace("close SWF");
      removeChild(holderSWF);
      // reset switch
      close_bt.visible = false;
      showAllButtons();
      infoObject.currentTarget.removeEventListener(infoObject.type, closeSWF);
      setChildIndex(close_bt,numChildren - 1);
      close_bt.visible = true;
      hideAllButtons();
      // - start timer last
      myTimer.addEventListener(TimerEvent.TIMER, closeSWF);

    You're exactly right. If you attach an event listener to the Loader before you add it to the stage, you can then use event.currentTarget to refer to the loader. And this is definitely the better way to do it if you're planning to use the loaded swf from multiple places or could ever need to do this in the future.
    So:
    protected function initLoader():void {
         var loader:Loader = new Loader();
         loader.addEventListener('closeMe', closeLoader);
         loader.load(new URLRequest(...));
         addChild(loader);
    protected function closeLoader(e:Event):void {
         var loader:Loader = e.currentTarget as Loader;
         if (loader) {
              loader.unloadAnstop(true);
              loader.removeEventListener('closeMe', closeLoader);
              removeChild(loader);

  • Communicate between loaded SWF's

    I have a base SWF, and I am loading a another SWF into a movieClip array... i need to communicate from the loaded SWF to the base SWF i tried _root but think this only goes to the root of the loaded movieClip any ideas?
    This is what I tried:
    on (release) {
    _root.moveContent(2);
    thanks in advance
    Rich

    _root always refers to the current _levels main timeline.  your main swf is always in _level0.  unless you load a swf into another _level, _root will always reference the main timeline of your main (or loading) swf.
    you can reference the main timeline of the loaded swf by referencing the target movieclip into which the swf was loaded.

  • Loading external swf, how to deal with errors within the loaded swf?

    I have a Flex app that basically lets you browse a bunch of thumbnails that represent swf files, when you click a thumbnail it opens a window that loads the actual swf into an image control. The problem I have is that these swfs can be uploaded by our clients, so they may have actionscript errors being thrown, etc. We can't really predict what they may do. Is there a way I can load these swf in such a way as to ignore any errors that the loaded swf may generate within itself.
    For example, one such swf reads some text from a text file to display, but when they are viewing it in this manner the file isn't there so a stream error is generated. My parent Flex app doesn't care about this error and I don't want to see it thrown up in an actionscript error box (I have debug verison loaded on my PC obviously) or interfere with the parent app in any way.
    Would application domains help at all? Would it make a difference if I loaded the swf into a separate domain? Or is there some way I can generically trap any error coming from the loaded swf and just ignore them?
    Any help appreciated.
    Thanks,
    Marcus

    There is no way to catch errors thrown at random times.  Remember that most folks have the release player which does not show error dialogs.
    Alex Harui
    Flex SDK Developer
    Adobe Systems Inc.
    Blog: http://blogs.adobe.com/aharui

Maybe you are looking for

  • Capture Cards for MacBook

    I want to video tape my Xbox games, and I'm wondering which capture card would be the best for a Mac computer and what do I also need to use it. Thanks

  • Issue when Bursting to Email in BI Publisher

    We have a requirement in BI Publisher to burst a report to email and to shared folder. We are able to successfully do the same. But we are facing the following issues We need to change the name of the file sent as attachment. When we are bursting to

  • Posting iPhone photos online

    Is there a (free) way to take photos with the 3g iphone and then upload them online or add them as an attachment (e.g., attaching files to a UBB post) without the use of a PC? For example, if I'm traveling without my Powerbook and I want to post phot

  • Soundstick Problem since 10.4.5 and iTunes 6.03 Upgrades

    Since upgrading to 10.4.5 and iTunes 6.03 this morning, the sound coming out of my HK Soundsticks is very hollow-- almost mono sounding. Comparing with the sound coming out of my Bose headphones, the Soundsticks appear to have frequencies missing-- l

  • Clicking on workitem prompts for relogin

    Hi all, One of my users is facing an issue with Portal work items. When the user logs into the Portal and clicks on a work item in the UWL, the systems opens a new window and shows the portal login screen. After keying in the user name and password,