SWF swf communication - swf loaded swf loading

Hello
I read the article by kglad SWF SWF communication when two SWF files uses actionscript 3.0 gratefully, but, probably because of my stubbornness, I have swf loaded at loading swf communication problems to work for me.

Loading of swf (swf1.swf) as loaded swf (swf2.swf) by casting to a MovieClip loader.content worked well for me.

I want the swf to call a function on the timeline of the swf file loading.  (Aside, I'm doubting it's possible, but I'm really very uneducated on this topic)

I copied the article code in swf2.fla as below;

Create a variable to refer to the main scenario for swf1

var swf1Main_mc:MovieClip; This assumes that swf1 is a movieclip.

Create your listener to ensure that loaded swf has been added to the display list and can get a

the reference to the main timeline (which is always the main timeline of the SWF loading).

this.addEventListener (Event.ADDED_TO_STAGE, initF);

function initF(e:Event):void {}

swf1Main_mc = MovieClip (this.root);

}

and add a simple button with an event listener for mouse to invoke a function (in swf2) for example

function btnClicked(e:Event)

{

swf1Main_mc.showME ();

}

where showME() is a function in swf1.  for example

function showME()

{

trace ("swf1 called swf2 showME");

}

All I get is a runtime error "TypeError: Error #1006: showME is not a function."  to swf2_fla::MainTimeline/btnClicked().

I took out what little hair remains try different variations in the code then, in desperation, please someone can spot what I'm doing wrong or point me in the right direction?

Thanks for your time,
Bob

A loaded swf file should not try to control its parent.  The child must only be send an event to the parent to take action.  In this way, the child is completely independent of the parent as well as to be able to publish on his own.  To load completion than the parent must assign an event listener to the child for this event, and the event handler function.

Example:

Add something to raise the event in the child:

dispatchEvent (new Event ("eventTriggered")); (if problem dispatchEvent, see: http://www.kirupa.com/forum/showthread.php?p=1899603#post1899603)

In your SWF to loading/parent, listen for the complete event on the Loader.contentLoaderInfo.  In the complete event handler, add a listener for the event on the loaded swf file.

triggered when external swf loading event handler
function loaderCompleteHandler(event:Event) {}
MovieClip (event.currentTarget.content) .addEventListener ("eventTriggered", eventHandler);
}

function eventHandler(event:Event):void {}
trace ("event sent in loaded swf");
}

Tags: Adobe Animate

