IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Flex Discussion :

Test du composant IFrame disponible sur Tour de Flex [Flex4]


Sujet :

Flex

  1. #1
    Membre à l'essai
    Profil pro
    Inscrit en
    Juin 2011
    Messages
    22
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2011
    Messages : 22
    Points : 15
    Points
    15
    Par défaut Test du composant IFrame disponible sur Tour de Flex
    Bonjour à tous,

    J'ai essayé de tester avec mon Flash Builder le composant IFrame disponible sur Tour de Flex (http://www.adobe.com/devnet-apps/flex/tourdeflex/web/ puis saisir "IFrame" dans la barre de recherche). Il y a deux mxml :
    • IFrame.mxml
    • IFrameDemo.mxml

    J'obtiens bien un arbre dans le panel de gauche. En revanche je n'ai strictement rien dans le panel de droite, que je clique ou non sur les éléments de l'arbre.

    Pourriez-vous m'expliquer pourquoi?

    Merci par avance à tous.

  2. #2
    Membre expert
    Avatar de Jim_Nastiq
    Homme Profil pro
    Architecte, Expert Flex
    Inscrit en
    Avril 2006
    Messages
    2 335
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Architecte, Expert Flex
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2006
    Messages : 2 335
    Points : 3 189
    Points
    3 189
    Par défaut
    Salut,

    probablement car tu n'as pas modifié le fichier template html qui modifie quelques propriétés du swf (wmode et opacity de mémoire... ).

    Pensez vraiment à effectuer une recherche avant de poster, ici et sur un moteur de recherche! c'est la moindre des choses
    Pensez au tag

    Mon Blog sur la techno Flex
    Ma page sur Developpez.com

    Jim_Nastiq

  3. #3
    Membre à l'essai
    Profil pro
    Inscrit en
    Juin 2011
    Messages
    22
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2011
    Messages : 22
    Points : 15
    Points
    15
    Par défaut
    Bonjour, merci pour avoir répondu rapidement.

    Sur http://www.communitymx.com/content/a....cfm?cid=e5141 j'ai trouvé la ligne de code à ajouter à la balise <object> :

    <param name="wmode" value="opaque">

    J'ai donc ajouté cette ligne à mon fichier index.template.html mais le contenu de ma page HTML ne s'affiche toujours pas..

    En fait je ne savais pas à laquelle des deux balises <object> il fallait rajouter la ligne, alors que je l'ai ajoutée aux deux, ce qui me donne la balise <noscript> suivante :

    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
    <noscript>
                <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="${width}" height="${height}" id="${application}">
                    <param name="movie" value="${swf}.swf" />
                    <param name="quality" value="high" />
                    <param name="bgcolor" value="${bgcolor}" />
                    <param name="allowScriptAccess" value="sameDomain" />
                    <param name="allowFullScreen" value="true" />
                    <param name="wmode" value="opaque" /> 
                    <!--[if !IE]>-->
                    <object type="application/x-shockwave-flash" data="${swf}.swf" width="${width}" height="${height}">
                        <param name="quality" value="high" />
                        <param name="bgcolor" value="${bgcolor}" />
                        <param name="allowScriptAccess" value="sameDomain" />
                        <param name="allowFullScreen" value="true" />
                        <param name="wmode" value="opaque" /> 
                    <!--<![endif]-->
                    <!--[if gte IE 6]>-->
                    	<p> 
                    		Either scripts and active content are not permitted to run or Adobe Flash Player version
                    		${version_major}.${version_minor}.${version_revision} or greater is not installed.
                    	</p>
                    <!--<![endif]-->
                        <a href="http://www.adobe.com/go/getflashplayer">
                            <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash Player" />
                        </a>
                    <!--[if !IE]>-->
                    </object>
                    <!--<![endif]-->
                </object>
    	    </noscript>
    Une nouvelle fois merci d'avance pour votre aide.

  4. #4
    Membre expert
    Avatar de Jim_Nastiq
    Homme Profil pro
    Architecte, Expert Flex
    Inscrit en
    Avril 2006
    Messages
    2 335
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Architecte, Expert Flex
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2006
    Messages : 2 335
    Points : 3 189
    Points
    3 189
    Par défaut
    Ok et à tout hazard tu n'aurais pas oublié le div qui accueille le contenu HTML ?

    Peux t'on voir l'intégralité de ton template html ?

    Pensez vraiment à effectuer une recherche avant de poster, ici et sur un moteur de recherche! c'est la moindre des choses
    Pensez au tag

    Mon Blog sur la techno Flex
    Ma page sur Developpez.com

    Jim_Nastiq

  5. #5
    Membre à l'essai
    Profil pro
    Inscrit en
    Juin 2011
    Messages
    22
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2011
    Messages : 22
    Points : 15
    Points
    15
    Par défaut
    Non je n'ai pas mis de div pour accueillir le contenu HTML. Faut-il le mettre dans le body? Mon index.template.html est le suivant

    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
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <!-- saved from url=(0014)about:internet -->
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">	
        <!-- 
        Smart developers always View Source. 
     
        This application was built using Adobe Flex, an open source framework
        for building rich Internet applications that get delivered via the
        Flash Player or to desktops via Adobe AIR. 
     
        Learn more about Flex at http://flex.org 
        // -->
        <head>
            <title>${title}</title>
            <meta name="google" value="notranslate">         
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    		<!-- Include CSS to eliminate any default margins/padding and set the height of the html element and 
    		     the body element to 100%, because Firefox, or any Gecko based browser, interprets percentage as 
    			 the percentage of the height of its parent container, which has to be set explicitly.  Fix for
    			 Firefox 3.6 focus border issues.  Initially, don't display flashContent div so it won't show 
    			 if JavaScript disabled.
    		-->
            <style type="text/css" media="screen"> 
    			html, body	{ height:100%; }
    			body { margin:0; padding:0; overflow:auto; text-align:center; 
    			       background-color: ${bgcolor}; }   
    			object:focus { outline:none; }
    			#flashContent { display:none; }
            </style>
     
    		<!-- Enable Browser History by replacing useBrowserHistory tokens with two hyphens -->
            <!-- BEGIN Browser History required section ${useBrowserHistory}>
            <link rel="stylesheet" type="text/css" href="history/history.css" />
            <script type="text/javascript" src="history/history.js"></script>
            <!${useBrowserHistory} END Browser History required section -->  
     
            <script type="text/javascript" src="swfobject.js"></script>
            <script type="text/javascript">
                <!-- For version detection, set to min. required Flash Player version, or 0 (or 0.0.0), for no version detection. --> 
                var swfVersionStr = "${version_major}.${version_minor}.${version_revision}";
                <!-- To use express install, set to playerProductInstall.swf, otherwise the empty string. -->
                var xiSwfUrlStr = "${expressInstallSwf}";
                var flashvars = {};
                var params = {};
                params.quality = "high";
                params.bgcolor = "${bgcolor}";
                params.allowscriptaccess = "sameDomain";
                params.allowfullscreen = "true";
                var attributes = {};
                attributes.id = "${application}";
                attributes.name = "${application}";
                attributes.align = "middle";
                swfobject.embedSWF(
                    "${swf}.swf", "flashContent", 
                    "${width}", "${height}", 
                    swfVersionStr, xiSwfUrlStr, 
                    flashvars, params, attributes);
    			<!-- JavaScript enabled so display the flashContent div in case it is not replaced with a swf object. -->
    			swfobject.createCSS("#flashContent", "display:block;text-align:left;");
            </script>
        </head>
        <body>
            <!-- SWFObject's dynamic embed method replaces this alternative HTML content with Flash content when enough 
    			 JavaScript and Flash plug-in support is available. The div is initially hidden so that it doesn't show
    			 when JavaScript is disabled.
    		-->
            <div id="flashContent">
            	<p>
    	        	To view this page ensure that Adobe Flash Player version 
    				${version_major}.${version_minor}.${version_revision} or greater is installed. 
    			</p>
    			<script type="text/javascript"> 
    				var pageHost = ((document.location.protocol == "https:") ? "https://" :	"http://"); 
    				document.write("<a href='http://www.adobe.com/go/getflashplayer'><img src='" 
    								+ pageHost + "www.adobe.com/images/shared/download_buttons/get_flash_player.gif' alt='Get Adobe Flash player' /></a>" ); 
    			</script> 
            </div>
     
           	<noscript>
                <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="${width}" height="${height}" id="${application}">
                    <param name="movie" value="${swf}.swf" />
                    <param name="quality" value="high" />
                    <param name="bgcolor" value="${bgcolor}" />
                    <param name="allowScriptAccess" value="sameDomain" />
                    <param name="allowFullScreen" value="true" />
                    <param name="wmode" value="opaque"/> 
                    <!--[if !IE]>-->
                    <object type="application/x-shockwave-flash" data="${swf}.swf" width="${width}" height="${height}">
                        <param name="quality" value="high" />
                        <param name="bgcolor" value="${bgcolor}" />
                        <param name="allowScriptAccess" value="sameDomain" />
                        <param name="allowFullScreen" value="true" />
                        <param name="wmode" value="opaque"/> 
                    <!--<![endif]-->
                    <!--[if gte IE 6]>-->
                    	<p> 
                    		Either scripts and active content are not permitted to run or Adobe Flash Player version
                    		${version_major}.${version_minor}.${version_revision} or greater is not installed.
                    	</p>
                    <!--<![endif]-->
                        <a href="http://www.adobe.com/go/getflashplayer">
                            <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash Player" />
                        </a>
                    <!--[if !IE]>-->
                    </object>
                    <!--<![endif]-->
                </object>
    	    </noscript>		
       </body>
    </html>
    Merci

  6. #6
    Membre expert
    Avatar de Jim_Nastiq
    Homme Profil pro
    Architecte, Expert Flex
    Inscrit en
    Avril 2006
    Messages
    2 335
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Architecte, Expert Flex
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2006
    Messages : 2 335
    Points : 3 189
    Points
    3 189
    Par défaut
    Si tu n'as pas de div alors forcement ... regarde le composant que tu utilises et essaye de comprendre comment il fonctionne.

    Tu trouveras une multitude d'informations sur ce sujet ici ou sur un tas de site dédié à Flex.

    Pensez vraiment à effectuer une recherche avant de poster, ici et sur un moteur de recherche! c'est la moindre des choses
    Pensez au tag

    Mon Blog sur la techno Flex
    Ma page sur Developpez.com

    Jim_Nastiq

  7. #7
    Membre à l'essai
    Profil pro
    Inscrit en
    Juin 2011
    Messages
    22
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2011
    Messages : 22
    Points : 15
    Points
    15
    Par défaut
    Re-bonjour et merci pour les réponses.

    J'ai réussi à faire apparaître mon IFrame. Le souci maintenant c'est que l'IFrame se place en haut à gauche de l'écran, et par-dessus les deux Panels, alors qu'il devrait se placer dans le second panel (j'ai mis en ligne une capture d'écran à l'adresse http://imageshack.us/photo/my-images/715/scaniframe.png).

    Que dois-je faire pour que l'Iframe s'insère bien dans le second Panel?

    Le code de mon IFrame.mxml est :
    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
    <?xml version="1.0" encoding="utf-8"?>
     
    <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"
    		   resize="callLater(moveIFrame)"
    		   move="callLater(moveIFrame)">
     
    	<mx:Script>
    		<![CDATA[
     
    			import flash.external.ExternalInterface;
    			import flash.geom.Point;
    			import flash.net.navigateToURL;
     
    			private var __source: String;
     
    			/**
    			 * Move iframe through ExternalInterface.  The location is determined using localToGlobal()
    			 * on a Point in the Canvas.
    			 **/
    			private function moveIFrame(): void
    			{
     
    				var localPt:Point = new Point(0, 0);
    				var globalPt:Point = this.localToGlobal(localPt);
     
    				ExternalInterface.call("moveIFrame", globalPt.x, globalPt.y, this.width, this.height);
    			}
     
    			/**
    			 * The source URL for the IFrame.  When set, the URL is loaded through ExternalInterface.
    			 **/
    			public function set source(source: String): void
    			{
    				if (source)
    				{
     
    					if (! ExternalInterface.available)
    					{
    						throw new Error("ExternalInterface is not available in this container. Internet Explorer ActiveX, Firefox, Mozilla 1.7.5 and greater, or other browsers that support NPRuntime are required.");
    					}
    					__source = source;
    					ExternalInterface.call("loadIFrame", source);
    					moveIFrame();
    				}
    			}
     
    			public function get source(): String
    			{
    				return __source;
    			}
     
    			/**
    			 * Whether the IFrame is visible.  
    			 **/
    			override public function set visible(visible: Boolean): void
    			{
    				super.visible=visible;
     
    				if (visible)
    				{
    					ExternalInterface.call("showIFrame");
    				}
    				else 
    				{
    					ExternalInterface.call("hideIFrame");
    				}
    			}
     
    		]]>
    	</mx:Script>
     
    </mx:Canvas>
    Le code de mon IFrameDemo.mxml est :
    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
    <?xml version="1.0" encoding="utf-8"?>
     
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" creationComplete="iFrame.visible=true" viewSourceURL="srcview/index.html"> 
     
    	<mx:HBox width="100%" height="100%">
     
    		<mx:Panel title="Tree" width="200" height="100%" >
    			<mx:Tree id="tree" width="100%" height="100%" dataProvider="{treeData}"
    					 labelField="@label" showRoot="false"
    					 change="iFrame.source = (Tree(event.target).selectedItem.attribute('path').toString());"  />
    		</mx:Panel>
     
    		<mx:Panel width="100%" height="100%" title="Content" paddingTop="1" paddingBottom="1" paddingLeft="1" paddingRight="1" >
    			<IFrame id="iFrame" source="http://www.adobe.com/devnet/flex/" width="100%" height="100%"  />
    			<mx:ControlBar>
    				<mx:CheckBox id="cbVisible" label="IFrame Visible" selected="true" click="iFrame.visible=cbVisible.selected"/>
    			</mx:ControlBar>
    		</mx:Panel>
     
    	</mx:HBox>
     
    	<mx:XMLList id="treeData">
    		<node label="Flex Resources">
    			<node label="Flex Developer Center" path="http://www.adobe.com/devnet/flex/" />
    			<node label="Flex Team Blog" path="http://weblogs.macromedia.com/flexteam/" />
    			<node label="Flex Blogs on MXNA" path="http://weblogs.macromedia.com/mxna/FeedList.cfm#Flex" />
    			<!-- these sites pop themselves out of a frame:
    			<node label="flex.org" path="http://www.flex.org" />
    			<node label="Adobe Labs" path="http://labs.adobe.com/wiki/index.php/Main_Page" />
    			-->
    		</node>
    		<node label="Search">
    			<node label="Google" path="http://www.google.com" />
    			<node label="Yahoo" path="http://www.yahoo.com" />
    		</node>
    	</mx:XMLList>
     
    </mx:Application>
    Et le code de mon index.template.html est :

    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
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <!-- saved from url=(0014)about:internet -->
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">	
        <!-- 
        Smart developers always View Source. 
     
        This application was built using Adobe Flex, an open source framework
        for building rich Internet applications that get delivered via the
        Flash Player or to desktops via Adobe AIR. 
     
        Learn more about Flex at http://flex.org 
        // -->
        <head>
            <title></title>
            <meta name="google" value="notranslate">         
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    		<!-- Include CSS to eliminate any default margins/padding and set the height of the html element and 
    		     the body element to 100%, because Firefox, or any Gecko based browser, interprets percentage as 
    			 the percentage of the height of its parent container, which has to be set explicitly.  Fix for
    			 Firefox 3.6 focus border issues.  Initially, don't display flashContent div so it won't show 
    			 if JavaScript disabled.
    		-->
            <style type="text/css" media="screen"> 
    			html, body	{ height:100%; }
    			body { margin:0; padding:0; overflow:auto; text-align:center; 
    			       background-color: #ffffff; }   
    			object:focus { outline:none; }
    			#flashContent { display:none; }
            </style>
     
    		<!-- Enable Browser History by replacing useBrowserHistory tokens with two hyphens -->
            <!-- BEGIN Browser History required section -->
            <link rel="stylesheet" type="text/css" href="history/history.css" />
            <script type="text/javascript" src="history/history.js"></script>
            <!-- END Browser History required section -->  
     
            <script type="text/javascript" src="swfobject.js"></script>
            <script type="text/javascript" src="AC_OETags.js" ></script>
            <script type="text/javascript">
                <!-- For version detection, set to min. required Flash Player version, or 0 (or 0.0.0), for no version detection. --> 
                var swfVersionStr = "10.0.0";
                <!-- To use express install, set to playerProductInstall.swf, otherwise the empty string. -->
                var xiSwfUrlStr = "playerProductInstall.swf";
                var flashvars = {};
                var params = {};
                params.quality = "high";
                params.bgcolor = "#ffffff";
                params.allowscriptaccess = "sameDomain";
                params.allowfullscreen = "true";
                var attributes = {};
                attributes.id = "IFrameDemo";
                attributes.name = "IFrameDemo";
                attributes.align = "middle";
                swfobject.embedSWF(
                    "IFrameDemo.swf", "flashContent", 
                    "100%", "100%", 
                    swfVersionStr, xiSwfUrlStr, 
                    flashvars, params, attributes);
    			<!-- JavaScript enabled so display the flashContent div in case it is not replaced with a swf object. -->
    			swfobject.createCSS("#flashContent", "display:block;text-align:left;");
     
    // Major version of Flash required
    var requiredMajorVersion = 9;
    // Minor version of Flash required
    var requiredMinorVersion = 0;
    // Minor version of Flash required
    var requiredRevision = 0;
     
    function moveIFrame(x,y,w,h) {
        var frameRef=document.getElementById("myFrame");
        frameRef.style.left=x;
        frameRef.style.top=y;
        var iFrameRef=document.getElementById("myIFrame");	
    	iFrameRef.width=w;
    	iFrameRef.height=h;
    }
     
    function hideIFrame(){
        document.getElementById("myFrame").style.visibility="hidden";
    }
     
    function showIFrame(){
        document.getElementById("myFrame").style.visibility="visible";
    }
     
    function loadIFrame(url){
    	document.getElementById("myFrame").innerHTML = "<iframe id='myIFrame' src='" + url + "'frameborder='40'></iframe>";
    }
     
            </script>
        </head>
     
        <body>
            <!-- SWFObject's dynamic embed method replaces this alternative HTML content with Flash content when enough 
    			 JavaScript and Flash plug-in support is available. The div is initially hidden so that it doesn't show
    			 when JavaScript is disabled.
    		-->
            <div id="flashContent">
            	<p>
    	        	To view this page ensure that Adobe Flash Player version 
    				10.0.0 or greater is installed. 
    			</p>
    			<script type="text/javascript"> 
    				var pageHost = ((document.location.protocol == "https:") ? "https://" :	"http://"); 
    				document.write("<a href='http://www.adobe.com/go/getflashplayer'><img src='" 
    								+ pageHost + "www.adobe.com/images/shared/download_buttons/get_flash_player.gif' alt='Get Adobe Flash player' /></a>" );
     
    			</script> 
            </div>
     
     
    		<div id="myFrame" style="position:absolute;background-color:transparent;border:0px;visibility:hidden;">
     
            </div>
     
           	<noscript>
                <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%" id="IFrameDemo">
                    <param name="movie" value="IFrameDemo.swf" />
                    <param name="quality" value="high" />
                    <param name="bgcolor" value="#ffffff" />
                    <param name="allowScriptAccess" value="sameDomain" />
                    <param name="allowFullScreen" value="true" />
                    <param name="wmode" value="opaque"> 
                    <!--[if !IE]>-->
                    <object type="application/x-shockwave-flash" data="IFrameDemo.swf" width="100%" height="100%">
                        <param name="quality" value="high" />
                        <param name="bgcolor" value="#ffffff" />
                        <param name="allowScriptAccess" value="sameDomain" />
                        <param name="allowFullScreen" value="true" />
                        <param name="wmode" value="opaque"> 
                    <!--<![endif]-->
                    <!--[if gte IE 6]>-->
                    	<p> 
                    		Either scripts and active content are not permitted to run or Adobe Flash Player version
                    		10.0.0 or greater is not installed.
                    	</p>
                    <!--<![endif]-->
                        <a href="http://www.adobe.com/go/getflashplayer">
                            <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash Player" />
                        </a>
                    <!--[if !IE]>-->
                    </object>
                    <!--<![endif]-->
                </object>
    	    </noscript>	
     
       </body>
    </html>
    Merci par avance pour vos réponses.

  8. #8
    Membre expert
    Avatar de Jim_Nastiq
    Homme Profil pro
    Architecte, Expert Flex
    Inscrit en
    Avril 2006
    Messages
    2 335
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Architecte, Expert Flex
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2006
    Messages : 2 335
    Points : 3 189
    Points
    3 189
    Par défaut
    La méthode moveIframe fonctionne t'elle comme elle le devrait ? en débug, as tu vérifier les valeurs de globalPt ? C'est cohérent ?

    Prend la peine de debugger et d'étudier le fonctionnement de cette solution

    Pensez vraiment à effectuer une recherche avant de poster, ici et sur un moteur de recherche! c'est la moindre des choses
    Pensez au tag

    Mon Blog sur la techno Flex
    Ma page sur Developpez.com

    Jim_Nastiq

  9. #9
    Membre à l'essai
    Profil pro
    Inscrit en
    Juin 2011
    Messages
    22
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2011
    Messages : 22
    Points : 15
    Points
    15
    Par défaut
    Bonjour,

    J'ai résolu mon problème. En fait j'ai utilisé un autre composant appelé IFrame.as dont voici le code:

    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
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
    733
    734
    735
    736
    737
    738
    739
    740
    741
    742
    743
    744
    745
    746
    747
    748
    749
    750
    751
    752
    753
    754
    755
    756
    757
    758
    759
    760
    761
    762
    763
    764
    765
    766
    767
    768
    769
    770
    771
    772
    773
    774
    775
    776
    777
    778
    779
    780
    781
    782
    783
    784
    785
    786
    787
    788
    789
    790
    791
    792
    793
    794
    795
    796
    797
    798
    799
    800
    801
    802
    803
    804
    805
    806
    807
    808
    809
    810
    811
    812
    813
    814
    815
    816
    817
    818
    819
    820
    821
    822
    823
    824
    825
    826
    827
    828
    829
    830
    831
    832
    833
    834
    835
    836
    837
    838
    839
    840
    841
    842
    843
    844
    845
    846
    847
    848
    849
    850
    851
    package myPackage
    {
    	import flash.display.DisplayObject;
    	import flash.display.DisplayObjectContainer;
    	import flash.events.Event;
    	import flash.external.ExternalInterface;
    	import flash.geom.Point;
    	import flash.utils.Dictionary;
     
    	import mx.core.Application;
    	import mx.core.Container;
    	import mx.core.UIComponent;
    	import mx.events.FlexEvent;
    	import mx.events.IndexChangedEvent;
    	import mx.events.MoveEvent;
    	import mx.logging.ILogger;
    	import mx.logging.Log;
    	import mx.logging.targets.TraceTarget;
    	import mx.managers.BrowserManager;
    	import mx.utils.URLUtil;
     
    	[Event(name="frameLoad", type="flash.events.Event")] 
     
    	public class IFrame extends Container
    	{
    		public var debug:Boolean = false;
    		public var overlayDetection:Boolean = false;
     
    		private var logTarget:TraceTarget;
     
    		private var __source: String;
    		private var __content: String;
    		private var frameId:String;
    		private var iframeId:String;
     
    		private var validForDisplay:Boolean = true;
     
    		private var containerDict:Object = null;
    		private var settingDict:Object = null;
     
    		private var frameLoaded:Boolean = false;
    		private var functionQueue:Array = [];
     
    		private static var logger:ILogger = Log.getLogger("com.plus.arutherford.ccgi.IFrame");
     
    		/**
    		 * Here we define javascript functions which will be inserted into the DOM
    		 * 
    		 */
    		public static var FUNCTION_CREATEIFRAME:String = 
    			"document.insertScript = function ()" +
    			"{ " +
    			"if (document.createIFrame==null)" + 
    			"{" + 
    			"createIFrame = function (frameID)" +
    			"{ " +
    			"var bodyID = document.getElementsByTagName(\"body\")[0];" +
    			"var newDiv = document.createElement('div');" +
    			"newDiv.id = frameID;" +
    			"newDiv.style.position ='absolute';" +
    			"newDiv.style.backgroundColor = 'transparent';" + 
    			"newDiv.style.border = '0px';" +
    			"newDiv.style.visibility = 'hidden';" +
    			"bodyID.appendChild(newDiv);" +
    			"}" +
    			"}" +
    			"}";
     
    		private static var FUNCTION_MOVEIFRAME:String = 
    			"document.insertScript = function ()" +
    			"{ " +
    			"if (document.moveIFrame==null)" +
    			"{" +
    			"moveIFrame = function(frameID, iframeID, x,y,w,h) " + 
    			"{" +
    			"var frameRef=document.getElementById(frameID);" +
    			"frameRef.style.left=x+'px';" + 
    			"frameRef.style.top=y+'px';" +
    			"var iFrameRef=document.getElementById(iframeID);" +
    			"iFrameRef.width=w;" +
    			"iFrameRef.height=h;" +
    			"}" +
    			"}" +
    			"}";
     
    		public static var FUNCTION_HIDEIFRAME:String = 
    			"document.insertScript = function ()" +
    			"{ " +
    			"if (document.hideIFrame==null)" +
    			"{" +
    			"hideIFrame = function (frameID, iframeID)" +
    			"{" +
    			"var iframeRef = document.getElementById(iframeID);" +
    			"var iframeDoc;" +
    			"if (iframeRef.contentWindow) {" +
    			"iframeDoc = iframeRef.contentWindow.document;" +
    			"} else if (iframeRef.contentDocument) {" +
    			"iframeDoc = iframeRef.contentDocument;" +
    			"} else if (iframeRef.document) {" +
    			"iframeDoc = iframeRef.document;" +
    			"}" +
    			"if (iframeDoc) {" +
    			"iframeDoc.body.style.visibility='hidden';" +
    			"}" +
    			"document.getElementById(frameID).style.visibility='hidden';" +
    			"}" +
    			"}" +
    			"}";
     
    		public static var FUNCTION_SHOWIFRAME:String = 
    			"document.insertScript = function ()" +
    			"{ " +
    			"if (document.showIFrame==null)" +
    			"{" +
    			"showIFrame = function (frameID, iframeID)" +
    			"{" +
    			"var iframeRef = document.getElementById(iframeID);" +
    			"document.getElementById(frameID).style.visibility='visible';" +
     
    			"var iframeDoc;" +
    			"if (iframeRef.contentWindow) {" +
    			"iframeDoc = iframeRef.contentWindow.document;" +
    			"} else if (iframeRef.contentDocument) {" +
    			"iframeDoc = iframeRef.contentDocument;" +
    			"} else if (iframeRef.document) {" +
    			"iframeDoc = iframeRef.document;" +
    			"}" +
    			"if (iframeDoc) {" +
    			"iframeDoc.body.style.visibility='visible';" +
    			"}" +
    			"}" +
    			"}" +
    			"}";
     
    		public static var FUNCTION_HIDEDIV:String = 
    			"document.insertScript = function ()" +
    			"{ " +
    			"if (document.hideDiv==null)" +
    			"{" +
    			"hideDiv = function (frameID, iframeID)" +
    			"{" +
    			"document.getElementById(frameID).style.visibility='hidden';" +
    			"}" +
    			"}" +
    			"}";
     
    		public static var FUNCTION_SHOWDIV:String = 
    			"document.insertScript = function ()" +
    			"{ " +
    			"if (document.showDiv==null)" +
    			"{" +
    			"showDiv = function (frameID, iframeID)" +
    			"{" +
    			"document.getElementById(frameID).style.visibility='visible';" +
    			"}" +
    			"}" +
    			"}";
     
    		public static var FUNCTION_LOADIFRAME:String = 
    			"document.insertScript = function ()" +
    			"{ " +
    			"if (document.loadIFrame==null)" +
    			"{" +
    			"loadIFrame = function (frameID, iframeID, url)" +
    			"{" +
    			"document.getElementById(frameID).innerHTML = \"<iframe id='\"+iframeID+\"' src='\"+url+\"' onLoad='"
    			+ Application.application.id + ".\"+frameID+\"_load()' frameborder='0'></iframe>\";" + 
    			"}" +
    			"}" +
    			"}";
     
    		public static var FUNCTION_LOADDIV_CONTENT:String = 
    			"document.insertScript = function ()" +
    			"{ " +
    			"if (document.loadDivContent==null)" +
    			"{" +
    			"loadDivContent = function (frameID, iframeID, content)" +
    			"{" +
    			"document.getElementById(frameID).innerHTML = \"<div id='\"+iframeID+\"' frameborder='0'>\"+content+\"</div>\";" +
    			"}" +
    			"}" +
    			"}";
     
    		public static var FUNCTION_CALLIFRAMEFUNCTION:String = 
    			"document.insertScript = function ()" +
    			"{ " +
    			"if (document.callIFrameFunction==null)" +
    			"{" +
    			"callIFrameFunction = function (iframeID, functionName, args)" +
    			"{" +
    			"var iframeRef=document.getElementById(iframeID);" +
    			"var iframeDoc;" +
    			"if (iframeRef.contentDocument) {" +
    			"iframeDoc = iframeRef.contentDocument;" +
    			"} else if (iframeRef.contentWindow) {" +
    			"iframeDoc = iframeRef.contentWindow.document;" +
    			"} else if (iframeRef.document) {" +
    			"iframeDoc = iframeRef.document;" +
    			"}" +
    			"if (iframeDoc.wrappedJSObject != undefined) {" +
    			"iframeDoc = iframeDoc.wrappedJSObject;" +
    			"}" +
    			"return iframeDoc[functionName](args);" +
    			"}" +
    			"}" +
    			"}";
     
    		/**
    		 * Track IDs in use throughout the app for iframe
    		 * instances in order to detect and prevent collisions
    		 * 
    		 */
    		public static var idList:Object = new Object();
     
    		private var appHost:String;
    		private var iframeContentHost:String;
     
    		/**
    		 * Constructor
    		 * 
    		 */
    		public function IFrame()
    		{
    			super();
    			this.addEventListener(Event.REMOVED_FROM_STAGE, handleRemove);
    			this.addEventListener(Event.ADDED_TO_STAGE, handleAdd);
    		}
     
    		/**
    		 * Generate DOM elements and build display path.
    		 * 
    		 */
    		override protected function createChildren():void
    		{
    			super.createChildren();
     
    			if (! ExternalInterface.available)
    			{
    				throw new Error("ExternalInterface is not available in this container. Internet Explorer ActiveX, Firefox, Mozilla 1.7.5 and greater, or other browsers that support NPRuntime are required.");
    			}
     
    			if (debug)
    			{
    				logTarget = new TraceTarget();
    				logTarget.addLogger(logger);
    			}
     
    			// Get the host info to check for cross-domain issues
    			BrowserManager.getInstance().initForHistoryManager();
    			var url:String = BrowserManager.getInstance().url;
    			appHost = URLUtil.getProtocol(url) + "://" 
    				+ URLUtil.getServerNameWithPort(url);
     
    			// Generate unique id's for frame div name
    			var idSuffix:int = 0;
    			while (idList[id + idSuffix])
    			{
    				idSuffix++;
    			}
    			frameId = id + idSuffix;
    			iframeId = "iframe_"+frameId;
    			idList[frameId] = true;
     
    			// Register a uniquely-named load event callback for this frame (for load notification)
    			ExternalInterface.addCallback(frameId + "_load", this.handleFrameLoad);
     
    			// Add functions to DOM if they aren't already there
    			ExternalInterface.call(FUNCTION_CREATEIFRAME);
    			ExternalInterface.call(FUNCTION_MOVEIFRAME);
    			ExternalInterface.call(FUNCTION_HIDEIFRAME);
    			ExternalInterface.call(FUNCTION_SHOWIFRAME);
    			ExternalInterface.call(FUNCTION_SHOWDIV);
    			ExternalInterface.call(FUNCTION_HIDEDIV);
    			ExternalInterface.call(FUNCTION_LOADIFRAME);
    			ExternalInterface.call(FUNCTION_LOADDIV_CONTENT);
    			ExternalInterface.call(FUNCTION_CALLIFRAMEFUNCTION);
     
    			// Insert frame into DOM using our precreated function 'createIFrame'
    			ExternalInterface.call("createIFrame", frameId);
     
    			buildContainerList();
     
    			if (loadIndicatorClass)
    			{
    				logger.debug("loadIndicatorClass is {0}", loadIndicatorClass);
    				_loadIndicator = UIComponent(new loadIndicatorClass());
    				addChild(_loadIndicator);
    			}
    			else
    			{
    				logger.debug("loadIndicatorClass is null");
    			}
     
    		}
     
    		/**
    		 * Build list of container objects on the display list path all the way down
    		 * to this object. We will seed the container classes we find with an event
    		 * listener which will be used to test if this object is to be displayed or not.
    		 *
    		 */
    		private function buildContainerList():void
    		{
    			// We are going to store containers against index of child which leads down
    			// to IFrame item.
    			containerDict = new Dictionary();
    			settingDict = new Dictionary();
     
    			var current:DisplayObjectContainer = parent;
    			var previous:DisplayObjectContainer = this;
     
    			while (current!=null)
    			{
    				if (current is Container)
    				{
    					if (current.contains(previous))
    					{
     
    						var childIndex:Number = current.getChildIndex(previous);                
    						logger.debug("index: {0}", childIndex);
    						// Store child index against container
    						containerDict[current] = childIndex;
    						settingDict[current] = childIndex;
     
    						// Tag on a change listener             
    						current.addEventListener(IndexChangedEvent.CHANGE, handleChange);
    						current.addEventListener(MoveEvent.MOVE, handleMove);
    					}
     
    				}        
     
    				previous = current;
    				current = current.parent;
    			}
    			// make sure frame runs visible setter using initial visible state
    			visible = visible;
    		}
     
    		/**
    		 * Triggered by removal of this object from the stage
    		 * 
    		 * @param event Event trigger
    		 *
    		 */
    		public function handleRemove(event:Event):void
    		{
    			// Remove systemManager hooks for overlay detection 
    			if (overlayDetection)
    			{
    				systemManager.removeEventListener(Event.ADDED, systemManager_addedHandler);
    				systemManager.removeEventListener(Event.REMOVED, systemManager_removedHandler);
    			}
    			visible = false;
    		}
     
    		/**
    		 * Triggered by addition of this object to the stage
    		 * 
    		 * @param event Event trigger
    		 *
    		 */
    		public function handleAdd(event:Event):void
    		{
    			// Hook the systemManager to provide overlaying object detection
    			if (overlayDetection)
    			{
    				systemManager.addEventListener(Event.ADDED, systemManager_addedHandler);
    				systemManager.addEventListener(Event.REMOVED, systemManager_removedHandler);
    			}
    			visible = true;
    		}
     
    		/**
    		 * Triggered by one of our listeners seeded all the way up the display
    		 * list to catch a 'changed' event which might hide or display this object.
    		 * 
    		 * @param event Event trigger
    		 *
    		 */
    		private function handleChange(event:Event):void
    		{
    			var target:Object = event.target;
     
    			if (event is IndexChangedEvent)
    			{
    				var changedEvent:IndexChangedEvent = IndexChangedEvent(event)
     
    				var newIndex:Number = changedEvent.newIndex;
     
    				visible = checkDisplay(target, newIndex);
     
    			}
    		}
     
    		/**
    		 * Triggered by one of our listeners seeded all the way up the display
    		 * list to catch a 'move' event which might reposition this object.
    		 * 
    		 * @param event Event trigger
    		 *
    		 */
    		private function handleMove(event:Event):void
    		{
    			moveIFrame();
    		}
     
    		/**
    		 * This function updates the selected view child of the signalling container
    		 * and then compares the path from our IFrame up the displaylist to see if
    		 * the index settings match. Only an exact match all the way down to our
    		 * IFrame will satisfy the condition to display the IFrame contents.
    		 *
    		 * @param target Object event source
    		 * @param newIndex Number index from target object.
    		 * 
    		 */
    		private function checkDisplay(target:Object, newIndex:Number):Boolean
    		{
    			var valid:Boolean = false;
     
    			if (target is Container)
    			{
    				var container:DisplayObjectContainer = DisplayObjectContainer(target);
     
    				// Update current setting
    				settingDict[container] = newIndex;
     
    				valid = true;
     
    				for (var item:Object in containerDict)
    				{
    					var index:Number = lookupIndex(item as Container);
    					var setting:Number = lookupSetting(item as Container);
    					logger.debug(item.toString());
    					valid = valid&&(index==setting);
    				}
    			}
     
    			// Remember this state so we can re-check later without a new IndexChangedEvent
    			validForDisplay = valid;
    			return valid;
    		}
     
    		/**
    		 * Return index of child item on path down to this object. If not
    		 * found then return -1;
    		 *
    		 * @param target Container object
    		 * 
    		 */
    		public function lookupIndex(target:Container):Number
    		{
    			var index:Number = -1;
     
    			try
    			{
    				index = containerDict[target];
    			}
    			catch (e:Error)
    			{
    				// Error not found, we have to catch this or a silent exception
    				// will be thrown.
    				logger.debug(e.toString());
    			}
     
    			return index;
    		}
     
    		/**
    		 * Return index of child item on path down to this object. If not
    		 * found then return -1;
    		 *
    		 * @param target Container object
    		 * 
    		 */
    		public function lookupSetting(target:Container):Number
    		{
    			var index:Number = -1;
     
    			try
    			{
    				index = settingDict[target];
    			}
    			catch (e:Error)
    			{
    				// Error not found, we have to catch this or a silent exception
    				// will be thrown.
    				logger.debug(e.toString());
    			}
     
    			return index;
    		}                
     
    		/**
    		 * Adjust frame position to match the exposed area in the application.
    		 * 
    		 */
    		public function moveIFrame(): void
    		{
     
    			var localPt:Point = new Point(0, 0);
    			var globalPt:Point = this.localToGlobal(localPt);
     
    			ExternalInterface.call("moveIFrame", frameId, iframeId, globalPt.x, globalPt.y, this.width, this.height);
    			logger.debug("move iframe id {0}", frameId);
    		}
     
    		/**
    		 * Triggered by change to component properties.
    		 * 
    		 */
    		override protected function commitProperties():void
    		{
    			super.commitProperties();
     
    			if (source)
    			{
    				frameLoaded = false;
    				ExternalInterface.call("loadIFrame", frameId, iframeId, source);
    				logger.debug("load Iframe id {0}", frameId);
    				// Trigger re-layout of iframe contents.	            
    				invalidateDisplayList();
    			} 
    			else if (content) 
    			{
    				ExternalInterface.call("loadDivContent", frameId, iframeId, content);
    				logger.debug("load Content id {0}", frameId);
    				// Trigger re-layout of iframe contents.	            
    				invalidateDisplayList();
    			}
    		}
     
    		protected function handleFrameLoad():void
    		{			
    			logger.debug("browser reports frame loaded with id {0}", frameId);
    			frameLoaded = true;
    			var queuedCall:Object;
    			var result:Object;
    			// Execute any queued function calls now that the frame is loaded
    			while (functionQueue.length > 0)
    			{
    				queuedCall = functionQueue.pop();
    				logger.debug("frame id {0} calling queued function {1}", frameId, queuedCall.functionName);
    				this.callIFrameFunction(queuedCall.functionName, queuedCall.args, queuedCall.callback);
    			}
    			dispatchEvent(new Event("frameLoad"));
     
    			invalidateDisplayList();
    		}
     
    		/**
    		 * Triggered when display contents change. Adjusts frame layout.
    		 * 
    		 * @param unscaledWidth
    		 * @param unscaledHeight
    		 * 
    		 */
    		override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
    		{
    			super.updateDisplayList(unscaledWidth, unscaledHeight);
     
    			if (_loadIndicator)
    			{
    				if (frameLoaded)
    				{
    					_loadIndicator.visible = false;
    				}
    				else
    				{
    					_loadIndicator.visible = true;
    					var w:int = _loadIndicator.measuredWidth;
    					var h:int = _loadIndicator.measuredHeight;
    					_loadIndicator.setActualSize(w, h);
    					_loadIndicator.move(this.width / 2 - w, this.height / 2 - h);
    				}
    			}
     
    			moveIFrame();
    		}
     
    		/**
    		 * Set source url
    		 * 
    		 * @param url Frame contents
    		 * 
    		 */
    		public function set source(source: String): void
    		{
    			if (source)
    			{
    				__source = source;
    				// mark unloaded now so calls in this frame will be queued 
    				frameLoaded = false; 
    				invalidateProperties();
     
    				// Get the host info to check for cross-domain issues
    				iframeContentHost = URLUtil.getProtocol(source) + "://"
    					+ URLUtil.getServerNameWithPort(source);     
    			}
    		}
     
    		/**
    		 * Return url of frame contents
    		 * 
    		 */
    		public function get source(): String
    		{
    			return __source;
    		}
     
    		/**
    		 * Set content string
    		 * 
    		 */
    		public function set content(content: String): void
    		{
    			if (content)
    			{
    				__content = content;
     
    				invalidateProperties();                
    			}
    		}
     
    		/**
    		 * Return content string of div contents
    		 * 
    		 */
    		public function get content(): String
    		{
    			return __content;
    		}
     
    		/**
    		 * Sets visibility of html iframe. Rtn calls inserted javascript functions.
    		 * 
    		 * @param visible Boolean flag
    		 * 
    		 */
    		override public function set visible(value: Boolean): void
    		{
    			super.visible = value;
     
    			// if we have an iframe in the same domain as the app, call the
    			// specialized functions to update visibility inside the iframe
    			if (visible)
    			{
    				if (source && iframeContentHost == appHost)
    					ExternalInterface.call("showIFrame",frameId,iframeId);
    				else
    					ExternalInterface.call("showDiv",frameId,iframeId);
    				logger.debug("show iframe id {0}", frameId);
    			}
    			else 
    			{
    				if (source && iframeContentHost == appHost)
    					ExternalInterface.call("hideIFrame",frameId,iframeId);
    				else
    					ExternalInterface.call("hideDiv",frameId,iframeId);
    				logger.debug("hide iframe id {0}", frameId);
    			}
    		}
     
    		/**
    		 * Calls a function of the specified name defined on the IFrame document
    		 * (like document.functionName = function () {...} ), passing it an array of arguments.
    		 * May not work if the iframe contents are in a different domain due to security.
    		 * 
    		 * If the frame contents are loaded when this method is called, it will return any
    		 * results from the function immediately to the caller (as well as to the callback
    		 * function, if defined). Otherwise, the call will be queued, this method will return
    		 * null, and results will be passed to the callback function after the frame loads
    		 * and the queued function call executes.
    		 * 
    		 * @param functionName String Name of function to call
    		 * @param args Array List of arguments to pass as an array
    		 * @param callback Function to call (if any) with results of IFrame function execution
    		 * 
    		 */
    		public function callIFrameFunction(functionName:String, args:Array = null, callback:Function = null):String
    		{
    			if (!source)
    			{
    				throw new Error("No iframe to call functions on");
    			}
    			if (iframeContentHost != appHost)
    			{
    				var msg:String = "Warning: attempt to call function " + functionName + 
    					" on iframe " + frameId + " may fail due to cross-domain security.";
    				logger.debug(msg);
    			}
     
    			if (frameLoaded)
    			{
    				// Call the function immediately
    				var result:Object = ExternalInterface.call("callIFrameFunction", iframeId, functionName, args);
    				if (callback != null)
    				{
    					callback(result);
    				}
    				return String(result);
    			}
    			else
    			{
    				// Queue the function for call once the iframe has loaded
    				var queuedCall:Object = {functionName: functionName, args: args, callback:callback};
    				functionQueue.push(queuedCall);
    				return null;
    			}
    		}
     
    		// --------------------------------------------------------------------
    		//  Loading indicator
    		// --------------------------------------------------------------------
    		/**
    		 * A UIComponent class to display centered over the iframe container while
    		 * the browser is loading its content. Should implement measuredHeight
    		 * and measuredWidth in order to be properly sized
    		 */
    		public var loadIndicatorClass:Class;
     
    		protected var _loadIndicator:UIComponent;
     
     
    		// --------------------------------------------------------------------
    		//  Overlaying object detection
    		// --------------------------------------------------------------------
     
    		private var overlappingDict:Dictionary = new Dictionary(true);
    		private var overlapCount:int = 0;
     
    		protected function systemManager_addedHandler(event:Event):void
    		{
    			// A display object was added somewhere
    			var displayObj:DisplayObject = event.target as DisplayObject;
    			if (displayObj.parent == systemManager && displayObj.name != "cursorHolder")
    			{
    				// If the object is a direct child of systemManager (i.e it floats) and isn't the cursor, 
    				// check to see if it overlaps me after it's been drawn
    				this.callLater(checkOverlay, [displayObj]);
    			}
    		}
     
    		protected function systemManager_removedHandler(event:Event):void
    		{
    			// A display object was removed somewhere
    			var displayObj:DisplayObject = event.target as DisplayObject;
    			if (displayObj.parent == systemManager && overlappingDict[displayObj])
    			{
    				logger.debug("iframe {0} heard REMOVE for {1}", frameId, displayObj.toString());
    				// If the object is a direct child of systemManager and was an overlapping object, remove it
    				delete overlappingDict[displayObj];
    				if (--overlapCount == 0)
    				{
    					visible = validForDisplay;
    				}
     
    				if (displayObj is UIComponent)
    				{
    					// Remove listeners for hide and show events on overlappiung UIComponents
    					UIComponent(displayObj).removeEventListener(FlexEvent.HIDE, overlay_hideShowHandler);
    					UIComponent(displayObj).removeEventListener(FlexEvent.SHOW, overlay_hideShowHandler);
    				}
    			}
    		}
     
    		protected function overlay_hideShowHandler(event:FlexEvent):void
    		{
    			var displayObj:DisplayObject = event.target as DisplayObject;
    			if (event.type == FlexEvent.SHOW && !overlappingDict[displayObj])
    			{
    				logger.debug("iframe {0} heard SHOW for {1}", frameId, displayObj.toString());
    				overlappingDict[displayObj] = displayObj;
    				overlapCount++;
    				visible = false;
    			}
    			else if (event.type == FlexEvent.HIDE && overlappingDict[displayObj])
    			{
    				logger.debug("iframe {0} heard HIDE for {1}", frameId, displayObj.toString());
    				delete overlappingDict[displayObj];
    				if (--overlapCount == 0)
    				{
    					visible = validForDisplay;
    				}
    			}
    		}
     
    		/**
    		 * Check to see if the given DisplayObject overlaps this object.
    		 * If so, add it to a dictionary of overlapping objects and update
    		 * this object's visibility.
    		 * 
    		 */
    		protected function checkOverlay(displayObj:DisplayObject):void
    		{			
    			if (this.hitTestStageObject(displayObj))
    			{
    				logger.debug("iframe {0} detected overlap of {1}", frameId, displayObj.toString());
    				overlappingDict[displayObj] = displayObj;
    				overlapCount++;
    				visible = false;
     
    				if (displayObj is UIComponent)
    				{
    					// Listen for hide and show events on overlapping UIComponents
    					// (ComboBox dropdowns for example aren't removed after use; they're just hidden)
    					UIComponent(displayObj).addEventListener(FlexEvent.HIDE, overlay_hideShowHandler, false, 0, true);
    					UIComponent(displayObj).addEventListener(FlexEvent.SHOW, overlay_hideShowHandler, false, 0, true);
    				}
    			}
    		}
     
    		/**
    		 * The native hitTestObject method seems to have some issues depending on
    		 * the situation. This is a custom implementation to work around that.
    		 * This method assumes that the passed DisplayObject is a direct child
    		 * of the stage and therefore has x and y coordinates that are already global
    		 * 
    		 */
    		protected function hitTestStageObject(o:DisplayObject):Boolean
    		{
    			var overlapX:Boolean = false;
    			var overlapY:Boolean = false;
     
    			var localMe:Point = new Point(this.x, this.y);
    			var globalMe:Point = this.parent.localToGlobal(localMe);
     
    			var myLeft:int = globalMe.x;
    			var myRight:int = globalMe.x + this.width;
    			var oLeft:int = o.x;
    			var oRight:int = o.x + o.width;
     
    			// Does object's left edge fall between my left and right edges?
    			overlapX = oLeft >= myLeft && oLeft <= myRight;
    			// Or does my left edge fall between object's left and right edges?
    			overlapX ||= oLeft <= myLeft && oRight >= myLeft;
     
    			var myTop:int = globalMe.y;
    			var myBottom:int = globalMe.y + this.height;
    			var oTop:int = o.y;
    			var oBottom:int = o.y + o.height;
     
    			// Does object's top edge fall between my top and bottom edges?
    			overlapY = oTop >= myTop && oTop <= myBottom;
    			// Or does my top edge fall between object's top and bottom edges?
    			overlapY ||= oTop <= myTop && oBottom >= myTop;
     
    			return overlapX && overlapY;
    		}  
    	}
    }
    Avec ce composant ça marche nikel.

    Merci encore, Jim_Nastiq.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [VB6] Place disponible sur un disque dur.
    Par pcvesoul dans le forum VB 6 et antérieur
    Réponses: 2
    Dernier message: 13/02/2006, 14h17
  2. Quel langage choisir pour appli test de composants réseau ?
    Par ouam81 dans le forum Langages de programmation
    Réponses: 1
    Dernier message: 06/02/2006, 18h18
  3. [Applet] polices disponibles sur mon pc
    Par jessicas dans le forum Applets
    Réponses: 7
    Dernier message: 19/09/2005, 23h35
  4. Réponses: 4
    Dernier message: 03/09/2005, 11h30
  5. Installation de composants Delphi 7 sur Delphi 2005
    Par Leobaillard dans le forum Composants VCL
    Réponses: 5
    Dernier message: 22/06/2005, 18h50

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo