Re #2.  Don't know for sure but I'd bet they didn't think about custom
styles and thought they could get everything they needed on the clipboard
in a more generic format so it would be more multipurpose and handle data
to from other applications and SWFs.

There is a way to serialize objects to text and back.  I think there may
be code in the RPC library for a stringified AMF, or you may be able to
write the objects to a bytearray, serialize that to string and then
reverse the process.


On 11/4/13 5:32 AM, "Cosma Colanicchia" <cosma...@gmail.com> wrote:

>Agree on 1, it should be more "pluggable" (unless it improved since the
>last time I checked).
>
>Regarding 2, clipboard class (see [1]) seems to support object references
>in clipboard. If the TextScrap is completely independent from its
>originating TextFlow, placing itself in the Clipboard (probably using a
>dedicated clipboard format, and in addition to the current serialized
>form)
>may have sense.
>
>
>[1]
>http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/d
>esktop/Clipboard.html
>
>
>
>
>2013/11/4 Harbs <harbs.li...@gmail.com>
>
>> I'm not sure. Is there any way to deserialize to resolve to a reference
>>to
>> a class instance?
>>
>> For the most part, I'm using custom styles to track character and
>> paragraph styles. setStyle() and getStyle() writes and reads references
>>to
>> common styles that can be applied to any number of TextLayoutElements.
>> (Yes. I can probably track them using strings rather than object
>>references
>> to solve my problem, but object references is much neater and I'd rather
>> solve the underlying issue if possible.)
>>
>> Is there a reason that the TextScrap is not written to and read from the
>> clipboard directly? Is it really necessary to serialize it?
>>
>> There's really two separate issues here:
>> 1) Serialization of TLF could probably be more robust.
>> 2) The question as to whether serialization is really necessary. Is that
>> to facilitate copying the data from one swf to another? What about
>>copying
>> BOTH serialized data as well as the original TextScrap? The TextScrap
>>could
>> be used for the same swf and the serialized data can be used for a
>> different one.
>>
>> Harbs
>>
>> On Nov 4, 2013, at 9:19 AM, Alex Harui wrote:
>>
>> > So is it as simple as serializing non-strings to text and
>>de-serializing
>> > on import?
>> >
>> >
>> > On 11/3/13 11:12 PM, "Harbs" <harbs.li...@gmail.com> wrote:
>> >
>> >> Here is a simple test case which illustrates the problem. I can
>>change
>> my
>> >> app for custom handling of copy/paste, but it seems to me that this
>>is a
>> >> general short-coming in the was copy paste is handled in TLF.
>> >>
>> >> Note: customStyle1 is preserved when the TextFlow is exported because
>> >> it's simple text, but customStyle2 is not preserved.
>> >>
>> >> The result of TextFlowExporter.export() is what's written to the
>> >> clipboard, so it's missing any complex custom styles.
>> >>
>> >> <?xml version="1.0" encoding="utf-8"?>
>> >> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009";
>> >>                         xmlns:s="library://ns.adobe.com/flex/spark"
>> >>                         xmlns:mx="library://ns.adobe.com/flex/mx"
>> minWidth="955"
>> >> minHeight="600" creationComplete="onComplete()">
>> >>      <fx:Script>
>> >>              <![CDATA[
>> >>                      import
>>flashx.textLayout.conversion.ITextExporter;
>> >>                      import
>>flashx.textLayout.conversion.TextConverter;
>> >>                      import flashx.textLayout.edit.EditManager;
>> >>                      import
>>flashx.textLayout.elements.ParagraphElement;
>> >>                      import flashx.textLayout.elements.SpanElement;
>> >>                      import flashx.textLayout.elements.TextFlow;
>> >>                      import flashx.undo.UndoManager;
>> >>                      [Bindable]private var textFlow:TextFlow;
>> >>
>> >>                      private function onComplete():void{
>> >>                              var para:ParagraphElement;
>> >>                              var span:SpanElement;
>> >>                              var i:int;
>> >>                              textFlow =  new TextFlow();
>> >>                              textFlow.interactionManager = new
>> EditManager(new UndoManager());
>> >>                              textFlow.tabStops = "s12 s72";
>> >>                              textFlow.paragraphSpaceAfter = 16;
>> >>                              para = new ParagraphElement();
>> >>                              span = new SpanElement();
>> >>                              span.fontSize = 16;
>> >>                              span.fontWeight = "bold";
>> >>                              span.text = "Here's some text.";
>> >>                              span.setStyle("customStyle1","hello");
>> >>
>>  span.setStyle("customStyle2",{id:1,content:"this is some custom
>> >> content"});
>> >>                              para.addChild(span);
>> >>                              textFlow.addChild(para);
>> >>
>> >>                              var exporter:ITextExporter =
>> >> TextConverter.getExporter("textLayoutFormat");
>> >>                              var res:Object =
>> exporter.export(textFlow,"stringType");
>> >>                              trace(res);
>> >>                      }
>> >>              ]]>
>> >>      </fx:Script>
>> >>      <s:RichEditableText verticalCenter="0" width="400"
>> >> textFlow="{textFlow}"/>
>> >>
>> >> </s:Application>
>> >>
>> >> Harbs
>> >>
>> >> On Nov 4, 2013, at 7:21 AM, Alex Harui wrote:
>> >>
>> >>> I'm not sure what user styles are and why the aren't in the markup.
>>  Can
>> >>> you provide more details?
>> >>>
>> >>> Consider whether this is a general TLF issue or just something you
>> >>> should
>> >>> do in your app to add functionality.  A general TLF issue probably
>> can't
>> >>> bypass the Clipboard because you should be able to copy/paste from
>>one
>> >>> SWF
>> >>> to another SWF.
>> >>>
>> >>> -Alex
>> >>>
>> >>> On 11/3/13 1:01 PM, "Gavriel Harbater" <gavha...@gmail.com> wrote:
>> >>>
>> >>>> Okay. After researching this, it looks like the problem is as
>>follows:
>> >>>>
>> >>>> The TextFlow is saved to the clipboard as a string which is the
>>markup
>> >>>> representation of the TextFlow. The markup is produced using
>> >>>> BaseTextLayoutExporter.export(). The markup produced from that is
>> >>>> missing
>> >>>> custom user styles. My custom user styles are actually quite
>>complex
>> >>>> classes.
>> >>>>
>> >>>> I'm looking for suggestions on the best way to handle this
>>problem. I
>> >>>> can
>> >>>> think of three possible angles:
>> >>>> 1) Somehow write user styles into the TextFlow markup. I'm not
>>sure if
>> >>>> there's a way to markup custom styles and complex ones are
>>definitely
>> >>>> an
>> >>>> issue.
>> >>>> 2) Write complex objects to the clipboard. Is this possible? If
>>yes,
>> >>>> why
>> >>>> are strings currently used?
>> >>>> 3) Skip the clipboard altogether and create some static function to
>> >>>> call
>> >>>> when the clipboard content is pasted to apply custom styles.
>> >>>>
>> >>>> Thoughts?
>> >>>>
>> >>>> On Nov 3, 2013, at 10:13 AM, Harbs wrote:
>> >>>>
>> >>>>> Looking into an issue I had, I noticed that user styles in TLF are
>> not
>> >>>>> preserved on copy/paste. (Actually, it would probably be more
>>correct
>> >>>>> to
>> >>>>> say that they're not preserved on copy.)
>> >>>>>
>> >>>>> I'm looking into TextScrap/TextClipboard now, but if anyone has
>> >>>>> experience here as to why the styles are being dropped, I'd love
>>to
>> >>>>> knowŠ
>> >>>>>
>> >>>>> Harbs
>> >>>>
>> >>>
>> >>
>> >
>>
>>

Reply via email to