A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Dispatching Event from embeded swf

  1. #1
    Senior Member next2heaven's Avatar
    Join Date
    Nov 2000
    Posts
    275

    Question Dispatching Event from embeded swf

    How do I send an even from an embeded swf and receive it from the class that called it?

    Code the dispatches from account_settings.swf file.
    Code:
    dispatchEvent(new CustomEvent(CustomEvent.ACCOUNT_INFO, {theData:pipeSize.selectedItem.data}));


    Code that embeds the item and listens for event
    Code:
    [Embed(source="/assets/account_settings.swf")]
    private var _accountSettingsClass:Class;
    var _accountSettings:MovieClip = new _accountSettingsClass as MovieClip;
    _window.addChild(_accountSettings);
    _accountSettings.addEventListener(CustomEvent.ACCOUNT_INFO, getInfo);

    (the CustomEvent is just a class that extends the Event and allows me to pass information back and forth with the event)
    Play Intimate Tonight!
    Check it out here

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    I don't see why that wouldn't work. Have you tried it? Are you sure the event is being dispatched?

  3. #3
    Senior Member next2heaven's Avatar
    Join Date
    Nov 2000
    Posts
    275
    The dispatch is being called for sure. I can't figure out why it's not 'hearing' it (so to speak).
    Play Intimate Tonight!
    Check it out here

  4. #4
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Is the event being dispatched before the listener is added? For example, if it is dispatched in the constructor, then there's no chance that the listener has been added yet.

  5. #5
    Senior Member next2heaven's Avatar
    Join Date
    Nov 2000
    Posts
    275
    No...I've got it attached to a button. So whenever you click the button it dispatches the CLICK event and in that function it does the dispatching using the customEvent.
    Play Intimate Tonight!
    Check it out here

  6. #6
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Is your event dispatched directly from the accountSettings document class, or an object within that? You might try setting bubbles=true on the event in the latter case.

    Also try catching it within the accountSettings class itself just as a debug, to see if it gets that far.

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