• Home
  • About
  • Contact Us
  • Gallery
  • Video
  • Archives
  • Site Map
Grab the RSS feed

FlashBannerOnline

FlashBannerOnline
  • Home
  • FlashBannerOnline
  • Free Downloads
  • General
  • Tutorials
    • Adobe AIR
    • CSS
    • Fireworks
    • Flash
      • ActionScript
    • FLEX
    • Javascript
      • JQuery
      • MooTools
    • PHP

AVM2 (AS3) to AVM1 (AS2/1) Communication via LocalConnection

  • ActionScript, Flash, Tutorials

    Posted on October 21st, 2009

    Written by Behrouz Pooladrag

    Related Posts

    • Sending Data from AVM2 (AS3) to AVM1 (AS2/AS1)
    • stage.width and stage.stageWidth in AS3
    • Flash Optimization – Activate & Deactivate Events

    Tags

    action script 2 load movie clip, actionscript, actionscript 2 avm2, adding avm1 movies flex, AS1, AS2, as2 as3, as2 firework, AS3, as3 avm1 clip stop, as3 loading external as1 movies, AVM1, avm1 avm2, avm1 loader, AVM2, avm2 -> avm1, Communication, flash as2 flex communication, flex localconnection external avm1, how to load actionscript 1 movie in as3, load as2 into as3 localconnection, load avm1 in as3, local connection as3, LocalConnection, localconnection actionscript 1, localconnection actionscript 3 example, localconnection as2 fla, localconnection avm2 to avm1, send bitmapdata through localconnection
    AVM2 (AS3) to AVM1 (AS2/1) Communication via LocalConnection

    The ActionScript virtual machine that runs ActionScript 3 code (AVM2) is completely different from the ActionScript virtual machin that runs ActionScript 1 and ActionScript 2 code (AVM1). Because of this, you cannot call commands in an AVM1 movie from and AVM2 movie or vise versa. The virtual machines just are not compatible in that respect and mostly run in their own kind of shell that allows it to only interact with code being played back in that same virtual machine. What that boils down to is that ActionScript 3 cannot talk to AS1 or AS2 – at least not directly.

    One thing these two virtual machines have in common is their implementation of LocalConnection. Both virtual machines deal with local connections in essentially the same way – enough that local connections in AVM1 can receive events from AVM2 and vise versa. So should you come into a situation where you would need a movie published in ActionScript 3 to communicate with a movie published in ActionScript 1 or 2, using local connection is the way to go.

    • LocalConnection AS2
    • LocalConnection AS3 (flash.net.LocalConnection)

    Example:

    // ActionScript 2 file, AS2animation.fla
    // one movie clip animation named animation_mc on the timeline

    // local connection instance to receive events
    var AVM_lc:LocalConnection = new LocalConnection();

    // stopAnimation event handler
    AVM_lc.stopAnimation = function(){
    animation_mc.stop();
    }

    // listen for events for “AVM2toAVM1″
    AVM_lc.connect(“AVM2toAVM1″);

    // ActionScript 3 file, AS3Loader.fla

    // local connection instance to communicate to AVM1 movie
    var AVM_lc:LocalConnection = new LocalConnection();

    // loader loads AVM1 movie
    var loader:Loader = new Loader();
    loader.load(new URLRequest(“AS2animation.swf”));
    addChild(loader);

    // when AVM1 movie is clicked, call stopPlayback
    loader.addEventListener(MouseEvent.CLICK, stopPlayback);

    function stopPlayback(event:MouseEvent):void {
    // send stopAnimation event to “AVM2toAVM1″ connection
    AVM_lc.send(“AVM2toAVM1″, “stopAnimation”);
    }

    The AS3 movie loads the AS2 movie into a Loader instance and places it on the screen. As it plays, the user can click the animation which calls stopPlayback sending the “stopAnimation” event to the local connection named “AVM2toAVM1″. The AS2 movie is then able to receive that event in its stopAnimation event handler and tell the animation_mc clip to stop.

    This entry was posted on Wednesday, October 21st, 2009 at 11:10 am and is filed under ActionScript, Flash, Tutorials. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

    You might also like

    Sending Data from AVM2 (AS3) to AVM1 (AS2/AS1) In Chapter 13, we showed how to use a LocalConnection to communicate between an AS3-based movie in Flash Player's...
    Using ActionScript 3.0 with PHP Loading External Variables Creating dynamic websites which combine the power of Flash or Flex with PHP is easier than ever with ActionScript...
    Flash Optimization – Freeing Memory Flash optimization is becoming increasing important & with alternative development tools that developers...
    Software SWF Encrypt for locking flash Do not use! Agency code and the lock on Flash ActionScript and especially relevant to the group of developers always flash...
  • 0 Comments

    Take a look at some of the responses we've had to this article.

  • Post a Comment

    Let us know what you thought.

  • Name:

    Email (required):

    Website:

    Message:

  • Ad Ad

  • FlashBannerOnline.Com

  • Subscribe

    Enter your email address:

    | More

  • Blogroll
    • Random Flash Banner!
  • Tag Cloud

    • actionscript addChild addEventListener Adobe AIR Air Animation AS2 AS3 as3 preloader Banner beginFill BitmapData blog.flashbanneronline.com Class CSS Date Class draw Flash flash.net.URLLoader flash banner free flash banner generator flash banner happy new year flashbanneronline FlashBannerOnline.com flash banner online free flash player function game getChildIndex Javascript lightbox Loading Mysql new year flash banner Object Optimization package PHP Sprite tot Tweener URLLoader URLRequest web XML
  • Recent Comment
    • Behrouz Pooladrag on Flash Optimization – Freezing And Unfreezing Objects
    • Valerie on Flash Optimization – Freezing And Unfreezing Objects
    • FlashLord on RSS Reader for FlashBannerOnline Blog!
    • Behrouz Pooladrag on Using ActionScript 3.0 with PHP Loading External Variables
    • LUN on Using ActionScript 3.0 with PHP Loading External Variables
  • RSS FlashBannerOnline
    • Happy New Year 2012 & Gift!
    • New Templates Oval Light Added to Flash Banner Online
    • FlashBannerOnline started in Arabic language
    • Happy New Year 2011
    • New Templates Christmas 2011 Added at Christmas!
    • New Templates angel animate Added to Flash Banner Online
    • Added Tow New Preloader (Pro Preloader , Rotate Preloader)
    • Happy New Year , by new Theme (Christmas 2010)
  • Add to Technorati Favorites

    Subscribe
  • Google
    Custom Search

Copyright © 2009 FlashBannerOnline - Powered by Wordpress.

FBO by