Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Oct 2001
    Messaggi
    275

    caricare html in un div da flash as3

    salve,
    ho un mc con diversi bottoni
    vorrei che premendo questi pulsanti, il contenuto html venga caricato in un div presente nella stessa pagina, evitando il refresh
    questo esempio funziona in html
    codice:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    	<head>
    		<title>intro_scena6js</title>
    		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    		<style type="text/css" media="screen">
    		html, body { height:100%; background-color: #009999;}
    		body { margin:0; padding:0; overflow:hidden; }
    		#flashContent { width:100%; height:100%; }
    		</style>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
    
    
    <script>
    function createRequestObject() 
    {
    	var returnObj = false;
    	
        if(window.XMLHttpRequest) {
            returnObj = new XMLHttpRequest();
        } else if(window.ActiveXObject) {
    		try {
    			returnObj = new ActiveXObject("Msxml2.XMLHTTP");
    			} catch (e) {
    			try {
    			returnObj = new ActiveXObject("Microsoft.XMLHTTP");
    			}
    			catch (e) {}
    			}
    			
        }
    	return returnObj;
    }
    var http = createRequestObject();
    var target;
    // This is the function to call, give it the script file you want to run and
    // the div you want it to output to.
    function sendRequest(scriptFile, targetElement)
    {	
    	target = targetElement;
    	try{
    	http.open('get', scriptFile, true);
    	}
    	catch (e){
    	document.getElementById(target).innerHTML = e;
    	return;
    	}
    	http.onreadystatechange = handleResponse;
    	http.send();	
    }
    function handleResponse()
    {	
    	if(http.readyState == 4) {		
    	try{
    		var strResponse = http.responseText;
    		document.getElementById(target).innerHTML = strResponse;
    		} catch (e){
    		document.getElementById(target).innerHTML = e;
    		}	
    	}
    }
    </script>
    
    
    	</head>
    	<body>
    
    Link Text
    
    <div id="content" style="width: 1024px; height: 500px; background: red"></div>
    	</body>
    </html>
    dove se premo il link, license.txt viene caricato nel div "content"
    come faccio a trasformare questo codice javascript in flash as3?
    ho provato questo

    navigateToURL(new URLRequest("javascript:sendRequest('license.txt', 'content');"));

    ma non funziona, nel senso che se clicco sul pulsante si apre una pagina blank con questo url
    about:blank
    dove sbaglio?
    grazie!

  2. #2
    Utente di HTML.it
    Registrato dal
    Oct 2001
    Messaggi
    275
    ok, ho un altro codice, e in as2 funziona benissimo
    nell'header ho:

    codice:
     <script>       
            
             function loadNewPage(temp) {
                    var req = new XMLHttpRequest();
                    req.open("GET", temp, false);
                    req.send(null);
                    var page = req.responseText;
                    document.getElementById("content").innerHTML = page;
     }
     
     </script>
    mentre il codice del pulsante in flash è

    codice:
    myButton.onRelease = function(){
        getURL("javascript:loadNewPage('/about');");
    	gotoAndPlay(1);
    }
    ora ho provato a tradurre in as3 in questo modo:

    codice:
    pulsante.addEventListener( MouseEvent.CLICK, muovi );
    function muovi(e:MouseEvent):void {
    navigateToURL(new URLRequest("javascript:loadNewPage('/about');"),"");
    ma non funziona, nel senso che in chrome non succede niente, mentre in ff mi apre una pagina blank
    qlc mi aiuta pls?
    grazie!

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.