• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Getting a reference to a placed object

Advisor ,
Oct 16, 2012 Oct 16, 2012

Copy link to clipboard

Copied

my code:

var myApplicationEventListener = app.eventListeners.add("afterImport", myEventInfo);

function myEventInfo(myEvent){

var myImportedObj=????????? ///HELP!!!

if (myImportedObj.constructor.name=="Story")

{processStory(myImportedObj)}

}

function processStory(myStory){

//blah blah blah blah

//blah blah blah blah

}

how cand i get that myImportedObj?? the parent and the target of the event is "Document".

TOPICS
Scripting

Views

736

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Oct 16, 2012 Oct 16, 2012

Hi Vamitul,

Your handler just listens to an ImportExportEvent (myEvent), which does not tell you what the imported file is placed as. (At this stage, in fact, the object is not placed yet.) That kind of event can only address the underlying file—through myEvent.fullName—but this is not the thing you are looking after…

Instead, you should use: app.eventListeners.add("afterPlace", myEventInfo)

This way myEvent.target will address the actual DOM object which results from any placing operation.


@+

Marc

Votes

Translate

Translate
Guide ,
Oct 16, 2012 Oct 16, 2012

Copy link to clipboard

Copied

Hi Vamitul,

Your handler just listens to an ImportExportEvent (myEvent), which does not tell you what the imported file is placed as. (At this stage, in fact, the object is not placed yet.) That kind of event can only address the underlying file—through myEvent.fullName—but this is not the thing you are looking after…

Instead, you should use: app.eventListeners.add("afterPlace", myEventInfo)

This way myEvent.target will address the actual DOM object which results from any placing operation.


@+

Marc

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Oct 16, 2012 Oct 16, 2012

Copy link to clipboard

Copied

LATEST

Thank you!

a wird thing happens with "afterPlace": sometimes the taget is a story, sometimes is a textframe..

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines