Précédent   Forum des professionnels en informatique > Webmasters - Développement Web > Flash/Flex > Flash > AS3
AS3 Questions relatives à la programmation ActionScript 3 (Cours AS3)
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 05/12/2010, 11h45   #1
Membre Expert
 
Avatar de Madfrix
 
Inscription : juin 2007
Messages : 2 278
Détails du profil
Informations personnelles :
Localisation : France, Gironde (Aquitaine)

Informations forums :
Inscription : juin 2007
Messages : 2 278
Points : 2 324
Points : 2 324
Par défaut problème de crossdomain

Bonjour,

dans mon apprentissage de Flex et d'AS3, je cherche aujourd'hui à créer un serveur de socket couplé à Flex. Le serveur est réalisé via PHP et est fonctionnel (testé en full PHP). Maintenant, j'ai crée un petit projet Flex pour tester mon serveur mais j'obtiens l'erreur suivante (je bosse en local via wamp server) :

Citation:
securityErrorHandler: [SecurityErrorEvent type="securityError" bubbles=false cancelable=false eventPhase=2 text="Error #2048"]
Voici mon arborescence (la plus simple possible en fait...) :

http://localhost/flex_socket/test.html -> mon projet Flex
http://localhost/socket/Serveur.php -> mon serveur de socket

J'ai testé de créer un fichier crossdomain.xml sous http://localhost/ et http://localhost/socket/ mais j'ai le même résultat. Voici le crossdomain :

Code :
1
2
3
4
5
6
7
8
9
 
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "
http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
    <site-control permitted-cross-domain-policies="all" />
    <allow-access-from domain="127.0.0.1" to-ports="*" secure="false"/>
    <allow-http-request-headers-from domain="127.0.0.1"/>
</cross-domain-policy>
J'ai testé plusieurs versions de crossdomain pour le même résultat...

Voici les sources Flex de mon projet :

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
 
<?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/halo" 
	xmlns:mx1="library://ns.adobe.com/flex/mx"
	creationComplete="init()">
 
	<s:layout>
		<s:VerticalLayout />
	</s:layout>
 
	<fx:Script>
		<![CDATA[
			import sockets.SocketPerso;
 
			private var _socket:SocketPerso;
 
			private function init():void
			{
				_socket = new SocketPerso();
				_socket.connect("127.0.0.1", 25854);
			}
 
		]]>
	</fx:Script>
 
</s:Application>

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
 
package sockets
{
	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.events.ProgressEvent;
	import flash.events.SecurityErrorEvent;
	import flash.net.Socket;
 
	import mx.controls.Alert;
 
	public class SocketPerso extends Socket
	{
		public function SocketPerso(host:String=null, port:int=0)
		{
			super();
 
			configureListeners();
 
			if(host && port)
				super.connect(host, port);
 
		}
 
		private function configureListeners():void {
			addEventListener(Event.CLOSE, closeHandler);
			addEventListener(Event.CONNECT, connectHandler);
			addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
			addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
			addEventListener(ProgressEvent.SOCKET_DATA, socketDataHandler);
		}
 
		private function closeHandler(event:Event):void {
			Alert.show("closeHandler: " + String(event));
		}
 
		private function connectHandler(event:Event):void {
			Alert.show("connectHandler: " + String(event));
			sendRequest();
		}
 
		private function sendRequest():void
		{
			writeUTFBytes("test");
			flush();
		}
 
		private function ioErrorHandler(event:IOErrorEvent):void {
			Alert.show("ioErrorHandler: " + String(event));
		}
 
		private function securityErrorHandler(event:SecurityErrorEvent):void {
			Alert.show("securityErrorHandler: " + String(event));
		}
 
		private function socketDataHandler(event:ProgressEvent):void {
			Alert.show("socketDataHandler: " + String(event));
			readResponse();
		}
 
		private function readResponse():void {
			Alert.show(readUTFBytes(bytesAvailable));			
		}
 
	}
}
Une idée ?

Merci
Madfrix est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/12/2010, 15h43   #2
Membre Expert
 
Avatar de Madfrix
 
Inscription : juin 2007
Messages : 2 278
Détails du profil
Informations personnelles :
Localisation : France, Gironde (Aquitaine)

Informations forums :
Inscription : juin 2007
Messages : 2 278
Points : 2 324
Points : 2 324
J'ai rajouté ceci dans ma fonction init :

Code :
1
2
 
Security.loadPolicyFile("http://127.0.0.1/crossdomain.xml");
et j'ai fait un crossdomain le plus simple possible :

Code :
1
2
3
4
5
6
7
 
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "
http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
    <allow-access-from domain="*" to-ports="*" />
</cross-domain-policy>
Mais qu'il y ai un fichier ou non, avec des instructions mauvaises ou non j'ai toujours le même message d'erreur (cf post d'avant)...
Madfrix est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 13h21.


 
 
 
 
Partenaires

Hébergement Web