2009-11-11 179 views

回答

0

的JavaScript Flex應用程序駐留在HTML頁面內..

<script language="JavaScript" type="text/javascript"> 
function images(url) 
{ 
var width = 700; 
var height = 500; 
var left = (screen.width - width)/2; 
var top = (screen.height - height)/2; 
var params = 'width='+width+', height='+height; 
params += ', top='+top+', left='+left; 
params += ', directories=no'; 
params += ', location=no'; 
params += ', menubar=no'; 
params += ', resizable=no'; 
params += ', scrollbars=no'; 
params += ', status=no'; 
params += ', toolbar=no'; 
newwin=window.open(url,'Screenshots', params); 
if (window.focus) {newwin.focus()} 
return false; 
} 
</script> 

,並單擊該按鈕時調用的Flex功能...

private function imagesButtonClick():void { 
    var url:String = data.images; 
    ExternalInterface.call("images", url); 
} 
1

您可以使用HTTPService調用一個php或html文件。

import mx.rpc.http.HTTPService 


<mx:HTTPService method="post" url="{php path}" resultFormat="e4x" ShowBusyCursor="true" /> 

PHP或HTML

<?php 

echo "<script>window.open('url path','mywindow','width=400,height=200,scrollbars=no, toolbar=no,menubar=no')</script>"; 


?> 

請檢查小錯誤。

希望這有助於

+0

喜Treby,我不太確定POST方法對PHP文件是如何工作的......在瀏覽器中調用的php代碼有效,但不在Flex代碼中。我已經做了進一步的研究,並相信我應該能夠使用ExternalInterface函數將JavaScript放入Flex中,但不能確定。 – medoix

+0

您可以忽略method =「post」,只需將url路徑設爲php或html即可。而在html方面,你只需把代碼放在 – Treby