1 Reply Latest reply on Jan 30, 2010 1:03 PM by el_kolo

    Flex and javascript

    el_kolo Level 1

      Hi,

       

      I have a flex RichTextEditor and flex button. I want to copy to clipboard text from rich TextEditor to clipboard with rollOver the button. It is not possible to do this only with Action Script. Can I implement javascript "copy to clipboard function" which will copy this text after rollOver? Can do It with flex button or I have to create javascript button? Any tip will be helpful.

        • 1. Re: Flex and javascript
          el_kolo Level 1

          Ok i Have it. It works in IE but it is bettern then nothing:)

           

          Flex:

          private function jsSend():void{
              if (ExternalInterface.available){
                  s=richTextEditor.text;
                  ExternalInterface.call("copyT",s);
              }
              }

          <mx:Button rollOver="jsSend()"/>

          JavaScript:

          function copyT(s) 

              if(window.clipboardData) 
              { 
              window.clipboardData.setData('text',s); 
              } 
              else 
              { 
                  var clipboarddiv=document.getElementById('divclipboardswf'); 
              if(clipboarddiv==null) 
              { 
                 clipboarddiv=document.createElement('div'); 
                     clipboarddiv.setAttribute("name", "divclipboardswf"); 
                 clipboarddiv.setAttribute("id", "divclipboardswf"); 
                 document.body.appendChild(clipboarddiv); 
              } 
                  clipboarddiv.innerHTML='<embed src="clipboard.swf" FlashVars="clipboard='+ 
          encodeURIComponent(s)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>'; 
              } 
              alert('The text is copied to your clipboard...'); 
              return false; 
          }