AS 3.0 - & gt; communication between classes

Hi all

Here's a good question, that nobody seems to have all the answers for... I searched on the net and it is not really that much info at all, so I'm assuming that we AS 3.0 people do a little "trail blazing", so to speak.

Here's my problem:

I would have a particularly modular interface, such as the main movieclip can load in modular pieces and insert them in a framework and have this operation as a 'window' in the Flash. The charger for the movieclip must be dynamic. I'll abstain not harder and get to the point of my question:

Let's say you have created a class to a movieclip 'circle', which is created in its very own .fla with its own (circle.as) class file that extends the movieclip class. Now let's consider this circle is one of the modules in the base movieclip that will load dynamically.

The circle movieclip loads, but now you want to communicate with the movieclip of circle and for example, question him and ask him what color his circle is. Surely, we would create a function in the circle class, something like the following:
public void getColor (): {of color
Return circlecolor;
};

On the main movieclip, we questioned this file that has been loaded, and you can imagine the code to resemble the following:
public void objectLoaded(event:Event):void {}
trace ("circleloaded! And Flash coders rule! ») ;
trace ("the color of this new object is" + event.content.getColor ());
};

Now my problem is that I can't connect at all! Test and debugging, it seems that the film circle will not even look at the scene as the root timeline (it will look at the charger as its personal root, I think!). Does anyone have ideas on how we can get some kind of a channel of communication between the classes of movieclip that are loaded dynamically in this mode?


Yes sorry I forgot:
You must send the object to a MovieClip for her to work. Full code:

the Circle.as class

package {}
import flash.display.MovieClip;

SerializableAttribute public class Circle extends MovieClip {}
var circlecolor:Number = 0xFF0000;

public void getColor (): number {}
Return circlecolor;
}
}
}

This class must be attached to the document (in my case loaded.swf), use the property inspector.

The following code goes into the swf loader:

import flash.events. *;
import flash.display. *;
flash.net import. *;

var ldr:Loader = new Loader();
ldr.contentLoaderInfo.addEventListener (Event.COMPLETE, onCircleLoaded);
LDR. Load (new URLRequest ("loaded.swf"));
addChild (ldr);

function onCircleLoaded(event:Event):void {}
trace ("the color is:" + MovieClip (event.target.content) .getColor ());
}

That's all

Tags: Adobe Animate

