With the advent of ActionScript 3.0 and Flash CS3, Adobe took out the possibility of direct access between AS2 and AS3 clips. The next option (besides communication through servers and web services) is local connection. Until now, if you’d create a clip in Flash MX2004 or Flash 8, using AS2, and inside that clip you would load another .swf file (that too created with AS2), both clips would be able to have access to each other’s objects and functions. This is not the case anymore with the new AS3 files. An AS3 clip will not be able to access any objects or functions defined in the AS2 file that it has loaded, and the loaded AS2 file will not be able to access objects and functions defined in its’ parent, the AS3 clip. The only way for the two movie clips to communicate is to use the LocalConnection class. For an unexperienced user this could be a little troublesome: loading the AS2 file, verifying that it’s been correctly loaded, creating LocalConnection objects in both files and trying to connect them in order to be able to execute functions defined inside those files and on the objects existing in those files.

For this reason we developed the ActionScriptBridge components (ASBTerminal for AS2 and ASBContainer for AS3), to ease the work needed to be done so the two AS2 and AS3 movie clips could communicate. The user has only to drag and drop an instance of the components in the AS2 and AS3 clips, define the functions he needs to call and use the run method of the components to call the defined functions.

Now this is still a beta version, but it’s working pretty well. The ASBContainer loads an external AS2 .swf file and the two clips attempt to communicate with each other using LocalConnection objects. The user has only to set the instance names for the two component instances and set the source file to the ASBContainer instance. All the rest is done by the two components: loading the AS2 file and initiating the communication. The connection name for each of the LocalConnection objects is set automatically by the ASBContainer instance. Each connection has a uniquely generated name, encrypted using MD5. Once the ASBContainer has established a communication channel with the ASBTerminal instance, it will not accept any other connection. Each ASBContainer instance should load its’ own AS2 file and there shouldn’t be two ASBContainer instances loading the same file.

Further development will depend on user feedback on this project, so any ideas or comments are welcome.

25 Responses to “Interaction between ActionScript 2.0 and ActionScript 3.0 within the same project”

  1. raulpopa says:

    G. Skinner just released a class based bridge called SWFBridge, very nice, but more hardly to use, so if you want to check it out, here is the link.
    http://www.gskinner.com/blog/archives/2007/07/swfbridge_easie.html

    The SWFBridge is a small work around the LocalConnection class, so they have few mistakes inside their bridge, like these:
    1. you can’t open the same swf for more than 1 time on one single machine, not in different browsers not even in the same AS3 project, because of their method of using manual setting for connection including a connectionID
    2. you can’t expect returns from methods you call
    3. you can’t call methods anywhere inside the AS2.0 movie, because you don’t have the scope parameter nor the run command methods.

    ActionScriptBridge solved all these problems, and it is the best tool to load AS2.0 content inside AS3.0 projects and use it to communicate back and forth properly.

  2. freddy says:

    I’ve seen a bug with focus between as2 and as3

  3. negush says:

    Hi freddy,

    As I mentioned, this component is still a beta version, so it is possible for bugs to exist. But it would really help us to know exactly what the bug is about.

    Thanks.

  4. freddy says:

    well… I’m working with Gmap AS2 component (http://www.afcomponents.com/components/g_map/) into a as3 movie with dropdown and textfileds iu components… when the as2 movie get the focus it’s imposible write in the textfiled(as3) for example because the foucs jump to the as2 movie

  5. freddy says:

    I’m gettin the same trouble with the gskinner class… maybe a localconnection bug?

  6. freddy says:

    ok… the problem is when the as2 movie get the focus and then you try to get the focus in the as3 movie… the as2 movie don’t less the focus

  7. raulpopa says:

    I’m sure this is a common issue, it is a Flash Virtual Machine issue, somehow, it acts a bit of this. VM2 focuses and loses focus for VM1, but the VM1 does not even know that it is loaded inside a VM2 movie, and it is not able to lose focus unless you step out of the the entire flash movie or if you reload the as2 content.

    There should be some fscommand that you could use to get the focus on the AS3 movie again… from the as2 movie.

    You should write to Adobe about this issue, since it is their issue.

  8. Wigz says:

    Just set GMap.enabled = false; and it should work fine. This will disable focus manager for GMap, but nothing else will be effected.

  9. shane says:

    Hi,

    i m updating my e-learning course player project with Flash cs3 and AS3.0. the old version of course player was in As2.0. which load cousre swf files .
    it was working fine Flash8 As2.0.
    the player load course swf. the loaded course swf on a specifec frame call a method like this
    _level0.setButton(2) method from course player;
    The setButton(parameter) method defination is in new courser player. the loaded movie which is in Actionscritp2.0 not finding this method
    in new course player which in Actionscript3.0. its working well with the old course player.
    can any one give me solution to solve the issue.

    i can’t make changes in course swf files b/c there are thousand of course files.
    i have used your nice component and also local connection classes
    but both are two way communication, so i have make changes in thousand of swf files of my cousrer ???

    regards

  10. Rajesh says:

    Hi,

    Its a very nice component. I am using this into our project.But there are few issues I am still facing it.

    1) Focus issues between as2 swf and as 3 swf.
    2) I have made connection between swf created using Flex and
    Flash 8. Communication happens only one way i.e. from AS 3 to AS 2
    but it is not happening the other way. How can i work around that.

    mxml code(hostAS3.mxml)
    ———————–

    public var uiComponent:UIComponent;
    public var conn:ASBContainer;

    private function initApp():void
    {
    uiComponent = new UIComponent();
    conn = new ASBContainer();
    conn.x = 100;
    conn.y = 100;
    conn.source = “myAS2.swf”;
    conn.boudingBox_mc.visible = true;

    conn.addEventListener(ASBEvent.INIT,initHandler);
    conn.addEventListener(ASBEvent.STATUS,statusHandler);
    conn.addEventListener(ASBEvent.CONNECT,connectHandler);
    conn.addEventListener(ASBEvent.ASB_RETURN,returnHandler);
    conn.addEventListener(SecurityErrorEvent.SECURITY_ERROR,asyncErrorHandler);

    uiComponent.addChild(conn);
    this.addChild(uiComponent);
    }

    public function asyncErrorHandler(aSyncEvt:AsyncErrorEvent):void
    {
    trace(“asyncErrorHandler”+aSyncEvt.text);
    }

    private function initHandler(event:ASBEvent):void
    {}

    private function statusHandler(event:ASBEvent):void
    {
    try
    {
    switch(event.level)
    {
    case “error”:
    trace(“Error in connecting”);
    break;

    case “status”:
    //conn.visible = false;
    trace(“Succeeded in connecting”);
    break;
    }
    }
    catch(err:Error)
    {
    trace(” error message “+err.message);
    trace(” “+ err.getStackTrace());
    }
    }

    private function connectHandler(event:ASBEvent):void
    {
    trace(“AS 3 -> in connectHandler”);
    conn.run(“test()”);
    }

    private function returnHandler(event:ASBEvent):void
    {
    Alert.show(“AS 3 -> returnHandler”);
    }

    public function callAS3():void
    {
    Alert.show(“Called from AS 2”);
    }

    //AS 2 code(myAS2.fla)
    ————
    var as2As3BridgeComp:MovieClip = null;
    var ASBTerminal_comp:MovieClip = null;
    ASBTerminal_comp = as2As3BridgeComp.attachMovie(“ASBTerminal”,”ASBTerminal_comp”,this.getNextHighestDepth());

    ASBTerminal_comp.addEventListener(“status”,statusHandler);
    ASBTerminal_comp.addEventListener(“asb_return”,asbReturnHandler);

    function test():Void
    {
    trace(“Calling from Flex”);
    }

    this.createClassObject(mx.controls.Button, “btnCallAS3″, this.getNextHighestDepth(),{label:”btnCallAS3”});
    btnCallAS3.addEventListener(“click”,btnCallAS3Click);

    function btnCallAS3Click()
    {
    trace(“btnCallAS3Click”);
    ASBTerminal_comp.run(“callAS3()”);
    }

    when i run this code it throws me error:
    Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095: flash.net.LocalConnection was unable to invoke callback getAndPass. error=ReferenceError: Error #1069: Property hostAS3_0 not found on _hostAS3_mx_managers_SystemManager and there is no default value.

    Please help me out…How I can solve this

  11. Rajesh says:

    I think it is something with the scoping issue in Flash. I am not sure what is wrong.I have properly included swc inside Flex by putting an instance of ASBContainer onto stage and publishing it as a swc. Also I have included ASBTerminal inside AS 2 code. I m not sure what is wrong but I have to solve this asap.Thanks

  12. Rajesh says:

    btw I am using Flex 2.0.1 and Flash 8 professional version.

  13. 194c01583a17 says:

    194c01583a17…

    194c01583a17bdac4959…

  14. Paul says:

    This is a great component. As far as I tested it, it seems to suit me very well.
    Thank you so much, it saves me so much trouble 🙂
    Keep up the good work

  15. Ashli Shay says:

    Sick of getting low numbers of useless traffic for your website? Well i wish to let you know about a brand new underground tactic that produces me personally $900 per day on 100% AUTOPILOT. I could truthfully be here all day and going into detail but why dont you simply check their site out? There is really a excellent video that explains everything. So if your seriously interested in producing easy hard cash this is the website for you. Auto Traffic Avalanche

  16. Tisha Gonce says:

    Do you mind if I quote a few of your articles as long as I provide credit and sources back to your webpage? My blog is in the exact same area of interest as yours and my visitors would really benefit from a lot of the information you present here. Please let me know if this alright with you. Thanks!

  17. Draw poker will be the traditional kind of
    poker and was played prolifically in high stakes cash games within the nineteenth century and early twentieth century.
    The Popularity of On line Poker – These days, online poker has changed into a popular option,
    making poker playing an available choice to a person with
    a laptop as well as an internet connection. Many top players advise against multi-tabling
    in any way, especially within the case of newer players, who should be focusing intently on staring at the players at their table,
    and paying close attention to exactly what happens.

  18. If you are playing online slots using real keep for sure,
    you should pay attention to some of this back you finally fail to bring house the victory.
    In this advanced mature you can law online slots in relation to
    everywhere, even to make transactions you can along with use online bank transfers
    or even on some sites you can create deposits using credit.

    Some things that you have to pay attention to are actually quite
    common, but people often ignore them and underestimate them, hence in the stop what happens is that the person loses all of the
    initial capital to bet. correspondingly you
    should begin reading anew and listening to some of the once that will
    make you skillful to enjoy online slot games without distressing
    virtually losing.

  19. For anybody who like to perform gambling and if you are looking for partners inside gambling activities,
    Mabosbet is the right choice. Mabosbetransfer You can contact our own customer support and make dealings with us.
    Mabosbet livechat is available 24 hrs nonstop and is
    prepared to serve you and help you online with betting.

    Mabosbet. com as a new responsible gambling agent,
    we always provide an option link to mabosbet to ensure members feel comfortable.
    You no longer require to have trouble obtaining an alternative Jababbet link with regard to access, it is already available for you.

    We also always give priority to the safety regarding our members, very strict protecting all of the privacy regarding
    members of Jababbet.

    Reliable Mabosbet From 2010

    Together with good praise, the support from the Headquarters is usually no doubt.
    Friendly, quick response, under 3 mins.

    Mabosbet is highly appreciated by gambling bettors through Indonesia because whatever success you get is going to be accepted
    by mabosvip. We usually want to provide the great for members with optimum service.
    The site mabosmail. com is also very straightforward to
    access, when you only want internet access and alternative links mabosvip, no require to use proxies, notifications,
    or troublesome applications.

    That will is why many individuals join mabosbola and make deposits, then, win typically the match.
    The best plus quality alternative mabosbola option site.

    Come join mabosbet. com the trusted on the internet
    gambling agent in Philippines. Contact livechat mabosbet today
    in the lower right corner to get a user ID.
    Welcome in order to the club.

    MABOSBET is usually a Trusted Online Wagering Site that has recently been established for more than 9 years with the particular most significant number of online gambling players.
    This gambling web site also provides the most satisfactory online gambling game along with the most
    popular gambling providers in Indonesia. On-line Gambling Games that can be played at MABOSBET
    are Sportsbook Soccer Wagering, Live Casino, Internet poker Card Gambling, Online Slot Gambling and
    Online Togel. Mabosbet itself has provided many different excellent facilities for internet gambling players in Indonesia which range from 24-hour Live Chat Support, Bonuses with the
    easiest conditions, additional wins with regard to True
    Gambling Players.

    This particular MABOSBET Gambling Site likewise proves
    to be very reliable, while this Gambling Internet site can also pay regarding any winning player with no deductions.
    So you will play gambling comfortably and safely without anxiety about spending.
    In addition to a new definite win at MABOSBET, you will also supply
    additional bonuses to supply a different experience playing online gambling.

    JOBI GOLF BALL OFFICIAL SBOBET ONLINE WITHIN INDONESIA
    Online Soccer Betting has become a extremely popular online gambling game inside Indonesia where every game has a market regarding betting.
    MABOSBET has become a great official partner of SGD777 Indonesia, where more
    than a decade has provided soccer gambling games for betting players in Indonesia.

    This SBOBET Soccer Gambling Industry allows a fair where players will actually
    be given the live market from your official match directly.
    Which means you will be very lucky to be able to play SBOBET in this specific MABOSBET.

    RELIABLE ONLINE SLOT MACHINE GAME SITE SITE WITH MANY
    PROFITS
    Online slot gambling is currently popular in Philippines, where online slots are incredibly lucrative with huge jackpots
    and freespins that are simple to win. Because regarding that this
    MABOSBET very first provided Online Slot Video games from 2012 for betting players in Indonesia.
    Exactly where Jackpot is provided a lot more than USD $ 1, 000, 000 for slot machine players who register in MABOSBET.
    The Slot Game machine at MABOSBET won’t just use your Balance, the Slot Game provides been built with the FREESPIN Bonus
    that comes out more often, so an individual is going to be
    Fortunately.

  20. Promosbobet says:

    Any of these sites that provides the best
    internet gambling game services in Philippines is Promosbobet.
    On-line bookie sites of which can provide direct access from home via
    typically the internet network and will be a good alternative to enhance bettors’ income without spending
    a lot regarding capital.

    Imagine, with only relatively affordable capital, members can play one of the most thrilling betting games of which members want such as
    soccer betting, online casino, or even real cash online slots, and
    of course get the financial benefits that members need.
    Almost everything a member can perform just by becoming an official member regarding the best and many trusted online bookmaker site Promosbobet.

    The greatest Online Gambling Promotion
    Bettors can get various types regarding benefits by turning into a
    member of the Promosbobet betting site. This site always provides remarkable promotions for brand
    spanking new customers and loyal consumers who have selected Promosbobet as a new betting partner
    for years.

    Deposit Bonus – the 1st bonus that a new member could
    get by becoming a fellow member of Promosbobet is when the fellow member makes a downpayment using a minimum associated with IDR
    100, 000 only! Bettors can get bonuses of up to almost 2 million rupiah.

    Winning Added bonus – just by simply playing online sports gambling that a person want or experiencing the fun in addition to
    challenges of capturing fish games, a person have a
    opportunity to win a earning bonus of upwards to 50%.

    Procuring & Rebate Bonus – by working with Sbobet and Maxbet, Mabosbet gives an individual the
    chance to get an immediate 5% cashback and 75% rebate!

  21. crownslot says:

    Tyre of Fortune: Showmanship Edition

    Wheel of Fortune is among the best online casino online games you can play in 2019,
    also it was developed by a company usually cited since the greatest
    casino developer, IGT. If you’ve observed the Wheel of Fortune show
    before, you probably realize how it performs.
    In this game, you play the role of one of the contestants,
    and it can your decision how very much money you would like
    to guess about each spin.

    this game lets a person win a whole lot of money when you are fortunate.

    The income could be huge, but an individual must wager a few cash to have it.

    this game is usually amazing for everybody who
    is playing the game and wants to be a part of
    the display rather than just observing it on TV, watching other folks get excited although they are seated at home.
    In case you have actually wished to be the part of typically the Wheel of Lot of money, this online casino may be what you are
    looking for!

    How Does Wheel associated with Fortune: Hollywood Release Work?

    This online game is in reality a representation of the famous TELEVISION show,
    where an individual gamble the gamble and spin the
    wheel. Your income increase according to exactly how much money
    you bet, however they usually are also tied in order to the payoff an individual get.

    Apart from that, this particular game has a lot more features
    to supply. A person get a chance to obtain a
    random jackpot bonus. This is seen when you spin and rewrite the jackpot wheel and an icon appears on the display – with each and every spin you choose, the jackpot increases.

  22. Jacquie says:

    welcome and thank you for visiting online casino agents for Indonesia.
    Here we are here to find the money for entry for fans of
    sbobet casino who want to connect the international agent site Promosbobet.

    The products offered are no question diverse and are enormously the best choice.
    Derived from providers that have credibility and have been proven to have the best predicate in serving their customers.

    Providers afterward Sbobet, Maxbet and many more.

    As the best online casino and soccer gambling site in Indonesia.
    We manage to pay for maximum assistance once customer withhold that works
    online 24 full hours every day. therefore members can comport yourself whenever and wherever without fearing to slope the possibility
    of difficulties or confusion.

  23. Robin says:

    Bola tangkas is the biggest city in Parts of asia that has been awarded several times for providing the best facilities
    and services. Sbobet has also pocketed several legal betting licenses in several states which make it
    legal to market online betting. Sbomabos as a trusted official bola tangkas agent
    that has been around since 2010 also follows the criteria of its official service provider.
    Sbomabos is now the sbobet sign in provider site that provides 24/7 service to all
    Indonesian online gambling users. Sbomabos as a sbobet gambling agent that has received official permission from PAGCOR and is centered in the Thailand so it is legal to promote products from our providers.
    We here provide transaction processing under 3 minutes from small to large minimal.

    The way to Login to the Sbobet Philippines Internet
    site
    Sbobet is an official website that always provides updated alternative backlinks so that users
    can easily access the sbobet website. Right now all sbobet login information can contact
    customer service from the required sbomabos website.
    Members who have completed registration at sbomabos
    can follow steps to login sbobet such as accessing the sbowin. com site, coming into the username and password
    provided by our cs. The sbo system also prioritizes member
    security after logging in, for the first time the
    member will be questioned to enter a new password.
    Members can also change their own username on the official sbo website.

  24. www.l69.me says:

    Option Link l69
    L69 is one of the official sites that provide the newest alternative link trusted online betting
    sites. L69 provides more than one alternative link from each
    and every betting site, and all of us here have become the most comprehensive alternative
    link providers and the L69 site includes a responsive display that will makes it easy
    that you can access our site coming from the display of your current gizmo or laptop.
    And what you need to understand is that we here have only 1 official link, l69.
    me and if there are usually other websites that provide
    information or call our own website is not our official site.

    Ball betting and casino gambling usually are types of games that are incredibly popular with the
    individuals of Indonesia. Why l69? Because we have been here for a lot more than five years
    and have become the trust associated with the people of Dalam negri as a location to
    play soccer gambling as well as on-line casino gambling. Itself has additionally
    obtained a license coming from the Asian and European governments in 2009 to turn out to be
    an online gambling wagering provider site in Parts of asia and Europe.
    By providing many different types of gambling bets that may be played on one ID,
    much more the members feel happy playing in your bookie.

    Great things about Alternative Links l69
    Yet however lately there are many members who knowledge problems and problems whenever entering into their Bola tangkas game
    since the Sbobet web site is usually blocked and several aged sites have been obstructed by the Indonesian authorities and never a few are also afflicted
    by what is called the Newsletter Task. The Indonesian government
    these days is struggling to eliminate links or paths to access sites that
    smell regarding pornography, gambling and there are a great many other content that is deemed inappropriate.

  25. sbobet says:

    THE BEST AND RELIABLE SBOBET JUDI BANDAR

    Agen-338a is an online bookie that works officially with the sbobet provider.
    Agen-338a has served betting members from 2010 until now
    and it has never given dissatisfaction in conditions of sbobet login. We are also one of the sbobet agents who
    have received several awards and have now become the number one site in Philippines.
    We have been also a site that is visited straight from the official sbobet
    provider to be trusted with marketing sports gambling products, casinos, slots, shooting fish,
    etc. for the Indonesian community. Each day there are more than 10, 500
    members who positively play on our official site and offer reviews that are very satisfied choosing all of us
    as the partner agent. Our brand searches also go beyond 10,
    000 lookups per day and we are a daily service site.

    Exactly how to Register a Sbobet Account
    We provide official sbobet accounts registration for all members who
    want to join without any fees or requirements. We also what is simplicity in the sbobet list, because to complete
    the sbobet account registration process, only confirmation is needed that
    you are 18+ and also have a local financial institution to make dealings.
    Sign up for sbobet can be through the registration form on the
    official website of Agen-338a or through our customer service who is
    willing to help you at any time. After filling in the registration form, the member just has to activate the ID
    with affirmation via our cs.

Leave a Reply