Skip to main content
Participating Frequently
May 23, 2011
Answered

Text editor and setTextFormat (need help)

  • May 23, 2011
  • 1 reply
  • 702 views

Hello,

I created a text editor in AS3 to administer a site online, but i have a problem when i select a word, put it in bold, save the text and load it, all the text after this word becomes bold too. (to put a word in bold i select that world and use a button that turn this word in bold)
(I'm sorry if my english is not very good i'm french)

Here is my code

var formatGlobal12:TextFormat = new TextFormat ("_serif", 12);
txt_references_springbok_fr.setTextFormat (formatGlobal12);

var formatSelection12:TextFormat = new TextFormat ("_serif", 12);
formatSelection12.bold=true
formatSelection12.leading=0
function appliquerFormatSurSelection12 (e:MouseEvent):void
{
        txt_references_springbok_fr.setTextFormat (formatSelection12, txt_references_springbok_fr.selectionBeginIndex, txt_references_springbok_fr.selectionEndIndex);
}

boutonAppliquer.addEventListener (MouseEvent.CLICK, appliquerFormatSurSelection12);

This topic has been closed for replies.
Correct answer Kenneth Kawamoto

Like that ?

fwrite($fp, (stripslashes($template_debut . ($_POST<![CDATA['value']]>) . $template_fin)));


$template_debut = "<?xml version=\"1.0\" encoding=\"utf-8\"?><data><zonetexte><![CDATA[";

..and add the closing CDATA to fin

1 reply

Kenneth Kawamoto
Community Expert
Community Expert
May 23, 2011

The code is OK and it should work - may be there's something you're not showing here?

ApihyAuthor
Participating Frequently
May 23, 2011

I don't know, maybe the problem is the code that saves the text. I really don't understand why he don't work.

This is the code :

miseajour_btn10.addEventListener(MouseEvent.MOUSE_DOWN, bout_sauver_MouseDown10);

var sauverxml10:Array = new Array();

function bout_sauver_MouseDown10(event:MouseEvent):void

{

var vr:URLVariables = new URLVariables();

vr.action = 'save';

vr.value = txt_references_oryx_fr.htmlText;

var rq:URLRequest = new URLRequest("site_swf_EN/en/references_oryx.php");

rq.method = URLRequestMethod.POST;

rq.data = vr;

sauverxml10.push(new URLLoader());

sauverxml10[sauverxml10.length-1].dataFormat = URLLoaderDataFormat.TEXT;

sauverxml10[sauverxml10.length-1].addEventListener(Event.COMPLETE, bout_sauver_Load_OK);

sauverxml10[sauverxml10.length-1].addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);

sauverxml10[sauverxml10.length-1].addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);

sauverxml10[sauverxml10.length-1].addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);

try

{

sauverxml10[sauverxml10.length-1].load(rq);

texte_statut.text = "sauvegarde en cours";

}

catch (error:Error)

{

texte_statut.text = "sauvegarde impossible";

}

}

function bout_sauver_Load_OK10(event:Event):void

{

var ld:URLLoader = event.currentTarget as URLLoader;

ld.removeEventListener(Event.COMPLETE, bout_sauver_Load_OK10);

ld.close();

texte_statut.text = "Réponse Php: " + event.target.data;

}

Kenneth Kawamoto
Community Expert
Community Expert
May 24, 2011

Can you verify what HTML string you are posting to, and what is returned, so that you know if Flash side or your PHP side is responsible.