A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Flash & JavaScript

  1. #1
    Member
    Join Date
    May 2005
    Location
    San Francisco
    Posts
    55

    Flash & JavaScript

    I'm trying to get flash to toggle a div layers display status.

    I have an html version working, but i can't seem to code it properly in AS3

    I need to figure out how to issue something like:

    <a href="javascript:toggleLayer('componentLevel2');" title="toggle">
    toggle
    </a>

    within this function

    function loadBuildingBenefits(event:MouseEvent):void {
    // send the methodToExecute method in another movie's
    // LocalConnection listening to "lc_example"
    outgoing_lc.send("lc_component1", "playBenefitsText");
    outgoing_lc.send("lc_example", "playBuildingBenefits");
    }

  2. #2
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


  3. #3
    Member
    Join Date
    May 2005
    Location
    San Francisco
    Posts
    55
    Thank you.

    I thought i had it, but this doesn't seem to do anything, but compiles w/o errors.

    import flash.net.LocalConnection;
    import flash.external.ExternalInterface;


    // create a new LocalConnection instance used to listen
    // for calls from a LocalConnection instance from another movie
    var incoming_lc:LocalConnection = new LocalConnection();
    var componentLevel2 = "componentLevel2";


    // create a local connection listening to a connection
    // with the name "lc_example"
    incoming_lc.connect("lc_component1");

    // define an method which will be called when a message
    // is sent from a LocalConnection instance from another movie
    function playBenefitsText():void {
    trace("Component 1 should received GREEN BENEFITS data");
    gotoAndStop(11);
    ExternalInterface.call("toggleLayer", componentLevel2);
    }

    function playLEEDText():void {
    trace("Component 1 should received LEED data");
    gotoAndStop(21);
    }

    function playStrategiesText():void {
    trace("Component 1 should received LEED data");
    gotoAndStop(35);
    }

    // set the client reference of the LocalConnection instance
    // to the object containing the method needing to be called
    incoming_lc.client = this;

  4. #4
    Member
    Join Date
    May 2005
    Location
    San Francisco
    Posts
    55
    actually thats causing the flash application to lock up on my macbook pro....

  5. #5
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    moved to the AS 3.0 forum.

    gparis

  6. #6
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    I'm not particularly familiar with LocalConnection, so I don't know if that's where your problem lies. But on the ExternalInterface side of things, you may want to move the call to toggleLayer up to before the gotoAndStop(11).
    That's a shot in the dark, honestly. What sort of trace output are you getting?

  7. #7
    Bearded (M|G)od MyFriendIsATaco's Avatar
    Join Date
    Dec 2002
    Location
    Awesomeville.
    Posts
    3,045
    [edit]Oops, I should have read the post more thoroughly! Sorry![/edit]
    Last edited by MyFriendIsATaco; 03-03-2008 at 01:43 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center