Similar Questions

  • question on communication between classes

    I am trying to learn AS3 and am confused as to whether you can communicate between the class of document and other classes in a program or if you can communicate between the two classes in a program by using the getters and setters. Whenever I try it I always get errors. Thank you

    Please check the answers then!

  • OOP communication between classes. Help, please!

    It is a slight continuation to a previous topic I posted.

    Description

    control_Class - is the attached main class dtö the .fla this class contains this line of code

    addChild (levels_bg)

    levels_bg -is a movieClip that has its own class of Levels_BG

    Levels_BG - after user selection his work monitoring

    control_Class.startlevel (e.currentTarget.shape_obj.text_box. (Text);

    which is a function in the control_Class:

    static public void startlevel (levelname:String): String

    {

    trace (LevelName.substr(LevelName.Length-1,LevelName.Length));

    }

    My problem is that when in this function, I can't draw or use one of the functions or variable in control_Class.

    for example.

    static public void startlevel (levelname:String): String

    {

    trace (LevelName.substr(LevelName.Length-1,LevelName.Length));

    RunThis();

    }

    private function runthis (): void

    {

    trace ("it works")

    }

    Hope someone could help me with this. Relatively new to OOP and I don't know if I'm doing this right.

    See you soon,.

    Pavel




    you will need to use static variables in control_Class.  I'm not sure it's a good Setup, but you have no instance control_Class shown in your code.

  • communication between classes

    I have a class calling another class. When the called class is made to do what its supposed to do its supposed to shipping and the event but his throw a type constraint error

    Here's the class using the

    package classes
    {
         import flash.events.Event;
         import flash.events.EventDispatcher;
         
         import mx.collections.ArrayCollection;
         import mx.rpc.events.ResultEvent;
         
         public class InitJobDetails extends EventDispatcher {
              
              public var HTTPC:HttpQueery; //Takes 3 Parameters - Params, Url Method
              private var _params:Object = new Object();
              public var _opsArr:ArrayCollection;
              
              public function InitJobDetails(event:Event) {
              _params["id"] = event.currentTarget.selectedItem.jobid;
              HTTPC = new HttpQueery(_params,"http://10.16.1.53/viewjobops.php","POST");
              HTTPC.addEventListener("Completed", notifymain);
              }
              
              private function notifymain(event:ResultEvent):void {
                   _opsArr = HTTPC._tempArray;
                   dispatchEvent(new Event("notifyMain"));
              }
    
         }
    }
    
    

    and here is the class called

    package classes
    {
         //Takes 3 Parameters - Params, Url Method
         import flash.events.Event;
         import flash.events.EventDispatcher;
         
         import mx.collections.ArrayCollection;
         import mx.rpc.events.ResultEvent;
         import mx.rpc.http.HTTPService;
         
         public class HttpQueery extends EventDispatcher {
              private var params:Object = new Object();
              private var _url:String;
              private var _method:String;
              public var _tempArray:ArrayCollection;
              public var RPF:ResultProxyFix;
              
              public function HttpQueery(Qparams:Object, Qurl:String, Qmethod:String) {
         
                   params = Qparams;
                   _url = Qurl;
                   _method = Qmethod;
                   
                   var QY:HTTPService = new HTTPService;
                   QY.url = _url;
                   QY.method = _method;
                   QY.addEventListener(ResultEvent.RESULT, completed);
                   QY.send(params);
                   }
         
         
         
              private function completed(event:ResultEvent):void {
              RPF = new ResultProxyFix(event);
              _tempArray = RPF.tempArray;
              dispatchEvent(new Event("Completed"));
              }
         }
    }
    
    

    The error is thrown when this class attempts to send the "Completed" event if I have my data on the http request. Am I doing this wrong?

    Below the error is thrown

    TypeError: Error #1034: Type coercion failed: cannot convert flash.events::Event@1d369be1 to mx.rpc.events.ResultEvent.

    to::EventDispatcher/dispatchEventFunction() flash.events

    to::EventDispatcher/dispatchEvent() flash.events

    class::HttpQueery/completed() [/ Users/jorgepease/Documents/Flex Builder 3/ArrowmailJobBoard/src/classes/HttpQueery.as:36]

    to::EventDispatcher/dispatchEventFunction() flash.events

    to::EventDispatcher/dispatchEvent() flash.events

    to mx.rpc::AbstractInvoker /http://www.adobe.com/2006/flex/mx/internal:dispatchRpcEvent ([C:\autobuild\3.2.0\framewor ks\projects\rpc\src\mx\rpc\AbstractInvoker.as:170])

    to mx.rpc::AbstractInvoker /http://www.adobe.com/2006/flex/mx/internal:resultHandler ([C:\autobuild\3.2.0\frameworks\ projects\rpc\src\mx\rpc\AbstractInvoker.as:193])

    at mx.rpc::Responder/result() [C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\Responde r.as:43]

    at mx.rpc::AsyncRequest/acknowledge() [C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\ AsyncRequest.as:74]

    to DirectHTTPMessageResponder / completeHandler ([C:\autobuild\3.2.0\frameworks\projects\rpc\s rc\mx\messaging\channels\DirectHTTPChannel.as:403])

    to::EventDispatcher/dispatchEventFunction() flash.events

    to::EventDispatcher/dispatchEvent() flash.events

    to flash.net::URLLoader/onComplete()

    Thanks for your help

    private void notifymain(event:ResultEvent):void {}

    Expected a ResultEvent and you are sending an ordinary event

  • Communication between HP eprint and Google Cloud Print

    Hello

    communication between HP eprint and Google Cloud Print seems to be broken. At least for me.

    Documents to print when I print vio Chrome browser or Cloud Print dashboard - but the State in the clouds print remains "submitted". It seems that somehow the HP eprint status doen't get referred to cloud print. In HP eprintcenter paper says "printed".

    Well, I wonder who will take care of this problem...  (Hope this does not lead to fingerpointing only...)

    Thanks for your support!

    Best,

    George

    Started more work, a few weeks ago. All is well now. Don't know who that sets well.

  • No communication between the Bluetooth SD - BT2 and PocketPC SD card

    I use an SD - BT2 (PA3271U) card in a Microsoft Pocket PC (also referred to as 'Microsoft PocketPC 2003') 4.20.00. I use the latest driver Toshiba 5.01 C and the card is recognized by the Pocket PC (Medion MD 95450 / MDPPC 150). I can connect to my mobile phone and GPRS connection is accumulation with no problems.

    But later at this point in time, the connection is established but dead... no connection to anyone. It seems that the communication between the Pocket PC and the card SD - BT2 is broken on the software side.

    Anyone have an idea (or a working driver) for this problem?

    Thanks in advance

    Karl

    Hello

    Have you tried to reinstall the drivers or software for SD - BT2?
    In my opinion, you should check this option.
    Also, I found a brand new version for PDA Bluetooth Stack (Bluetooth software and drivers).
    Check out this site.
    http://APS.toshiba-tro.de/Bluetooth/pages/download.php.

    Good bye

  • Communication between Labview and Rn42 Bluetooth

    Hello

    I am currently working on a project that requires communication between a bluetooth equipment and my pc with bluetooth built-in. The bluetooth hardware is verfied working with Blueterm on android. However I'm unable to connect with my laptop blueterm. Is back a unabe to connect error. I use bluetooth vi without series or visa. This method is suggested? Thank you


  • Best method of communication between the Application LV

    Hello together,

    I'm looking for the best way of communication between two Applications LabVIEW. As VI is clear, I can use a queue or a global variable and so on.

    But what is the best, when I compile the screw later for DLLs or Applications. So far, we always use the TCP/IP Protocol, but I think that there must be a better way instead.

    So if someone has an idea - he is welcome.

    Thanks in advance

    Markus

    TRAXX wrote:

    What I don't like with TCP/IP you still need a second thread (looped) who manages the TCP/IP communication. I thought that there must be an easier way.

    I also thought that shared variables are always limited to a single application. Thanks for the ideas...

    This second loop is a loop that YOU control. If you go with shared variables you are a slave to what they can or cannot do. In addition, they work over TCP/IP is not out of the picture.

    Its your call.

    Ben

  • No communication between the printer and the Red computer on switch flashing printer does on every time I turn it off

    I get a message there is no communication between the printer and the computer. Printer is all-in-one HP Officejet 4315v. Have uninstalled and reinstall the software and unplug the USB port and plug it back. Repeated several times. Still no communication. Exclamation red light next to 'on' and green button 'on' butter is flashing all the time.

    You have a hardware failure of the printer.  Contact the manufacturer for support.

  • communication between the printer and the computer stops

    Original title: printer problem

    Without rhyme or reason communication between our computer and the printer just stops (often!)   Why?  and how to fix it?

    Hello

    ·                         try to uninstall and reinstall and use the latest printer drivers VISTA for your model of the manufacturer of the printer

    You can also track information to try to solve your problems of printer below

    read the printer correct that information the slot microsoft, including the 'fix - it' and the information of the links to the other

    Solve printer problems

    http://Windows.Microsoft.com/en-us/Windows-Vista/troubleshoot-printer-problems

    and read this microsoft tutorial too

    Introduction

    This tutorial is designed to help you identify and fix the problem printer common windows problems, including print errors, or errors, and other issues that could prevent you from printing. This tutorial does not cover printing problems related to specific programs. Printing problems can be caused by cables that are not properly connected, corrupt, drivers, incompatible drivers, the printer settings, missing updates and problems with your printer.

    How to use this tutorial

    For best results, complete each step before move you on to the next. Try to print after each step before moving on to the next step.

    http://Windows.Microsoft.com/en-us/Windows/help/printer-problems-in-Windows

  • Need help configuration IOS IPsec to enable communication between the VPN client

    Hi, I need help with the configuration of IPsec VPN router 2811. I want to allow communication between VPN clients, is that possible? I know that ASA, you can do this by using the command "permit same-security-traffic intra-interface".

    The fact is that each Client IP communicator installed, but when they tried to call each other, he failed. I guess that's because the connectivity between them is not permitted because of the VPN connection.

    Thanks in advance...

    Hello

    Try this: -.

    local pool IP 192.168.1.1 ippool 192.168.1.5

    access-list 1 permit host 192.168.1.2< vpn="" ip="" addr="" of="" client="">

    access-list 1 permit host 192.168.1.3< vpn="" ip="" addr="" of="" client="">

    access-list 1 permit 10.10.10.0 0.0.0.255

    < lan="" behind="" the="">

    ISAKMP crypto client configuration group vpnclient

    key cisco123

    ACL 1< binding="" the="" acl="">

    !

    --------Done-------------

    If you do NAT on the router then you might want to exempt your VPN traffic to be NAt had

    Assuming that the NAT of your router is

    overload of IP nat inside source list 111 interface FastEthernet1/0

    !

    ! - The access list is used to specify which traffic

    ! - must be translated to the outside Internet.

    access-list 111 deny ip 10.10.10.0 0.0.0.255 192.168.1.0 0.0.0.255

    access-list 111 deny ip 192.168.1.0 0.0.0.255 192.168.1.0 0.0.0.255

    Above two statements are exempt from nat traffic.

    access-list 111 allow ip 10.10.10.0 0.0.0.255 any<, permits="">

    I would like to know if it worked for you.

    Concerning

    M

  • Encrypted L3 Communications between the TOWER and WLC?

    Hi all

    I work with a client who wants to put the towers away to their WLC (a 4402). The problem is that communications between the TOWER and WLC must be secured, even through their private Wan! I have a few questions that result, if someone is able to help you;

    1. I can't know if and what method of encryption is (is it AES etc.?) used on connections between towers and the WLC and what are the steps?

      1. The terminology can be a problem here, it's not a wireless mesh, just classic LAP for WLC
    2. EXTENSIVE customer network is already encrypted (IPSec VPN via VPLS) in parts - what is the consequence of execution of AP<-->WLC with end to end (if possible) on a network encryption EXTENDED with IPSec, i.e. double encryption?

    Strange but true - pointers will be greatly appreciated... Phil.C

    With a controller of the 4400 series, the control traffic between the AP and the regulator is already encrypted AES.  The user traffic is not encrypted.  If you use a 5508 controller all traffic between the AP and the controller is encrypted AES.

    For what is running the traffic through a VPN, it should work.  The issue I see with this is with the MTU in general.  The controller will drop all packets with a payload of less than 32bytes data.  According to the MTU over the VPN I've seen packets getting fragmented and it is a question.  If you use one of the versions CAPWAP (5.2 or newer) discovery dynamic MTU is part of the Protocol and this MTU problem does not really exist.

  • communication between master blocking and blocking fowarding sensor sensor

    1. how the communication between the master sensor blocking and blocking fowarding sensor take place?

    RDEP or SSL or SSH? Which one?

    Forwarding of blocking sensors will use RDEP more 443 (https) to communicate with the master blocking sensor.

    To ensure that the sensor of blocking of the Master to allow connections from sensors transfer blocking under the hosts permitted configuration section.

    Here's a link for how to do this with VEI:

    http://www.Cisco.com/univercd/CC/TD/doc/product/iaabu/csids/csids10/idmiev/swchap3.htm#32776

    Hope this helps,

    Peter

  • communication between machines in vmware.

    Hello.

    I have two machines in my vmware.

    I want to have a communicate with each other.

    I have set up a virtual network in vmware-NAT.

    Each of them has an ip address:

    Server Windows 2012 - 50.50.10.200

    Windows 7 - 50.50.10.5

    I'm doing a ping of windows 7 for server 2012 and I am not getting a response.

    So I don't see that they are communicating with each other.

    I'd appreciate your help.

    Mehdi neo

    If your two virtual machines to connect to the same virtual network NAT, they should have a communication between them, for you case "cannot get a response", please check if you have disabled the firewall in your server 2012

  • No communication between the primary and standby

    Hello

    I have configured the DG,

    primary-> testprod
    standby mode-> testprod_s
    I started, standby machine instance watch with testprod and its place...
    but there is no communication between the primary and standby...

    How can I ask/check communication?

    Heartbeat PING [ARC3]: Unable to connect to the day before "testprod_s". Error is 12514

    eve of post form

    status of $lsnrctl
    $lsnrctl services

    When oracle not registered with listener service, this kind of errors occurred.
    The value of register LOCAL_LISTENER & manually as below in sleep mode and post

    SQL > alter the registry system;

Maybe you are looking for

  • How to disable the photos app to compress the video?

    When to use photos app to manage the photo and video (for example, automatically import the iPhone for photos), if I drag a video in the library of photos on the desktop, the application can continue to block, without warning, without answers, I thou

  • IOS 9.3 there bugs for the iphone 6?

    Hi guys I have an iPhone 6 currently running in iOS 9.2.1 asked if it is wise to update the iOS to 9.3. Are they bugs in the new iPhone OS 6? Should I update the OS or not?

  • Tips for creating an application with web services please?

    I created a simple application for a client who interacts / monitors a device VISA with LV 2009.  The architecture is essentially a state machine with a timeout for VISA calls that retrieve the current state. The client asked that the app will also b

  • Error, you must be an administrator to run a console session using SFC

    Original title: vista administor have windows vista Home premium and it may seem silly, but how to administer privileges. Am the only one on the laptop so I thought I got them somehow, but not so much that when I tried to invite her command of my I g

  • Windows Firewall Security Center - does not work

    Help my firewall does not work I tried to turn it on and it says Security Center cannot enable Windows Firewall it supposed to turn it on manually I turn on manually and it does not turn.Is there another free way to turn it on.