Skip navigation
Currently Being Moderated

add the event listener to link

Jun 26, 2012 3:22 AM

I am trying to trigger an event as image link is modified in InDesign file, using action script API in csaw lib. But it's thowing the error:

 

invalid value for parameter 'handler' of method 'addEventListener'. Expected File or JavaScript Function, but received nothing.

 

here is my code to add and handle the event:

 

 

tempLink.addEventListenerLink("afterAttributeChanged", handleLinkModified);
 
 
 
private function handleLinkModified(event:com.adobe.indesign.Event):void
  {
  trace("From link handler: LINK modified");
  }
 

 

I got this idea from one of John Hawkinson Thread: http://forums.adobe.com/message/4049418

Can someone let me know what''s going wrong with my logic?

 

Thanks

Mac

 
Replies
  • Currently Being Moderated
    Jun 26, 2012 3:38 AM   in reply to Mac_06

    You cannot use Actionscript functions as event handlers directly.

     

    You'll need to use the IDScriptingEventAdapter.

     

    Harbs

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 26, 2012 3:50 AM   in reply to Mac_06

    If you are using Extension Manager, right click on the project and select Properties. Select "CS Extension Builder Libraries" on the left side. Select the Host Adapters tab and check Adobe CSHA InDesign.

     

    You should then be able to import IDScriptingEventAdapter and then you do something like this:

     

    IDScriptingEventAdapter.getInstance().addEventListener(eventName,handl erFunction);

     

    Harbs

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 26, 2012 9:03 AM   in reply to Mac_06

    You cannot attach events to specific objects. Not in JS and not is AS.

     

    Harbs

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 27, 2012 4:46 AM   in reply to Mac_06

    Attach the event listener to the document or application and check the links when it fires...

     

    Harbs

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points