Similar Questions

  • Communication between loaded SWF

    Hi all

    I have a few questions that left me speechless, any help would be greatly appreciated!

    I have a flash container that loads other flash files that have been made in Adobe Captivate, (essentially normal SWF files) and in addition to that I have other SWF widget files I created as his children to extend the default features of Captivate. So, essentially, I have 3 'levels' of the sovereign funds charge.

    Container-> Captivate SWF-> Widget

    The problem lies in the Middle - I don't know how the Captivate is organizing its variables, events and responsible children because I do not have access to its code. What I want to do, is get my SWF container communicates with the one Widget and vice versa, but I can't get the work of the hierarchy... I can send values to the 'scene' via the widget, but not vice versa.

    So first of all, since I don't have the code - SWF

    -Is it possible to list all the variables inside a child or a parent, so I can work this?

    Is there a way I can tell when a child or a parent raises an event? (especially when I don't know the names/functions of the event)

    - and is there an easier way, I could go on that I don't see?

    Thank you

    Yes.  You can use describeType() to any flash object to inspect all its methods, properties, and events.   describeType() generates a xml object that you can scroll through like I did above to search for items of interest.

  • AS3 communication with external swf loaded in mc

    Hi all

    Thanks for posting first

    My problem is this, I have a blank swf file that loads a swf into a clip called content_mc here is the code located in the blank swf file

    startLoad ("home page")

    var loadedSWF:Loader

    var content_mc:MovieClip = new MovieClip();

    function startLoad (SWFname:String) {}

    loadedSWF = new Loader ();

    loadedSWF.load (new URLRequest (nomswf + ".swf"));

    content_mc. AddChild (loadedSWF);

    function nextSWF (whichSWFName, removeSWF) {}

    content_mc.removeChild (removeSWF);

    If whichSWFName == 'start page') {}

    startLoad ("pre-loader");

    }

    }

    so this basically puts everything up now on the button of the swf file loaded on the outside I

    btn.next.addEventListener (MouseEvent.CLICK, nextpls);

    function nextpls (event: MouseEvent) {}

    MovieClip (parent.parent) .nextSWF ("home page", parent);

    }

    OK to explain if I remove the content_mc of the first part of the code that everything will work as it should

    the problem is that I need to load into this movieclip

    so I need to tell the MovieClip content_mc which its finished passing ("home page", parent) bit

    However I can't communicate with him

    I don't know if I did not have enough parents or if I need to say () and so on

    Maybe I need a reference or something ive read on those.

    currently learning AS3 and this part is a real headache

    any help is greatly appreciated

    Thank you

    fonzio1

    Should be more like this:

    Child ("home page")

    import flash.events.MouseEvent;
    import flash.display.MovieClip;
    
    btn.addEventListener(MouseEvent.CLICK, nextpls);
    
    function nextpls(e:MouseEvent):void {
        (parent.parent.parent as MovieClip).nextSWF("startPage", this);
    }
    

    Parent

    import flash.display.MovieClip;
    import flash.display.Loader;
    import flash.net.URLRequest;
    
    var content_mc:MovieClip = new MovieClip();
    addChild(content_mc);
    
    var loadedSWF:Loader;
    
    function startLoad(SWFName:String):void {
        loadedSWF = new Loader();
        loadedSWF.load(new URLRequest(SWFName+".swf"));
        content_mc.addChild(loadedSWF);
    }
    
    function nextSWF(whichSWFName, removeSWF){
        content_mc.removeChild(removeSWF.parent);
        if(whichSWFName == "startPage"){
            startLoad("pre-loader");
        }
    }
    
    startLoad("startPage");
    

    (Personally I use communication based instead of AS1 as "parent.parent" etc...)

  • Communication between two SWFs (FLASH movie load)

    Hi all

    My first flash animation gives users a choice to display several other movies (SWF) "external" flash by loading on top of my first film.  When a user chooses an external movie, the reading head is "parked" in an empty frame in my 'initial film' and code in this framework launches the external SWF file loading.  The document of the external SWF file size is the same as the main movie then she covers it completely. The code is simple.

     //Create a new Loader instance
    var loader:Loader = new Loader();
    // Load the SWF file into the instance
    loader.load(new URLRequest("Rule1.swf"));
    // Add the instance to the main timeline's display list
    addChild(loader);
    


    My external SWF plays until it ends.  If at this point, I can go back to my first film and move the playhead I think that my problem can be solved.  This is where my problem begins.  I don't know how deparcage the playhead in my "first film" once the external SWF is complete.  How can I get the playhead parked in a specific picture in my first film for that opportunity can choose another external movie? I'd appreciate any help I can get.

    Thank you

    NCP

    You must assign an event listener for the charger so that it can perform the function loadCompleteHandler.  You must wait for the swf file to complete loading before assigning the listener - to what I show below it waiting for the INIT event, which occurs once the file loaded AND is ready for use.  So the next line should be added to your code to load before calling the function load for the charger.

    Create a new instance of charger
    var loader: Loader = new Loader();

    Assign a listener to the INIT event

    loader.contentLoaderInfo.addEventListener (Event.INIT, loaderCompleteHandler);

    Load the SWF file in the instance
    Loader.Load (new URLRequest ("Rule1.swf"));
    Add the instance to the display list of the main timeline
    addChild (loader);

  • ContainerController issue when load child swf

    Hello

    I have swf parent (test.fla). Simply, it will load a child swf (child.fla).

    Parent once loaded the child swf file I can acess point of the child and its clips.

    Question:

    When I manufacturer a variable like "ContainerController", the swf parent not able to gain access to clips of the child. How to solve this problem?

    When I do not include "ContainerController" in child swf, I got the track of the parent as a class (its what I expect)

    [object MainTimeline]

    -> MC

    MC1->

    When I include "ContainerController" in child swf, I got the track of parent (litigation) class

    [object MainTimeline__Preloader__]

    instance3->

    instance5->

    Here you can get the demo files for your reference: https://rapidshare.com/files/3986374440/test.rar

    Thank you

    Siva

    Click file > publication settings > advance settings actionscript (key next to the drop-down list icon script) > library > default connection > merged with code > ok > retest.

    In addition, here are all the ways to communicate between two files, as3, http://kb2.adobe.com/community/publishing/918/cpsid_91887.html

  • 'Detect' a variable from an external SWF loaded via SWFLoader

    I load an external SWF file to a click event.  Then, when interactions has reached the end of the presentation, we would like what he offload and go into another State.

    Is this possible?  (actually turned the SWF into a component using Flash Builder 4 in the hope that it would be easier to detect variables and events)

    Thank you

    Doug

    It is possible, but you will have to wire upward communications between the

    Sovereign wealth funds

  • Why I can't load external .swf boxes?

    Hello world...

    I am trying to load an external .swf that contains check boxes. The external .swf has a script in the applications folder on FMS3 server-side.

    When I insert the external .swf locally, it works fine.

    If I load the external .swf remotely with an Apache Web server, the external .swf is loaded but do not appear the boxes...

    Why?

    Please, help me...

    Emiliano.

    Are these components AS2 or AS3? If the latter, I would advise you to place the components in a RSLS (runtime shared library) and active in the external SWF, then reference the RSL.

    -Robert

    --

    Robert Reinhardt

    Creator, videoRx.com

    Author, series Bible Flash and video for Adobe Flash CS4 Professional Studio Techniques

    Adobe Community Expert

    http://blogs.flashsupport.com/Robert

  • Class to load an external .swf file

    Hello

    My flash application has many resources that will change all the time. In order to keep the user having to download my main .swf file over and over again and in order to maintain the size of the low main file, I want to put the resources into separate .swf files and load them dynamically from a url using a charger.

    Once downloaded, I would like to extract the classes that are in the file resources swf and use them in the main swf file. Can anyone share a code to do this? Note that I'm not only interested in using a symbol of the swf resource. I would use a class, with all its methods and everything, and my main swf does not contain the class definition. Does only the swf resource.

    Thank you!!

    It is a big question for flash programming.

    And when we know the answer to that, you are likely to use it on a daily basis as the programmers of high level of an agency.

    ApplicationDomain is your answer and the adobe documentation has a chapter on it.

    ApplicationDomain is where all of your classes will be loaded in and when you use a charger, you can target it with the laoderContext.

    AplicationDomain.currentDomain loads all classes in the main application and if your main application already has these classes, then the application uses the classes of parents

    New Application.Domain () specifies a separate repo of the classes that are loaded so that the classes in the main application will be confused by the classes in a loaded swf file. pertaining to the same names.

    This lock down communication between SWFs but uses the most recent child update classes when a child is loaded with the same class as the parents name.

    ApplicationDomain (currentDomain) new surround a new repo with the repo of parent of the class definitions.

  • totalFrames of dynamically loaded swf

    I tried for 2 days now to find the total number of images to a .swf dynamically loaded.

    Here is a code example:

    var loader:Loader = new Loader;
    loader.load(new URLRequest("mop.swf"))
    master_mc.addChild(loader);
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, xmlLoadedF);
    function xmlLoadedF(event:Event):void
    {
        trace(loader.content.totalFrames);
    }
    

    I am really puzzled.

    Any help would be greatly appreciated.

    I know it's old, but I found via google and thought I would correct the error.

    You can reference properties avm1 (and methods) swf using localconnection to communicate between SWFs avm1 and avm2, SWF SWF communication when two SWF files uses actionscript 3.0

  • AS2 loading swf that loads additional s AS2 swf into Flex

    My loaded AS2 swf can not seem to load the AS2 swf using loadMovie() and loadMovieNum().

    I have a file .mxml with a tag with an attribute of the source of mx:Image bound to a string variable. I can set this variable to a valid way to AS2 swf and swf file load as expected.

    However, the AS2 swf contains one or more statements loadMovie() to load additional SWFs 'child' in empty movieClips that fails silently.

    (I have to load several legacy/AS2 projects, I try to avoid the migration of these projects to AS3, also try to avoid incrustation of the SWF to the 'child' in a single AS2 swf).

    I tried both loadMovie and loadMovieNum, I change the publication for local file access and network access settings, I tried to replace the mx:Image bound by a mx:SWFLoader tag, tag none of these work. I even tried to switch the compiler Flex setting - use network.

    All the other features seem to work in the loaded AS2 swf.

    I found many posts/articles as intercommunication between an AS3 Flex swf and loading AS2 swf, but it's not my problem. I need not communication, a few features.

    Thanks in advance for any idea!

    OK, once more, during 5 minutes walk away a problem proved to be invaluable. I started to think that maybe there is a known issue with loadMovie(). Even if I was trying to avoid to touch the source code of these sovereign wealth funds AS2, I decided that it would be useful to test replacing loadMovie() by MovieClipLoader.loadClip () statements.

    It works! Even if it means that all the old AS2 files that I need to load will have to be revised, it is much less of a task of migrating to AS3 or incorporation of the swf file of the child in the movie alone. I hope at least that this will save someone else the frustration of trying to do the same thing.

  • With the help of a ClassLoader to load several SWF files?

    Hello community,

    Pulling my hair out on this one. I want to use a single charger (from the class Loader) to, in order, load a SWF to a single movieclip on the stage. I have a charger that I want to load external files: 'peel0.swf', 'peel1.swf',..., 'peel9.swf' in 10 corresponding clips (that already exist on my scene): 'peel0_mc', 'peel1_mc',..., 'peel9_mc '.

    The problem with my code is that it does not load, but the last peel. Everything seems to be cranking away as you like, until I have look at the contents of my peeling - only the 'peel9_mc' Gets the external file "peel9.swf" in charge. When I slow down things with 'Simulate download' I see the 0-8 "peelX_mc" loaded with the correct SWF but when the 'loop' moves to the next line, it disappears from the mc. It's as if the *.addChild method does not stick.

    Any input would be greatly appreciated,

    -john

    VarioPegged!

    Yes! It worked like a charm. I do * love * this community.

    I sincerely appreciate your time and efforts to help me.

    Kind regards

    -john

  • Loading an AS2 Swf in AS3 project

    So, I have a need to load some AS2 SWF inherited in my new AS3 interface. To avoid communication problems, I created a proxy AS2 SWF that loads the existing sovereign funds and takes their calls of communication to convey to the interface via the class LocalConnection - the only method (as I understand it) that you can use to communicate between AS2 and AS3.

    I detected AS version when loading a SWF file in the interface and pass the load to the proxy if the version is not 3. The proxy load properly, but I start getting errors immediately. Let me paste code to show the following steps:

    First of all. Immediately, I get a StatusEvent error, even if the path is sent to the proxy and load properly.

    Then, when the complete event is triggered in the AS2 SWF - it sends a completion back to let the AS3 SWF know that she finished (and any manipulation to get at that time.) I have the following error:
    Error #2044: Unmanaged by the AsyncErrorEvent:. Text = Error #2095: flash.net.LocalConnection could not invoke the callback loadSwf. error = ReferenceError: Error #1069: loadSwf property not found on com.applied.flash.events.AS2Connect and there is no default value.

    Join the Code

    This is the code of AS2Proxy.swf.

    connection: LocalConnection var = new LocalConnection();

    Connection.Connect ("AS3Connect");

    {if (Path)}
    proxyLoader.contentPath = path;
    }

    connection.loadSwf = function (path: String) {}
    proxyLoader.contentPath = path;
    }

    proxyLoader.complete = function() {}
    Connection.Send ("AS3Connect", "swfLoaded", true);
    }

    function completion (): Void {}
    Connection.Send ("AS3Connect", "swfLoaded", true);
    }


    It's the AS2Connect class for the hearing which is sent by the AS2 SWF

    package com.applied.flash.events {}

    SerializableAttribute public class AS2Connect extends Object {}

    public function swfLoaded (value: Boolean): void {}
    trace (value);
    }
    }
    }

    Finally, it's all the code in the AS3 swf file

    connection: LocalConnection var = new LocalConnection();
    var myIP:String = connection.domain;
    Connection.client = new AS2Connect();
    try {}
    Connection.Connect ("AS3Connect");
    } catch (e) {}

    simulation.source = ModulePath + curPageXML.attribute ("Path") m:System.NET.SocketAddress.ToString ();
    contentPlayers.addChild (simulation);
    simulation.addEventListener (Event.INIT, doInitSim);

    function doInitSim(evt:Event):void {}
    If {(simulation.content.loaderInfo.actionScriptVersion > 2)
    simulation.addEventListener (Event.COMPLETE, doVideoReady);
    } else if (simulation.source! = InterfacePath + "AS2Proxy.swf") {}
    simulation.source = InterfacePath + "AS2Proxy.swf";
    simulation.addEventListener (Event.COMPLETE, doProxyReady);
    }
    }

    function doProxyReady(evt:Event):void {}
    Connection.Send ("AS3Connect", "loadSwf", ModulePath + loadedXML.Pages.Page [tree.selectedIndex].attribute("Path").toString ());
    connection.addEventListener (StatusEvent.STATUS, doStatus);
    }

    function doStatus (evt :*){
    trace (e);
    }

    Well, the component has worked well for me.

    Here's how I bypassed not being not able to change the former rulers.

    I created a new AS2 project that consists of a loading component and ASBTerminal component.

    I then added the code to operate the ASBTerminal. Knowing all the function calls _root or _level0 coming out the loaded SWF, I created a function for each and said the SBA to perform a function in the new interface, passing along and reformatting of arguments as needed.

    Then, I created for the interface AS3 call functions.

    loadSwf()
    sendStop()
    sendPlay()
    sendGotoAndStop()
    sendGotoAndPlay()

    Each of these passes call a function in the loading component. loadSwf sets the contentPath. sendStop... sends the appropriate call (play(), stop(), gotoAndPlay()), gotoAndStop().

    Then I add my custom, things functions that I could appeal to some of the former sovereign wealth funds, and whatever.

    So, there are 3 files of the chain when I load a legacy SWF file.

    1. the main interface of AS3
    2. the "proxy" AS2 swf loaded into the interface.
    3. the legacy AS2 swf that loads the proxy.

    The proxy acting as an intermediary between existing content and new content.

  • load the swf video

    So, I have already created my flash movie and I added the activeX container and everything works fine until I have create the .exe application.

    in the properties of the activeX > movie properties > what should I put for the load movie when I deploy the application on another computer. (I have already added the .swf file to the project)

    Lets say that the est...\sensor\sensor.exe application and the application will always be in the same folder how don't do so activeX load the movie in the same folder no mater if the folder is located in c:\ or f:\

    I hope I'm at least one semi-claire,

    Thank you

    You can use the information in path and of the function of path of the band on the current VI to determine the current path.  But the path for a VI that is embedded in a .exe is different from the development environment to be taken into account.  See this KB. http://digital.NI.com/public.nsf/allkb/FD7DE8BC8FFC256C862565F4006BE363

  • Load swf to the last image

    Hello

    I have several files SWF is meant to be read in order (like a book). I can load the previous swf file, but I need to go to the last image. Is this possible with the code that I have?

    lastPage2.addEventListener (MouseEvent.CLICK, fl_ClickToLoadUnloadSWF_1);

    Import fl.display.ProLoader;

    var fl_ProLoader_1: ProLoader;

    var fl_ToLoad_1:Boolean = true;

    function fl_ClickToLoadUnloadSWF_1(event:MouseEvent):void

    {

    If (fl_ToLoad_1)

    {

    fl_ProLoader_1 = new ProLoader();

    fl_ProLoader_1.load (new URLRequest ("CEAS_I_1_16.swf"));

    addChild (fl_ProLoader_1);

    }

    on the other

    {

    fl_ProLoader_1.Unload ();

    removeChild (fl_ProLoader_1);

    fl_ProLoader_1 = null;

    }

    fl_ToLoad_3 =! fl_ToLoad_1;

    }

    It doesn't work at all, but I could find another code that you suggested on another thread: go to a specific external swf image

    It worked!

    var loadmod2:Loader;

    lastSection.addEventListener (MouseEvent.CLICK, loadlast);

    function loadlast(e:MouseEvent):void

    {

    {if(!loadmod2)}

    loadmod2 = new Loader();

    loadmod2.contentLoaderInfo.addEventListener (Event.Complete, loadCompleteF);

    }

    loadmod2. Load (new URLRequest ("CEAS_I_1_16.swf"));

    }

    function loadCompleteF(e:Event):void {}

    addChild (loadmod2);

    MovieClip (loadmod2.content), .gotoAndPlay (33);

    }

  • Is there a way that Captivate 8 swf format can take focus when the html page loading?

    I am trying to create a project to 8 Captivate user can navigate using the keyboard or the PlayBar. I added buttons to slides with Page Up and Page Down shortcut keys, but the keyboard commands do not work until the user gave focus to the swf file by clicking in it, is there a way for the swf file take the focus automatically when loading? I tried changing the setting wmode to "opaque", but has not made a difference.

    Or are there keys or key combinations that will work even if the SWF is not developed?

    -Stuart

    Captivate has already an update script to throw. You can try adding the onload of body. Add the script to the head section

    then add the function in the body:

Maybe you are looking for

  • Firefox uses too much RAM

    After the update to Firefox 23 I had a lot of problems. The major problem I had is that Firefox uses up to the amount of memory RAM (from 2 GB for less than 5 tabs assets/load) and ends up crashing. After a few tests, I found that when I closed the t

  • Mac Pro notebook

    How can I remove an app that I tried to store down load from the application?

  • Printer all-in-one HP 6700: fax printer HP6700 can be used on a home wireless phone?

    Can I set up the function of my printer fax all-in-one HP6700 to work on my phone wireless at home?  And if so, how?  I have AT & T phone wireless home service so it is is no longer seen as a land line and taken them murals are not active.

  • I usually play stings Yahoo but now it will not load.

    Hi, I play usually stick to yahoo but it does not now?  It allows me to put the code fight to go to the bathroom, but then the custom of the open room, a box came saying caches? IV tried to play on other sites but it still will not let me get on all

  • KB2686509 cannot install with error 0x8007F0F4

    I tried to update the KB2686509 but fails with ErrorCode 0x8007F0F4