---
title: "flex4 倾斜字体"
author: "demojava"
date: "2011-10-13T21:30:29Z"
tags: []
categories: ["Web前端"]
slug: "flex4"
draft: false
lastmod: "2011-12-13T21:31:47Z"
id: 1195364
url: "https://demojava.iteye.com/blog/1195364"
---

倾斜字体要在flex3中做的话用
选择特效：
mx.effects.Rotate来处理
<mx:Script>
        <!
            public var angle:int=0;
      ]]>
</mx:Script>
    <mx:Rotate id="rotate" angleFrom="{angle-45}" angleTo="{angle}" target="{myVB}"/>
<mx:Label showEffect="{rotate}" />
而在flex4中对label做了扩展,先上图：
![](http://dl.iteye.com/upload/attachment/569829/1bf9504b-d2f6-3d86-bd12-58ddf0389a9b.png)

```as

<?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">
	<s:layout>
		<s:VerticalLayout horizontalAlign="center" paddingTop="20" gap="20"/>
	</s:layout>
	<fx:Script>
		<![cdata[
		]]>
	</fx:Script>
	<s:HSlider id="mySlider"
			   width="150"
			   minimum="-180" maximum="180" value="0"
			   liveDragging="true"/>
	<s:Label 
			 text="Rotated Text" fontSize="24"
			 rotation="{mySlider.value}"/>
	
</s:Application>

```


--TextFlow反转字体（0-360反转）

```xml

	<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
			 xmlns:s="library://ns.adobe.com/flex/spark"
			 xmlns:mx="library://ns.adobe.com/flex/halo"
			 width="500" height="300">
		<fx:Script>
			<![cdata[
				import flash.text.engine.textrotation;
				import flashx.textlayout.formats.blockprogression;
				import flashx.textlayout.formats.verticalalign;
				import mx.collections.arraylist;
				import spark.events.indexchangeevent;
				protected function rotatetext(event:indexchangeevent):void {
					var target:string = event.target.selectedItem;
					switch(target) {
						case "0":
					//	Here, the textRotation for each character in the TextFlow is changed:
							tArea.textFlow.textRotation = TextRotation.ROTATE_0;
							break;
						case "90":
						tArea.textFlow.textRotation = TextRotation.ROTATE_90;
						break;
						case "180":
						tArea.textFlow.textRotation = TextRotation.ROTATE_180;
						break;
						case "270":
						tArea.textFlow.textRotation = TextRotation.ROTATE_270;
						break;
					}
					tArea.textFlow.invalidateAllFormats();
					tArea.textFlow.flowComposer.updateAllControllers();
				}
			]]>
		</fx:Script>
		<s:ComboBox change="rotateText(event)" x="400"
					dataProvider="{new ArrayList(['0', '90', '180', '270'])}"/>
		<s:RichText id="tArea" width="300" fontSize="20" paddingTop="10">
			<s:textFlow>
				<s:TextFlow>
					<s:p>
					中国四川省广安县协兴乡牌坊村的一个客家家庭
					</s:p>
					<s:p>
						Vertical alignment or justification (adopts default value if
						undefined during cascade). Determines how TextFlow elements
						align within the container.
					</s:p>
				</s:TextFlow>
			</s:textFlow>
		</s:RichText>
	</s:Group>

```