Skip to main content
Inspiring
September 10, 2009
Answered

SelectionEvent Problem

  • September 10, 2009
  • 1 reply
  • 1240 views

Hi i have added following to get selection

textFlow.addEventListener(SelectionEvent.SELECTION_CHANGE, selectionHandler);

function selectionHandler(ev:SelectionEvent):void {

trace(ev.type);

/*var range:ElementRange = ev.selectionState ?

                ElementRange.createElementRange(ev.selectionState.textFlow,

                ev.selectionState.absoluteStart, ev.selectionState.absoluteEnd) : null;

               trace("Starting index of selection range: " + range.absoluteStart);

               trace("Ending index of selection range: " + range.absoluteEnd);*/

}

when i uncomment from above code it gives this error
1119: Access of possibly undefined property selectionState through a reference with static type flashx.textLayout.events:SelectionEvent.
can you please tell my what i need to fix
Thanks
This topic has been closed for replies.
Correct answer robin_briggs

First, I would suggest you try upgrading to a newer version of TLF, if you are using the one we posted to the Labs site last November that works with the Flash CS4 Component.

If you change this line:

    EditManager(textFlow.interactionManager).modifyInlineGraphic(null,e.target.value,e.target.value);

and add an additional argument that specifies the location of the inline graphic you want to change as a SelectionState, it should work:

     EditManager(textFlow.interactionManager).modifyInlineGraphic(null,e.target.value,e.target.value, new SelectionState(textFlow, 15, 15));

for example if your inline graphic is at absolute position 15 in the text flow.

- robin

1 reply

Adobe Employee
September 10, 2009

This code compiles and runs OK for me. I retyped it, so perhaps I corrected a typo I don't see here. Do you have all the imports you need declared?

chicflashAuthor
Inspiring
September 13, 2009

Hi

Please check this attached file i want to select my inlinegraphic just on click over it and apply modifyinlinegraphic command. but image is only selected if click in this way that cursor move to at image index. (movieclip click event is called)