Communicate between SWF & Global static vars

Sorry for my inglish...
I’m having some problems on getting full communication between loaded SWFs. I'm totally stuck and my timing is running.
Suppose the following scenario:
Father-SWF has his own class and loads A-SWF and B-SWF. A and B SWF has his own class and package. To exchange values and run functions between SWF, I’m using a Global class with public static vars. Some of this vars are function, example:
GLOBAL CLASS WITH STATIC VARS (com. with other class and package beetween SWF)
package scripts
     public class GlobalAct
          public static var mainStage:Object;
          public static var myFuncGlobalA:Function;
          public static var myFuncGlobalB:Function;
MAIN CLASS FATHER SWF
package
     import flash.display.MovieClip;
     import scripts.GlobalAct;
     public class FatherClass extends
MovieClip
          public function FatherClass():void
               GlobalAct.mainStage
= this;
               GlobalAct.
myFuncGlobal = myFunc;
          public function myFunc():void
               //some wird stuff
A_SWF CLASS
package
scripts
     import flash.display.MovieClip;
     import scripts.GlobalAct;
     public class Layout extends
MovieClip
          private var someMc:MovieClip;
          public function Layout()
                someMc
= new MovieClip();
                someMc. addEventListener(MouseEvent.CLICK,
mouseFunc);
          public function mouseFunc (evt:MouseEvent):void
               GlobalAct. myFuncGlobalA ();
B_SWF CLASS
     Similar to A-SWF class but with other kind of functions…calling “GlobalAct.myFuncGlobalB();” for example.
This works great, when I run Father-SWF, it load every SWF and functions run from SWF to SWF.
The problem happens when I load Father-SWF in another SWF. There is a MAIN-SWF with his own set os class and a Global static vars Class.
MAIN-SWF loads a SWF that will load Father-SWF into the MAIN-SWF.
WORKING
Father-SWF -> many SWF that could load other SWF
NOT WORKING
Main SWF -> SWF -> Father-SWF -> many SWF that could load other SWF
When this happens none of the Global functions seems to work. The other Global vars seems OK, only function vars seems not to work.
I only get the error: “TypeError: Error #1006: value is not a function. at scripts::Layout/ mouseFunc ()” when I try to click a button inside A-SWF.
Does I lose my Global reference when loading the Father-SWF in another SWF?
How can I make this bullet proof and generic for every situation?
What’s the best oop practice to communicate between class and SWF on AS3?

I figured it out.
It's under the pop-up window. Select edit locations to select confirm.

Similar Messages

  • AS3: static vars and on-stage MC's

    hi,
    my basic problem is as follows:
    i have one swf which loads another one. both of them have
    document class.
    i want to access a variable of the main swf's class from the
    inner swf's
    class, so i turned that var into static. it works fine, as
    long as i don't
    access MC's on the main swf's stage from its class. i've
    tried to solve it
    using the 'ApplicationDomain' but it still fails.
    for testing purposes i've made 2 swf's - 'main.swf' and
    'inner.swf', where
    on the main's stage i've placed a button, with instance name
    'myBtn'.
    this is the main's class:
    package {
    import flash.display.MovieClip;
    import flash.display.Loader;
    import flash.net.URLRequest;
    import flash.system.*;
    import flash.events.*;
    public class MainClass extends MovieClip {
    private static var myStatic:String = "abc";
    private var ldLoader:Loader;
    public function MainClass(){
    loaderInfo.addEventListener(Event.INIT, myOnInit);
    private function myOnInit(eEvent){
    ldLoader = new Loader();
    var urlRequest = new URLRequest("inner.swf");
    var context:LoaderContext = new LoaderContext (false,
    ApplicationDomain.currentDomain);
    ldLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,
    completeHandler);
    ldLoader.load(urlRequest, context);
    this.myBtn.addEventListener(MouseEvent.MOUSE_UP,btnUp);
    private function btnUp(evt){
    trace("btn up");
    private function completeHandler(evt){
    var inner = this.addChild(evt.target.content);
    inner.myOnInit();
    static function get staticVar():String{
    return myStatic;
    this is the inner's class:
    package {
    import flash.display.MovieClip;
    public class InnerClass extends MovieClip{
    public function InnerClass(){}
    public function myOnInit(){
    trace(MainClass.staticVar);
    when i compile 'inner' i get the following error:
    1119: Access of possibly undefined property myBtn through a
    reference with
    static type MainClass.
    the only way to avoid this error is to comment the last line
    of the
    'myOnInit' function in the main class, however then there's
    no access to the
    main's MC's.
    any solution?
    thanks in advance,
    eRez
    www.allofme.com

    Hi,
    can you give us a bit of code ... that will help. And did you
    declare your movieClip before (and outside of) the constructor?
    Like this i mean:
    class RandImg{
    private var mcDefault:MovieClip; // --> here it is ..
    mcDefault
    public function RandImg(){ // --> cunstructor
    trace("mcDefault path = " + mcDefault);
    If mcDefault is not declare before and outside your
    constructor, its impossible for your class to access it. Of course
    you are probably aware of that .. but im trying to figure out what
    can be the problem .. just guessing.
    So please give us some code and we will try to help!

  • Can't communicate between JS and ExtendScript

    I tried this: (according to the docs it should work)
    In JS
    var csInterface = new CSInterface();
    csInterface.evalScript('$.test()', function(r){console.log(r)})
    In JSX
    $.test = function() {
                       alert("test");
                        return 65656;
    I'm seeing the alert, but the logged statement is empty. Anyone know how to communicate between the two?

    I tried a few ways but the only way I could do it properly was pretty involved:
    1) Use Socket.io to communicate between generator and extension
    2) When you want to raise an "event" from JSX, update generator settings, use a unique id for your event
    3) Parse the event in generator
    4) Emit the event from generator to extension.

  • Links between swfs

    HI ALL,
    I am writing a script to communicate between flash and Visual
    Basic.
    My main problem is that my swf is composed of two swf : Clip1
    which contains clip 2.
    and when I want to get a variable of clip 2 (getVariable
    function) : i get a communication error
    Code in clip 1 to load clip2 : loadMovieNum ("/clip2.swf",
    1);
    Inside clip 2 I define a variable abc that I want to access.
    Abc is declared in clip 2 at _level0
    Does any one have an idea on how to access level from the
    first swf clip 1 ?
    Thank you .

    If you where to run clip2.swf alone, any variable declared in
    clip2.swf can be referenced as varName or _level0.varName. But if
    the clip is been loaded from another clip like clip1.swf. Then the
    variable is not declared on _level0 but on the level specified as
    the second parameter of the loadMovie method. That is. if you
    loaded the movie like this: loadMovieNum ("/clip2.swf", 1); then
    clip2.swf becomes _level1 and not _level0. So if you want to access
    this variables you need to write _level1.varName

  • I have question about take folders.  After recording multiple takes on a project of say 16 tracks. Is there a way to switch between takes globally?  Instead of one at a time which is tedious.  I am talking about a situation where all tracks are being

    Oops , my body got put into the title sorry.   Anyway so when doing live recording and multiple takes of all tracks is there a way to switch between takes globally instead of switching them one by one?

    You used the data.  Verizon can not see what it was sued for.  However your phone can see whats apps used the data.  go to settings-data usage- there will be a place that says data usage cycle.  line the dates up with your cycle.  then there will be a bar graph below that   extend bother white bars one all the way to the left and one all the way to the right.  after those are extended below that will be a list of apps,  there should be one that used over 2 gb and that will show you what app used that data in her purse

  • Can NI-PSP be used to communicate between machines developed with different versions of LabVIEW?

    Hi all,
    A customer has a large PC application developed with LabVIEW 2010 SP1.
    They would like to add extend their system with a cRIO-9075. According to this document (ftp://ftp.ni.com/pub/devzone/tut/crio_software_versions.htm ), the minimum supported version of LabVIEW (with Scan Engine support) is LV 2011.
    To minimize risks, it is preferred that we don't upgrade LabVIEW for the main application, which is atively being used in production.
    I was thinking of developing the cRIO software in a newer version of LabVIEW (say, LV 2013 SP1), and using shared variables only to communicate between the PC and the cRIO.
    Is this a viable option? Does it matter if the PC and the cRIO have different versions of the LV runtime?

    It shouldn't matter, but then with shared variables you can never know for sure -- there are so many things that can make them break.
    You might be money ahead to write the comm using TCP/IP. You know that will work.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Communicate between two iviews

    Hi everyone, if i create two iviews. And i want to pass a variable from one iview to the other one by triggling an event .
    What technology can help me do that?  Thx~~

    Hi Louis,
        Communication between two iviews is accomplished by EPCF concept.
      Refer to this forum thread where Prakash Singh has clearly explained about the same
    Communicate between two iviews
    Hope this helps.
    Regards,
    Joshua Kiran

  • Communicate between separate VI's using OOP

    Hello,
    I have a question relating to how two separate labview programs can communicate with each other. Specifically I want to make a temperature controller using the OOP features of labview, and implement a Model-Viewer-Controller design.
    I would like the Controller Object to launch the Viewer (the GUI) object. My question is though, how will these objects communicate between themselves?
    The Viewer object is used to set the desired temperature, and display current temperature. Some how it must communicate this to the Controller object who will use its Model Object to create the correct response (i.e. change the set temperature of some hardware device, although generically the Model Object is an abstract class, to be implemented by it child classes), and then communicate back to the Viewer with the current temperature.
    I was wondering if the Vi server tools are the right for this?
    Thanks,
    Paul.

    Hi Bob, thanks for your post.
    Here is what I want to program using an object oriented approach.
    I want to make a temperature controller, which has three objects. A Controller Object, a model object, and a view object. The controller is a mediator between the model (which will talk to the hardware), and the view (which will display the current temperature, and where the set temperature can be changed).
    The controller will have a method like myController.addView(Object View), and addModel(). So when I run the controller and give it a View object, I want it to open a window with a temperature indicator, and a set temperature control. When the set temperature is changed, the view object will notify the controller of this change (using an event), and the controller will run a method on the Model object which will control some piece of hardware setting its Temperature to a new value. The model will also send events (from time to time) to tell the controller that the temperature (of the device) has changed. The controller will then tell the view to update its temperature indicator.
    I have found a nice article about implementing the Model-View-Controller design pattern using Java (I am a java programmer, trying to use labView). The article is here: http://java.sun.com/developer/technicalArticles/javase/mvc/
    I would like to program this in labView.
    Also I would like to make my code reusable as much as possible. So the controller, view, and model objects will all be abstract classes, to be implemented by code specific to the device. Also some devices will require more than one type of view object displaying the data in different ways.
    I hope this makes what I am trying to do more clear.
    So basically I want the View object to open a window with a temperature indicator and a set temperature control. I want the controller object to start the view object and tell it to open the window. But I am not sure how to do that with labView.
    Thanks, any advise will be valuable!
    Paul.

  • Communicate between TS Executions

    Hello,
    Communicating between two threads in TestStand is easy enough using the Notification step type, but it seems like notifications cannot be used to communicate between two different executions. Is it possible to use the notification step in TS to communicate between two different TS executions? What is the best way to send messages between two TS executions?
    Thanks,
    Kevin

    Scratch that. I believe I've realized notifications do work between executions.

  • Communicate between two backing beans

    Hi !
    How can I communicate between backing beens ?
    I would like to put data from Bean1 to Bean2.
    This is my code in Bean1, I try this:
    Bean2 b = new Bean2();
    //... b settings...
    //Map map = facesContext.getExternalContext().getRequestMap();
    //map.put("Bean2", b);
    HttpServletRequest request = (HttpServletRequest)facesContext.getExternalContext().getRequest();
    request.setAttribute("Bean2", b);
    So I put Bean2 instance in request, but JSF created new instance :(
    How can I solve this problem ?

    This article might give you some new insights: http://balusc.xs4all.nl/srv/dev-jep-com.html

  • Communicate between 2 ipads over internal wifi only

    Can I communicate between 2 ipads over internal wifi WITHOUT internet? They are on the same subnet and would have network access to each other, but it seems to IM or message between them it must go over the internet.

    If you want to message between the two iPads, yes you must be connected to the Internet as the messages are transmitted via Apple Servers.

  • Passing data parameter between SWF files

    Hello Xcelsius Gurus,
    Is it possible to pass data parameter between SWF files?
    If possible, how to achieve it?
    Thank you.
    Justine

    Hi,
    Thank you for the reference.  Little bit confused, please let me clarify. 
    I do not understand how the receiver SWF receieved the data parameter and process.
    For example, I have a parent dashboard and a child dashboard.  In the parent dashboard, I have set up combo box to filter the data.  And I want the data that I have selected in combo box to the child dashboard.
    To do this, first I need to setup the flash variable at the parent dashboard to fetch the data I selected.
    After this, how to link this data to the child dashboard?
    Furthermore, after the child dashboard received the data parameter, I need this data to insert into the spreadsheet so I can filter the data.  Is this possible?
    Thanks.
    Edited by: Justine Liu on Jan 19, 2010 3:11 PM

  • Dealing with a turn based application with using a global static variable

    Hi there. I read some articles about JavaFX concurrency,so as a newbie i have to practice on it. Now i'm trying to implement a turn based application that can be played among 3-6 players. Moreover, i use a scene imported from a .fxml file and i have to update it correctly depends on some calculations of each thread (in other word players ). My main issue is, i don't wanna use a while loop which checks the state of game like;
    while( GameState != State.GAME_OVER ){
         currentPlayer = GameBoard.getNextPlayer();
         // do some actions,calculations etc.
    So, i want to use worker threads instead of this while loop. I guess using Service class for iterating and assigning the next player will be suitable instead of using the while loop and Tasks for doing each player's calculation,or waiting for some responses from Human players on UI based,however, i'm struggling with two problems.
    There should a global static variable ( like GameState which is an Enumarator ) determines the state of the game,so it should be updated and should be checked by each turn. Is there any way to do this ?
    How can i get rid off this while loop ?
    I will appreciate for every answer. Thanks anyway.

    It shouldn't make too much difference. The basic idea is that you have a model class representing your game state (the Game class in jsmith's example). When a player makes a move, you update the state of the game. Since this will result in changes to the UI, this update should be performed on the FX Application Thread.
    If the player making the move is a human player, the move will likely be made by a user action (button press or mouse click, etc); this will be handled on the FX Application thread anyway.
    When the state of the game changes so it is the turn of an "artificial" player to make a move, have the object representing the artificial player calculate its next move, and then update the game state. Since this is a response to the game state changing (it's now the turn of the artificial player), this will also be on the FX Application Thread.
    The only (slight) complexity comes if the calculation of the move for the artificial player takes a long time. You don't want to perform this long running calculation on the FX Application Thread. The cleanest way to manage this is to launch a Task which calculates the desired move, and then updates the game state when the move is ready. So, something like this:
    GameState game = ... ;
    // UI is bound to the game state.
    ExecutorService executorService = ... ;
    final Player currentPlayer = game.getCurrentPlayer() ;
    final Task<Move> calculateMoveTask = new Task<Move>() {
         @Override
         public Move call() {
              Move move = // compute next move...
              return move ;
    calculateMoveTask.setOnSucceeded(new EventHandler<WorkerStateEvent>() {
         @Override
         public void handle(WorkerStateEvent event) {
              gameState.makeMove(currentPlayer, calculateMoveTask.getValue());
    executorService.submit(calculateMoveTask);
    If you're doing more threading than that, you're probably doing it wrong... . There should also be no need for anything to be held as a "global" static variable (the idea above is the only structural modification you need to the example posted by jsmith).

  • Any standard RFC there to communicate between satellite system and Solman?

    Hi Gurus,
                        Any standard RFC there to communicate between satellite system and Solman?
                   Thanks in advance.
    Regs,
    BBR.

    following four RFCs are created so as to initiate the communication between the satellite system and the solman system
    _READ, _TRUSTED, _BACK, _TMW
    but, you have to Read the Links and the Notes too to understand their names and their meaning
    http://help.sap.com/saphelp_sm310/helpdata/en/48/647e3ddf01910fe10000000a114084/content.htm
    http://help.sap.com/saphelp_sm310/helpdata/en/b3/dd773dd1210968e10000000a114084/frameset.htm
    http://www.slideshare.net/wlacaze/sap-solman-instguide-initial-customizing-presentation

  • Driver to communicate between LabVIEW and Omron CJ1G PLC

    I am trying to communicate between my Omron PLC (Model CJ1G) and LabVIEW.  I want to be able to read specific registers and be able to display and save the data in LabVIEW.
    I have the "Idustrial Automation Servers for OPC" CD but my PLC model no. doesn't appear under the Omron options.
    What other options do I have?
    Thanks, in advance,
    Felipe

    Hi Felipe:
    I checked in our PLC compatibility database and the only Omrom PLCs that are supported are the following: C20, C200, C500, C1000, C2000, CQM, and CPM1.
    The PLCs that are suppored in the IA OPC server is based on the driver dll that was supplied to us by Omron. When newer PLCs are released, they are not included in this dll and are thus not supported. You might want to contact Omron to see which OPC Server supports that PLC. You should be able to use any 3rd party OPC Server to work with DSC which will then be the OPC Client.
    Hope this helps.
    Best Regards,
    Jaideep

Maybe you are looking for