Précédent   Forum des professionnels en informatique > Webmasters - Développement Web > Flash/Flex > Flex > MXML
MXML Questions relatives au format MXML
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 09/06/2008, 17h35   #1
Nouveau Membre du Club
 
Inscription : février 2006
Messages : 145
Détails du profil
Informations forums :
Inscription : février 2006
Messages : 145
Points : 27
Points : 27
Par défaut TextArea de resize pas selon le text

J'ai un probleme..

Je veux absolument utiliser un textarea mais celui ci ne se resize pas sur le text, malgre tout mes effort !!

Code :
<mx:TextArea borderStyle="none" editable="false" wordWrap="true" id="message" text="{Message(data).message}" width="100%"/>
Il me met des scroll bar quand le text fait plus de 44 pixel (taille pdf d un textarea)

Alors j ai essaye en utilisant un text control mais le hic c'est qu'il faut que je donne une width en pixel alors que moi je la donne en pourcentage...

Le label ya pas de background color..

Une astuce qq un ???? Merci...
Gaaaga est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/06/2008, 17h43   #2
Nouveau Membre du Club
 
Inscription : février 2006
Messages : 145
Détails du profil
Informations forums :
Inscription : février 2006
Messages : 145
Points : 27
Points : 27
Alors, voila, avec un peu de recherche, j'ai plus ou moins reussi a avoir ce que je voulais, mais y a tjs un pb.... Et je n'arrive pas a savoir lequel.. mais ma TextArea n'affiche que 300 caracteres au lieu de 800 par exemple.. help ?


Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%"
	verticalScrollPolicy="off" horizontalScrollPolicy="off">
	<mx:Script>
		<![CDATA[
			import mx.events.FlexEvent;
			import com.model.messages.Message;
 
			/**
			 * get the label shown on the top left of the note
			 * it represents the information of the note (user)
			 * 
			 * @param message : the note of a message 
			 * 
			 * @return the label to show
			 * 
			 */				
			[Bindable]
			function getLabelName(message:Message): String
			{
				var label:String = message.fromUser.toString() + " wrote: ";
				return label;
			}		
 
 
			/**
			 * get the label shown on the top right of the note
			 * it represents the information of the note (user, date, time)
			 * 
			 * @param message : the note of a message 
			 * 
			 * @return the label to show
			 * 
			 */				
			[Bindable]
			function getLabelDate(message:Message): String
			{
				var label:String = "at " + message.timeStamp.hours.toString() + "." + message.timeStamp.minutes.toString() + " on " + message.timeStamp.month.toString() + "/" + message.timeStamp.date.toString() + "/" + message.timeStamp.fullYear.toString();  
				return label;
			}		
 
 
			private function onLoad():void
           {
               this.addEventListener(FlexEvent.UPDATE_COMPLETE, resizeme);
           }
 
 
           private function resizeme(event:Event):void
           {
               var ta:TextArea = event.target.message as TextArea;
               ta.explicitHeight = ta.textHeight + 10;
           }      
 
 
		]]>
	</mx:Script>
	<mx:HBox id="hBoxLabels" width="100%">
		<mx:Label text="{getLabelName(Message(data))}" width="50%" textAlign="left" color="#5c5c5c"/>
		<mx:Label text="{getLabelDate(Message(data))}" width="50%" textAlign="right" color="#8b8b8b"/>	
	</mx:HBox>
 
 
		<mx:TextArea borderStyle="none" textAlign="left" editable="false" id="message" text="{Message(data).message}" width="100%" maxChars="64000" maxHeight="1000000" creationComplete="onLoad()">
 
		</mx:TextArea>	
 
</mx:VBox>
Gaaaga est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 11/06/2008, 13h48   #3
Nouveau Membre du Club
 
Inscription : février 2006
Messages : 145
Détails du profil
Informations forums :
Inscription : février 2006
Messages : 145
Points : 27
Points : 27
Okay c bon, c resolu, le probleme venait de la VBox principal contenant le textArea, avec une ptite ligne en plus, ca marche !

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%"
	verticalScrollPolicy="off" horizontalScrollPolicy="off">
	<mx:Script>
		<![CDATA[
			import mx.controls.Text;
			import mx.events.FlexEvent;
			import com.woodwing.lucina.model.messages.Message;
 
			/**
			 * get the label shown on the top left of the note
			 * it represents the information of the note (user)
			 * 
			 * @param message : the note of a message 
			 * 
			 * @return the label to show
			 * 
			 */				
			[Bindable]
			function getLabelName(message:Message): String
			{
				var label:String = message.fromUser.toString() + " wrote: ";
				return label;
			}		
 
 
			/**
			 * get the label shown on the top right of the note
			 * it represents the information of the note (user, date, time)
			 * 
			 * @param message : the note of a message 
			 * 
			 * @return the label to show
			 * 
			 */				
			[Bindable]
			function getLabelDate(message:Message): String
			{
				var label:String = "at " + message.timeStamp.hours.toString() + "." + message.timeStamp.minutes.toString() + " on " + message.timeStamp.month.toString() + "/" + message.timeStamp.date.toString() + "/" + message.timeStamp.fullYear.toString();  
				return label;
			}		
 
 
			private function onLoad():void
           {
 
               this.message.addEventListener(FlexEvent.UPDATE_COMPLETE, resizeme);
           }
 
 
          private function resizeme(event:Event):void
           {
             var ta:TextArea = event.target as TextArea;
             ta.explicitHeight = ta.textHeight + 10;
             this.height = this.height +  ta.explicitHeight;
           }      
 
 
		]]>
	</mx:Script>
	<mx:HBox id="hBoxLabels" width="100%">
		<mx:Label text="{getLabelName(Message(data))}" width="50%" textAlign="left" color="#5c5c5c"/>
		<mx:Label text="{getLabelDate(Message(data))}" width="50%" textAlign="right" color="#8b8b8b"/>	
	</mx:HBox>
 
	<mx:TextArea id="message" borderStyle="none" textAlign="left" editable="false" text="{Message(data).message}" width="100%" maxChars="64000" maxHeight="10000" creationComplete="onLoad()">
	</mx:TextArea>	
 
 
</mx:VBox>
Gaaaga est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 11/06/2008, 14h50   #4
Nouveau Membre du Club
 
Inscription : février 2006
Messages : 145
Détails du profil
Informations forums :
Inscription : février 2006
Messages : 145
Points : 27
Points : 27
Raaaaah re-probleme...

En fait, le code que j'ai mis au dessus correspond au renderer d'une liste.

Donc maintenant, le truc c'est que la liste est dessinee avant que les elements du renderer le soient.
En gros, ma liste se base sur la taille par defaut du textArea pour afficher ses elements, sauf que du coup, lorsque les elements et leur height sont mis a jour, la liste, elle, ne l'est pas.. quelqu'un voit il comment faire ?
Gaaaga est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 11/06/2008, 16h14   #5
Nouveau Membre du Club
 
Inscription : février 2006
Messages : 145
Détails du profil
Informations forums :
Inscription : février 2006
Messages : 145
Points : 27
Points : 27
Bon, j'ai modifie mon code, :

j'ai rajoute ca dans ma liste :
Code :
variableRowHeight="true" wordWrap="true"
et ma fonction du renndere :

Code :
1
2
3
4
5
6
7
 private function resizeme(event:Event):void
           {
             var ta:TextArea = event.target as TextArea;
             ta.explicitHeight = ta.textHeight + 10;
             this.height = hBoxLabels.height +  ta.explicitHeight + 28; // 28 is the paddingTop+verticalGap 
 
           }
mais il reste des bugs ponctuels, genre parfois un de mes TextArea va avoir une height completment disproportionnee (bcp trop grande) et en scrollant ca va se remettre bien, ou pas. C'est chelou... mais c'est bidouille !
Gaaaga est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 02h29.


 
 
 
 
Partenaires

Hébergement Web