AS2 swf to AS3 local Connection

Hello:
I am embedding multiple copies of a single AS2 swf build in
FLASH into a FLEX2 AS3 swf. I am using LocalConnection to
communicate from FLEX to the flash swfs. This exhibits the strange
behaviour that only the last loaded swf actually works correctly.
The swf is a told to gotoAndStop at a particular frame. I trace the
FLASH swf function and it is getting the correct frame number from
FLEX. But it does not work correctly.
see a samle at
http://www.miragevideo.com/test.html
The problem seems to be the localConnectin being shared by
three similar instances of the gauge class. Any ideas??
Here is the FLEX code
<?xml version="1.0"
encoding="utf-8"?>
<mx:Canvas xmlns:mx="
http://www.adobe.com/2006/mxml"
width="400" height="200"
horizontalScrollPolicy="off"
verticalScrollPolicy="off">
<mx:Image id="gaugeSWF"
source="@Embed(source='../../resources/gauge.swf')"
creationComplete="init();" />
<mx:Script>
<![CDATA[
import flash.net.LocalConnection;
private var toFlash_lc:LocalConnection = new
LocalConnection();
private var _amount:int;
private function init():void{
toFlash_lc.addEventListener(StatusEvent.STATUS, onStatus);
toFlash_lc.send("lc_from_Flex",
'setGauge',_amount) ;
public function set amount(val:int):void{
_amount = val;
private function onStatus(event:StatusEvent):void {
switch (event.level) {
case "status":
// trace("LocalConnection.send()
succeeded");
break;
case "error":
trace("LocalConnection.send() failed");
break;
]]>
</mx:Script>
</mx:Canvas>
and the FLASH code:
// Code in the receiving SWF file
var receiving_lc:LocalConnection = new LocalConnection();
receiving_lc.setGauge = function(frame:Number) {
trace("in flash frame= " + frame +
" angle: " + ((frame/100)*180));
mask._rotation = -(frame/100)*180;
angle.text = frame.toString();
receiving_lc.connect("lc_from_Flex");
stop();

You can only have 1 LocalConnection per sender/receiver. If I
have 2 SWFs, A and B. If I want A and B to send messages to each
other, I need 2 LocalConnections. If I have 3 SWFs and want
bi-directional communication between all of them, I'd need 6
LocalConnections. Add a 4th SWF and you'll need a total of 12 and
so forth.

Similar Messages

  • Load as2 swf in as3 swf

    Hi All,
    I am new to this forum.
    Can anyone tell me how to load as2 swf in as3?
    If this is possible,can anyone give me some sample example?
    Thanks
    Harshal

    You can talk to loaded AVM1 (AS1/2) SWF using LocalConnection. I used Grant Skinner's SWFBridge class in the past and worked very well:
    http://gskinner.com/blog/archives/2007/07/swfbridge_easie.html
    Kenneth Kawamoto
    http://www.materiaprima.co.uk/

  • Load AS2 swf into AS3 swf problem

    I have a flash with AS3 and inside this swf i load in a AS2 swf.
    to load swf works just fine, but the problem is when i load this i want to go to
    a specific part of it, for example i want to go to frame 3 in the loaded swf.
    i must control this from the AS3 swf, does someone know if this is possible?
    thanks in advance

    so can i do like this then to go to frame 3 in my loaded swf?
    MovieClip(ldr.content).gotoAndStop(3); ?
    sorry for being such an airhead
    thanks for helping me out =)
    Date: Sun, 7 Jun 2009 10:25:09 -0600
    From: [email protected]
    To: [email protected]
    Subject: load AS2 swf into AS3 swf problem
    no.
    if, in your loaded swf, you have a function f1() on the loaded swf's main timeline and you load that swf using a loader (say ldr), use:
    MovieClip(ldr.content).f1();   // to call f1() in the loaded swf
    >

  • Convert AS2 swf to AS3 swf

    I have a swf (written in AS3) that loads other swfs into it.
    There are no issues when loading other AS3 swfs but there is a
    problem loading AS2 swfs. I get the following error:
    TypeError: Error #1034: Type Coercion failed: cannot convert
    flash.display::AVM1Movie@35d3a51 to flash.display.MovieClip.
    Is there any way to convert the AS2 swf into a AS3 swf so it
    will be compatible with my loader? I cannot go back and change the
    AS2 swfs because I do not have the fla files. Or is there any way
    to incorporate AS3 code that will load AS2 swfs properly? It seems
    hard to believe that Adobe would neglect this backwards
    compatibility issue. Thanks

    Hello Andrei1,
    Thanks for looking at my simple AS3 code. The AS2 swfs that
    I've been working (and having difficulties) with are components
    that I've purchased from places like www.flashden.com. Some are
    image transitions (such as "Dynamic Image Draw found at
    http://www.flashden.net/item/dynamic-image-draw/7532)
    while another is used to create a looped banner rotator animation
    (IMG_loop, a free d/l from www.afcomponents.net). I have another
    that uses an .xml file to configure a slideshow animation.
    You mention "needing to do more" if AS2 scripts inside its
    swf are to be run by the parent AS3 fla; what would these lines of
    code be?
    In researching my problem further I've since realized that
    most of these issues deal both with the version of AS used, as well
    as the version of the Flash player the fla is set up to animate
    for. In particular, the "Dynamic Image Draw" component requires
    that Flash Player 8 or 9 be used with AS2.
    Given that many of my purchased components are like this,
    I've since changed my main fla movie from AS3 back to AS2 and have
    learned that the scripting needed to call individual multiple swfs
    into it at various points in the timeline is MUCH simpler!!!!! One
    single, easily interpreted, line of code vs. 5 lines using
    variables and much more arcane (to me) function calls.
    I started my file with AS3 figuring that I'd be better off
    learning the new version of the language; much stress and
    forehead-rubbing later, I've seen just how much easier and
    understandable AS2 is to learn.
    I recognize that there are likely very strong arguments for
    the more structured coding approach used by AS3, but for someone
    like me who wants to generate customized Flash presentations with
    little fuss, I'm not qualified to make them.
    Perhaps this is a no brainer for those many flash gurus out
    there, but for me this tiny bit of wisdom has been hard fought for!
    That being said, is there an easy way to convert a swf file
    created using AS2 to something that AS3 can work/interact with?
    I've come across a free d/l product called actionscript bridge, but
    haven't been able to understand how to get it to work.

  • Load AS2 SWF in AS3 SWF with FlashVars

    I am able to load SWF which is created using AS2 in to AS3
    SWF but I am not able to pass Flashvars to it..
    Does any one has any idea, how can I do that??
    Thanks

    You can talk to loaded AVM1 (AS1/2) SWF using LocalConnection. I used Grant Skinner's SWFBridge class in the past and worked very well:
    http://gskinner.com/blog/archives/2007/07/swfbridge_easie.html
    Kenneth Kawamoto
    http://www.materiaprima.co.uk/

  • How do you load an AS2 swf into AS3?

    I think this is the way around my dilemma. How do you load and AS2 .swf into an AS3 file?
    thanks again!
    Steve

    check that code in your last thread:
    What is the  code to load a .swf file in AS3 on the same layer?

  • AS2 .swf to AS3.swf

    This may have been posted somewhere else however I have created a series of AS2 .swfs and now that I am using captivate 5 i need to convert them to as3.swf
    Can anyone help

    That's going to depend on whether or not there's any AS2 code in your SWFs and how complex that code is.
    Did you create these SWFs in Flash?  If so, what version?  If it's Flash CS3 or above you should be able to open the original FLA files and change your publish settings to output as AS3.
    If you've programmed a lot of interactivity into these SWFs as AS2 and you don't know AS3, you'll need to either learn it yourself or pay someone that does.

  • Load AS2 swf into AS3 swf

    here is the code i'm using:
    var url:String = "avm1.swf";
    var urlrequest:URLRequest = new URLRequest(url);
    var loader:Loader = new Loader();
    loaderListener(loader.contentLoaderInfo);
    loader.load(urlrequest);
    function loaderListener(dispatched:IEventDispatcher){
    dispatched.addEventListener(Event.COMPLETE, assignSWF);
    function assignSWF(event:Event){
    addChild(loader.content);
    here is the error i get:
    It is illegal to move AVM1 content (AS1 or AS2) to a
    different part of the displayList when it has been loaded into AVM2
    (AS3) content.
    Is there a different way to do this?

    addChild(loader)

  • Loading AS2 swf in AS3 fails - sort of

    I have an AS 3.0 file that loads a 2.0 swf. That 2.0 swf
    loads other 2.0 swf.
    When running in the AS 3.0 shell, the file is loaded, but the
    onLoadComplete() function is not called. The clip is loading, but
    no mclListener events are raised. (ie: mclListener.onLoadError ,
    mclListener.onLoadProgress, etc.) If I load the same chain with an
    AS 2.0 parent, the events are raised.
    Any ideas why, or what to do about it???
    Thanks -
    This is the AS 3.0 code:
    //Load the editor.
    var loader:Loader = new Loader();
    var request:URLRequest = new URLRequest("BDAS_Editor.swf");
    loader.load(request);
    addChild(loader);
    This is the AS 2.0 code in the BDAS_Editor.swf:
    var my_mcl:MovieClipLoader = new MovieClipLoader();
    var mclListener:Object = new Object();
    my_mcl.addListener(mclListener);
    my_mcl.loadClip(myPath,Template_mc);
    mclListener.onLoadComplete = function(target_mc:MovieClip,
    status:Number):Void {
    trace("onLoadComplete " + target_mc);

    Ok I found it out (somewhere else).
    The reason was, that you can't use levels when you load content in AS3.
    That Version works:
    var my_mcl:MovieClipLoader = new MovieClipLoader();
    var mc:MovieClip;
    var myListener:Object = {
        onLoadInit: function(target_mc:MovieClip) {
           trace("*********First my_mcl instance*********");
           trace("Movie clip = "+target_mc+" is now initialized");
           target_mc.play();
           fertig();
        onLoadError: function(target_mc:MovieClip, errorCode:String) {
           trace("ERROR CODE = "+errorCode);
           trace("Your load failed on movie clip = "+target_mc+"\n");
    my_mcl.addListener(myListener);
    function load_swf(url:String) {
        mc.removeMovieClip();
        mc = createEmptyMovieClip("mc", getNextHighestDepth());
        my_mcl.loadClip(url, mc);
    var testurl:String = "any_swf_in_as2.swf";
    load_swf(testurl);

  • Loading an AS2 swf into a AS3 project?

    I have an AS2 swf that is merely an image gallery made with a few components. I tried loading this swf into an AS3 project I am working on and it seems to load in and play properly in my AS3 file. I'm not looking to communicate with the AS2 swf with AS3 code, I just want to display it and be able to use the component buttons in the AS2 file that play or stop the images from being played.  I was wondering if using this will cause any potential issues in my AS3 project. It seems to render and work fine on my machine. Thanks

    as2 swfs will play without problem when loaded into an as3 swf.

  • AS3 issue embedding AS2 .swf files

    Hi there,
    I'm attempting to create a menu navigation system with Flash/AS3 that opens up a series of older AS2 activities.
    At the moment I'm testing it with two buttons/two activities.
    The problem I'm having is that when I'm testing the navigation, the first button clicked will open its respective activity correctly, which can then be shut down using the original activity's exit button, and return to the two buttons on my AS3 menu. However, if I then select the other activity from the same screen, it won't load. I'm able to click the original activity again, and have it open, but not the new one.
    If I test the main flash navigation file again and click the other button first (that wasn't working), the other activity opens fine, and can be closed down. However the first button now won't open the activity. So both the buttons work (if they're the first ones clicked), but from then on, only the first button clicked works.
    In the debug panel, it looks as if the AS2 .swf files that I'm attempting to embed are themselves embedding a wrapper.swf file (with navigation buttons) as well as another sub set of shared .swf files for their own operation. Might it possible that these sub swf files aren't being unloaded properly when I switch between the main AS2 movies from my menu system?
    Is there a way to clear/unload everything that's been loaded (even resources loaded by the external files themselves - like a hard reset) between button presses?
    I have no access to the original AS2 code as this was done by another team years back.
    I'd be really grateful for any help or advice that anyone might be able to give.
    Thanks

    Just looking at the debugging panel, this is what I see when I try and run the program:
    Attempting to launch and connect to Player using URL /*****/*****/****.swf
    [SWF] Volumes:Data:Documents:*****:****:****:*****.swf - 876582 bytes after decompression
    [SWF] Volumes:Data:Documents:*****:****:****:*****:F11_pr_qu_3:quiz.swf - 176016 bytes after decompression
    LocateFolders.enginesFolder(file:///*****/****/****/*****/F11_pr_qu_3/quiz.swf)
    [SWF] Volumes:Data:Documents:*****:****:****:*****:F11_pr_qu_3:wrapper.swf - 481279 bytes after decompression
    ### Latest wrapper ###
    etc etc...
    Then follows a whole set of loading instructions and trace instructions put in the as2 swf which show XML files being loaded and the program launching. These must have been put in place by the previous programmer.
    When I click the exit button on the 'embedded' swf, the debugging panel shows things shutting down:
    ActivityToolbar clickQuit()
    Wrapper quitActivity()
    EndGame clear(false)
    Now when I click the second button, I should see a similar set of launching greetings etc. instead it bottles out at the following:
    [SWF] Volumes:Data:Documents:*****:****:****:*****:F11_wb_fc_1:flashcards.swf - 94720 bytes after decompression
    LocateFolders.enginesFolder(file:///file:///*****/****/****/*****/F11_wb_fc_1/flashcards.s wf)
    And there it stops.
    If I restarted the program and pressed the second button first, it would show the flashcards.swf activity loading correctly, but would then refuse to load the first activity when I clicked on the button.

  • Cross domain scripting at run time using local connection flash AS2

    Hi
         I want to do live video streaming using FMS and FMLE in Flash As2. Suppose 100 users watching video online and I want to show message to  all 100 users using the Local connection.
    If I am sending message using different browser in same pc then I can get the message which was send from another swf file but I am checking from another pc then message not coming in receiver swf file.
    Please find the code below. 
    receievemovie.swf
    // Code in the receiving SWF file
    this.createTextField("result_txt", 1, 10, 10, 100, 22);
    System.security.allowDomain("*")
    System.security.allowInsecureDomain("*")
    var my_lc:LocalConnection = new LocalConnection();
    my_lc.allowDomain = function(sendingDomain:String) {
    domain_txt.text = sendingDomain;
    return true;
    my_lc.allowDomain = function(sendingDomain:String) {
    return (sendingDomain == "*");
    my_lc.allowInsecureDomain = function(sendingDomain:String) {
    return (sendingDomain == "*");
    my_lc.methodToExecute = function(param1:String) {
        result_txt.text = param1
    myResult.text=param1
    my_lc.connect("lc_name");
    sendmovie.swf
    System.security.allowDomain("*")
    System.security.allowInsecureDomain("*")
    var sending_lc:LocalConnection;
    var sending_lc:LocalConnection = new LocalConnection();
    sending_lc.allowDomain = function(sendingDomain:String) {
    return (sendingDomain == "*");
    sending_lc.allowInsecureDomain = function(sendingDomain:String) {
    return (sendingDomain == "*");
    myButton.onRelease = function(){
    sending_lc = new LocalConnection();
    sending_lc.send("lc_name", "methodToExecute", sendMsg.text);
    sendMsg.text="Message has been sent"
    If you have any other way to do it please suggest me to do that.
    Thanks & regards
    Sunil Kumar

    Hi, go to
    Flash Resources , you can
    find a java application that can serve policy files to resolve this
    problem.

  • Loading an AS2 Swf into an AS3 project

    I have a need to be able to load legacy AS2 SWF's into a new
    AS3 project. I know that this is not readily possible, because you
    can only communicate between the two via the LocalConnection class.
    So, what I have done is to create an AS2 proxy SWF. This SWF will
    handle the loading of all legacy SWF's and act as a middleman to
    pass the function calls between the pre-compiled SWF and the new
    SWF using the LocalConnection class. The new SWF also needs to be
    able to load AS3 SWF's, though.
    Because of this, I have the need to detect the AS version of
    the loaded SWF. If 1 or 2, then change the source to the
    AS2Proxy.swf, if 3 then simply load it.
    I have written the following code. My problem comes in when
    the init event fires. Regardless of the compiled version of the
    loaded SWF, it always traces 3 as the AS version.

    Alright, I solved this problem, only to come up with many
    more.
    To solve this problem, I needed to point to the loaderInfo
    object of the UILoader's content. So:
    simulation.content.loaderInfo.actionScriptVersion.
    Now the proxy loads correctly, but I start getting errors
    immediately. Let me paste some code to show the next steps:
    First off. I immediately receive a StatusEvent error, though
    the path gets sent into the proxy and loads correctly.
    Next, when the complete event fires in the AS2 SWF - it sends
    a completion back up to let the AS3 SWF know that it finished (and
    any handling that needs to happen at that point.) I receive the
    following error:
    Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095:
    flash.net.LocalConnection was unable to invoke callback loadSwf.
    error=ReferenceError: Error #1069: Property loadSwf not found on
    com.applied.flash.events.AS2Connect and there is no default
    value.

  • Tweens don't work in multiple external AS2 SWFs loaded by AS3 SWF

    When I try to load a single external AS2 SWF in an AS3 parent
    SWF, scripted tweens using the mx.tween class work fine. However,
    when I load two or more external AS2 SWFs, the first will work, but
    in subsequent SWFs the tweens do not animate. Does anyone have a
    solution?
    Related post:
    http://www.actionscript.org/forums/showthread.php3?t=147637

    SymTsb,
    So what is the code to do that? To delete the TWEEN variable?
    easeTime = .5;
    var day_handlerX:Tween = new
    mx.transitions.Tween(daynightlabel_mc, "_x",
    mx.transitions.easing.Regular.easeOut, daynightlabel_mc._x,
    (left_point+daynightlabel_mc_leftDifference), easeTime, true);
    day_handlerX.onMotionFinished = function() {
    trace("day_handlerX="+day_handlerX);
    trace("day_handlerX onMotionFinished triggered");
    delete day_handlerX;
    trace("deleted day_handlerX="+day_handlerX);
    does not work. the TWEEN object is still there.
    Can ADOBE say something??
    AS3 is ...

  • Communication between AS2 Template and AS3 Swf

    I created a template in AS2 which loads as2 swf's. i want to load as3 swf. then how can load as3 swf.within as2 template.
    please help me to find out this...

    hI,
    Look at package SDYNAMICDOCUMENTS, or look for DD_* ( This is Dynamic Documents  Tamplates ) in SE38.
    Regards,
    Marcelo Ramos.

Maybe you are looking for

  • Error  " NO Measures found"

    Hi Experts, while running the IM52 for Budget distribution i am getting the error  " NO Measures found" . please guide me any one to solve this problem.  Thanks, RVI

  • Distribution List from outlook won't synch to 3GS I phone

    I've created a distribution list in my Outlook contacts so I can email a group of people from my iphone but it won't synch over to the phone contacts. Any suggestions

  • Callin a report and scheduling it in the background ........  urgent

    Hi , i need to call a report2 from report1 .. i need to schedule the report2 in the background ...... such that the execution of report1 is never affected by the execution of report2 ....  jsut a call from report1 to report2 ..... also i need to pass

  • Strategic Sourcing with bid configuration?

    Hi Gurus, This might be a "big" question: what's the main configuration steps for the strategic sourcing with bid for SRM 7.0 (classic scenario)? Kindly please guide. Thanks and best regards Jack

  • After Effects 5.5環境設定が-

    1.25G Dual OS10.2.4での使用ですが.起動の度に 『After Effects エラー:環境設定ファイル「Adobe After Effects 5.5環境設定」が 無効です.このファイル名には「.old」が付けられ.新しい環境設定ファイルが作成されます.』 というエラー表示がでてきて.終了の際にも必ず『予期しない理由で終了』となってしまいます. OS9では何もなく起動.終了するのですが... 一度システムが不具合を起こし.OSXをインストールし直したのですが その時に何か余計な