Hello everybody, je découvre haxe.

Le but est de déplacer à la souris un champ input FTextInput (lib fcomponentshx).

Dans la fonction main de la classe j'appelle une nouvelle instance du champ :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
texteinput      = new FTextInput (flash.Lib.current, TEXTEDEPART, { x : textinputposx, y : textinputposy },TEXTINPUTSIZEX,TEXTINPUTSIZEY);
Le champ input est correctement affiché et fonctionne, mais je me heurte à de fâcheux soucis dans la fonction static deplacer_champ(event:MouseEvent) pour le déplacer à la souris :
La ligne "mc.addChild(texteinput);" retourne cette erreur de compilation : "fcomponentshx.FTextInput should be flash.display.DisplayObject".

Est-ce que quelqu'un peut m'aider svp ?

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
 
import flash.display.MovieClip;
 
import flash.events.MouseEvent;
 
import flash.events.Event;
 
import flash.events.FocusEvent;
import flash.display.Graphics;
 
import flash.display.Shape;
 
import flash.display.Sprite;
 
import flash.events.KeyboardEvent;
import flash.display.Loader;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.text.TextFieldAutoSize;
 
import flash.text.StyleSheet;
import fcomponentshx.FTextInput;
 
class FTextInputGFX extends MovieClip{}
 
class Library extends MovieClip{}
 
 
class Bublz{
 
        static inline var TOOLBOXSIZEX          = 32;
        static inline var TOOLBOXSIZEY          = 32;
        static inline var TEXTINPUTSIZEX        = 32;
        static inline var TEXTINPUTSIZEY        = 32;
        static inline var TOOLBOXSPACE          = 4;
        static var textinputposx:Float          = (TOOLBOXSIZEX*2+TOOLBOXSPACE*2);
        static var textinputposy:Float          = 0;
        static inline var POSX                  = 0;
        static inline var POSY                  = 0;
        static inline var IMGW                  = 600;
        static inline var IMGH                  = 480;
        static inline var TEXTEDEPART           = 'Tape ton texte';        
	static var mc :                         MovieClip;
 
	static var stage :                      Dynamic;
	static var texteinput ;
	static var bulle :                      Sprite;
	static var handlemove :                 Sprite;
	static var handleresize :               Sprite;
	static var dim_x :                      Float=50;
	static var dim_y :                      Float=30;
	static var deplace :                    Bool=false;
	static var redim   :                    Bool=false;
	static var survolbulle :                Bool=false;
	static var survolhandlemove :           Bool=false;
	static var survolhandleresize :         Bool=false;
	static var start_resize_x :             Float=0;
	static var start_resize_y :             Float=0;
 
	static var nickTextInput :              FTextInput;
 
 
 
	static function main(){
 
 
		mc 			= flash.Lib.current;
 
		stage 			= mc.stage;
 
		var rect:Shape = new Shape();
		rect.graphics.beginFill(0xFFFFFF);
		rect.graphics.drawRect(POSX,POSY, IMGW,IMGH);
		rect.graphics.endFill();
		flash.Lib.current.addChild(rect);
		var ldr:Loader = new Loader();
		ldr.mask = rect;
 
		var url:String = flash.Lib.current.loaderInfo.parameters.img; 
		var url:String = "content/images/"+url;
		var urlReq:URLRequest = new URLRequest(url);
		ldr.load(urlReq);
		flash.Lib.current.addChild(ldr);
 
 
                texteinput      = new FTextInput (flash.Lib.current, TEXTEDEPART, { x : textinputposx, y : textinputposy },TEXTINPUTSIZEX,TEXTINPUTSIZEY);
 
	   	handlemove = new Sprite();
		handlemove.graphics.lineStyle(1,0xFF7799);
		handlemove.graphics.beginFill(0xFF99AA);
		handlemove.graphics.drawRect(0,0,TOOLBOXSIZEX,TOOLBOXSIZEY);
                handlemove.x = 0;
 
		handlemove.y = 0;
 
	   	handleresize = new Sprite();
 
		handleresize.graphics.lineStyle(1,0xFF7799);
 
		handleresize.graphics.beginFill(0xFF99AA);
		handleresize.graphics.drawRect(TOOLBOXSIZEX+TOOLBOXSPACE,0,TOOLBOXSIZEX,TOOLBOXSIZEY);
		handleresize.x = 0;
 
		handleresize.y = 0;
 
		bulle = new Sprite();
                bulle = flash.Lib.attach("Bulle");
 
      		bulle.addEventListener(MouseEvent.MOUSE_DOWN, survol_bulle);
		handlemove.addEventListener(MouseEvent.MOUSE_DOWN, survol_handlemove);
		handleresize.addEventListener(MouseEvent.MOUSE_DOWN, survol_handleresize);
		bulle.addEventListener(MouseEvent.MOUSE_OUT, quit_bulle);
		handlemove.addEventListener(MouseEvent.MOUSE_OUT, quit_handlemove);
		handleresize.addEventListener(MouseEvent.MOUSE_OUT, quit_handleresize);
 
		stage.addEventListener(MouseEvent.MOUSE_MOVE, bouge);
 
		mc.addChild(bulle);	
		mc.addChild(texteinput);		
		mc.addChild(handlemove);
 
		mc.addChild(handleresize);
 
	}
 
 
	static function survol_bulle(event:MouseEvent){survolbulle=true;}
	static function survol_handlemove(event:MouseEvent){survolhandlemove=true;}
	static function survol_handleresize(event:MouseEvent){survolhandleresize=true;start_resize_x= (event.stageX)-dim_x*0.5;start_resize_y= (event.stageY)-dim_y*0.5;}
	static function quit_bulle(event:MouseEvent){survolbulle=false;}
	static function quit_handlemove(event:MouseEvent){survolhandlemove=false;}
	static function quit_handleresize(event:MouseEvent){survolhandleresize=false;}
 
	static function bouge(event:MouseEvent){
 
		if(event.buttonDown){
			if (survolhandlemove==true){
				deplace         = true;
			}else if ((survolhandleresize==true) && redim==false){
				redim           = true;
			}
 
 
    		}
    		if(!event.buttonDown){
			deplace                 = false;
			redim                   = false;
			bulle.alpha             = 1;
 
    		}
 
 
		if (deplace==true){
			var mouse_x   : Float 	= event.stageX;
			var mouse_y   : Float 	= event.stageY;
			texteinput.x 		= mouse_x+dim_x/2;
 
			texteinput.y 		= mouse_y+dim_y/2;
			bulle.x 		= mouse_x;
 
			bulle.y 		= mouse_y;
			bulle.alpha=0.5;		
		}else if (redim==true){
			var mouse_x   : Float 	= (event.stageX)-dim_x*0.5;
			var mouse_y   : Float 	= (event.stageY)-dim_y*0.5;
			var mouse_x2  : Float 	= event.stageX;
			var mouse_y2  : Float 	= event.stageY;
			dim_x			= dim_x+(mouse_x-start_resize_x);
			dim_y			= dim_y+(mouse_y-start_resize_y);
			bulle.width		= dim_x;
			bulle.height		= dim_y;
			texteinput.width	= dim_x;
			texteinput.height	= dim_y;
			bulle.alpha=0.5;
		}
 
  	}	
 
}