简单的flex文本编辑器

editor.mxml

<?xml version="1.0"?>
<!-- Simple example to demonstrate the ColorPicker control. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" fontSize="12" viewSourceURL="#">
<mx:Script>
 <![CDATA[
  private function adddata():void{
   request.send();
  }
  private function setSize():void{
    fontsize.text=String(myComboBox.value);
  }
 
  private function setFamily():void{
    fontfamily.text=String(myComboBox2.value);
  }
 ]]>
</mx:Script>
 
<mx:HTTPService id="request" method="POST" url="write.php" useProxy="false">
 <mx:request xmlns="">
  <textarea>{textarea.text}</textarea>
  <bgcolor>{bgcolor.text}</bgcolor>
  <fontcolor>{fontcolor.text}</fontcolor>
  <fontsize>{fontsize.text}</fontsize>
  <fontfamily>{fontfamily.text}</fontfamily>
 </mx:request>
</mx:HTTPService> 
 
    <mx:Panel verticalCenter="0" horizontalCenter="0" layout="absolute" title="ColorPicker Control Example" height="394" width="513"
        paddingTop="10" paddingBottom="10" paddingLeft="10" paddingRight="10"
        color="0xffffff" borderAlpha="0.15" >
        <mx:Label width="100%" color="0x000000"
           text="Select the background color of the VBox container."/>
        <mx:ComboBox id="myComboBox" change="setSize()" width="121" x="10" y="40" color="#000000" fontSize="14">
            <mx:dataProvider>
                <mx:Array>
                 <mx:Object label="请选择字号" data="12" />
                    <mx:Object label="14" data="14" />
                    <mx:Object label="16" data="16" />
                    <mx:Object label="18" data="18" />
                </mx:Array>
            </mx:dataProvider>
        </mx:ComboBox>
       
       <mx:ComboBox id="myComboBox2" change="setFamily()" width="135" x="129" y="40" color="#000000" fontSize="14">
            <mx:dataProvider>
                <mx:Array>
                 <mx:Object label="请选择字体" data="Arial" />
                 <mx:Object label="Arial" data="Arial" />
                    <mx:Object label="宋体" data="宋体" />
                    <mx:Object label="幼园" data="幼园" />
                    <mx:Object label="隶书" data="隶书" />
                </mx:Array>
            </mx:dataProvider>
        </mx:ComboBox>
       
        <mx:ColorPicker id="cp" showTextField="true" selectedColor="0xFFFFFF" x="272" y="36" width="33" height="31"/>
        <mx:ColorPicker id="cp2" showTextField="true" selectedColor="0x000000" x="313" y="36" width="33" height="31"/>
       <mx:Label id="fontsize" text="" color="#000000" x="354" y="45" visible="false" width="38"/>
        <mx:Label id="bgcolor" text="{cp.selectedColor.toString(16)}" visible="false" color="#000000" x="272" y="314" width="214"/>            
       <mx:TextArea id="textarea" width="396" fontFamily="{String(myComboBox2.value)}" height="207" color="{cp2.selectedColor}" fontSize="{Number(myComboBox.value)}" backgroundColor="{cp.selectedColor}" x="10" y="75">
        </mx:TextArea>
         <mx:Button x="10" y="312" label="提交" color="#000000" click="adddata()" />
         <mx:Button x="102" y="312" label="重填" color="#000000" />
         <mx:Label id="fontcolor" text="{cp2.selectedColor.toString(16)}" visible="false" y="62" x="372" width="110"/>
         <mx:Label id="fontfamily" color="#000000" text="" visible="false" y="306" x="207" width="110" height="30"/>
    </mx:Panel>
</mx:Application>

write.php

<?php
$fso=fopen("data.html","w");
$textarea=$_POST["textarea"];
$textarea=str_replace(" ","<br/>",$textarea);
fwrite($fso,"<font style='font-family:".$_POST["fontfamily"].";background-color:#".$_POST["bgcolor"].";color:#".$_POST["fontcolor"].";font-size:".$_POST["fontsize"]."px;'>".$textarea."</font>");
?>

    A+
发布日期:2009年05月15日  所属分类:未分类

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: