Skip to main content
Participant
January 5, 2011
Question

TFL getEventMirror

  • January 5, 2011
  • 1 reply
  • 590 views

In the Name of God

Hi everyone,

I have been trying to get getEventMirror from tfl_internal working in my project and so far, no luck...

No even is dispatched at all, not FlowEvent, nor MouseEvents... It is so frustrating...

Even the copy paste of the TFL group's exmaple project does not work.

I am on FB 4 and Flex SDK 4.x (not hero)... actually I'm working on the BB Playbook sdk.

Am I missing something?

This topic has been closed for replies.

1 reply

Adobe Employee
January 5, 2011

Rich posted an example a little while ago on our blog of how to use the event mirrors in TLF 2.0, which is part of the Flex Hero release. It is here:

http://blogs.adobe.com/tlf/2010/12/tlf-flowelement-linkelement-events-and-eventmirrors.html

There have been changes to event mirrors since TLF 1.1, so its possible this won't work with 1.1, but it seems like a good place for you to start. If you can upgrade to Hero, that will be easiest. Alternatively, if you can send me a code snippet that illustrates the problem in 1.1, I can look into it.

Thanks,

- robin

KefayatiAuthor
Participant
January 6, 2011

OK, so I changed my SDK to Hero and also realized that EventMirrors do not work when textFlow is binded (I used to had a actual flow that I was manipulating and had it binded to the textFlow property of a RichEditable Text. Nw after I changed the code to take care of these issues, I have the even fire, but not always!

This is wiered! Also, more wierd is that the event which is a FlowMouseEvent does not consistently contain the stuff it should have (like the flowElement or the originalMouseEvent... sigh...

My code is rather big, but the part that matters is as follows:

                    var ayaSpan:SpanElement = new SpanElement();
                    ayaSpan.text = aya.@text;
                    var mirror1:IEventDispatcher = ayaSpan.getEventMirror();
                    mirror1.addEventListener(FlowElementMouseEvent.CLICK, toggleTextBG);
                   
                    var ayaNumSpan:SpanElement = new SpanElement();
                    ayaNumSpan.text = '   ﴿'+arbicNums(aya.@index)+'﴾';
                    ayaNumSpan.breakOpportunity=BreakOpportunity.NONE;
                    var mirror2:IEventDispatcher = ayaNumSpan.getEventMirror();
                    mirror2.addEventListener(FlowElementMouseEvent.CLICK, toggleTextBG);
                   
                    //var ayaSP:SubParagraphGroupElement=new SubParagraphGroupElement();
                    //ayaSP.replaceChildren(0,0,ayaSpan,ayaNumSpan);
                    //ayaSP.addChild(ayaSpan);
                    //ayaSP.addChild(ayaNumSpan);
                   
                    var ayaPara:ParagraphElement = new ParagraphElement();
                    ayaPara.addChild(ayaSpan);
                    ayaPara.addChild(ayaNumSpan);
                    //ayaPara.addChild(ayaSP);
                    mainText.textFlow.addChild(ayaPara);

            public function toggleTextBG(e:FlowElementMouseEvent):void{
                trace("Flow even fired-- ");
                if(e.flowElement==null)trace("Null flow element!");
                else {
                    trace(e.flowElement.getParagraph().getText(0));
                    //e.flowElement.getParagraph().fontWeight="bold"; even this simple thing sometimes throws an exception!
                }

One side thing, as I saw it is encouraged by TFL group, as you see, I have tried SubParagraphGroupElement too with no luck. In fact it always fires an exception when I use it. BTW, I used replaceChildren as in the exmaples with the smae results...