代码
//主应用loadFp.mxml    
   
<!--l version="1.0" encoding="utf-8-->   
   
        
            
        
   
        
   
       

//主应用loadFp.mxml 




//flash cs3代码,生成所需要的fpl.swf    
   
import flash.display.Stage;    
Stage.align = 
"LT";    
//Stage.scaleMode = 
"showAll";    
var url = 
"template.swf";    
var fp;    
//localConnection通讯接口    
var caller:LocalConnection = new LocalConnection();    
var sender:LocalConnection = new LocalConnection();    
caller.connect(
"_flashpaperloader");    
caller.allowDomain(
"*");    
sender.allowDomain(
"*");    
Security.allowDomain(
"*");    
//设置页面    
//caller.setPage = function(n:Number)    
//{    
        //fp.setCurrentPage(n);    
//}    
   
//设置大小    
caller.setPaperSize = function(w:Number,h:Number)    
{    
         trace(
"fpLoader width=" + w + " height =" + h) ;    
         fp.setSize(w,h);    
}    
//设置缩放    
//caller.setCurrentZoom = function(zoom:Object)    
//{    
        //fp.setCurrentZoom(zoom);    
        //sendCurrentZoom();    
//}    
//设置下一页    
//caller.nextPage = function()    
//{    
        //var p:Number = fp.getCurrentPage();    
        //if(p + 1 <= fp.getNumberOfPages())    
                //fp.setCurrentPage(p + 1);    
//}    
   
//设置上一页    
//caller.prePage = function()    
//{    
        //var p:Number = fp.getCurrentPage();    
        //if(p - 1 > 0)    
                //fp.setCurrentPage(p - 1);    
//}    
   
   
//卸载    
caller.unload = function()    
{    
         caller.close();            
         caller = null;    
         sender = null;    
         fp.destroy();    
         fp = null;    
         unloadAndStop();    
         paper.unloadMovie();    
         paper = null;    
}    
   
   
// function: loadFlashPaper    
// ------------------------    
// Load FlashPaper document, size it,    
// Parameters:    
//    path_s: Path of SWF to load    
//   dest_mc: Movie clip to hold the imported SWF    
//   width_i: New size of the dest MC    
// height_i: New size of the dest MC    
// loaded_o: (optional) Object to be notified that loading is complete    
function loadFlashPaper(path_s, dest_mc, loaded_o) {    
         var intervalID = 0;    
         var loadFunc = function(){    
                 trace(
"加载开始....");    
                 dest_mc._visible = false;                    
                 fp = dest_mc.getIFlashPaper();    
                if (!fp) {    
                        return;    
                 } else if (!fp.setSize(0,0)){    
                         trace(
"没有设置窗口大小");    
                        return;    
                 } else {    
                         trace(
"flashPaper加载成功了");    
                         clearInterval(intervalID);                    
                        //var pages_i = fp.getNumberOfPages();    
                        //paper.toolbar_mc.brandClip_mc.swapDepths(1000);    
                //paper.toolbar_mc.brandClip_mc.removeMovieClip();    
                        //ctrlHolder_mc.swapDepths(_root.control_mc);    
                         dest_mc._visible = true;                        // Now show the document    
                        //_root.control_mc._visible = true;         // Now show the controller    
                         loaded_o.onLoaded(fp);    
                 }    
         }    
         intervalID = setInterval(loadFunc, 100);    
         dest_mc.loadMovie(path_s);    
}    
   
   
// function: onLoaded()    
// ------------------------    
// Called once loading is complete    
// Parameters:    
//    fp: FlashPaper interface (returned by getIFlashPaper())    
function onLoaded() {    
        // We can now call the FlashPaper API functions.    
        // Remove the standard user interface features:    
        //fp.showUIElement(
"PrevNext", false);    
         fp.showUIElement(
"Print", false);    
        //fp.showUIElement(
"Find", false);    
        //fp.showUIElement(
"Tool", false);    
        //fp.showUIElement(
"Pop", false);    
        //fp.showUIElement(
"Zoom", false);    
        //fp.showUIElement(
"Page", false);    
        //fp.showUIElement(
"Overflow", false);    
        //fp.enableScrolling(false);    
        // Some additional API features (here commented out):    
            
         fp.setCurrentZoom(100);    
        //sendCurrentZoom();    
         sender.send(
"_flexloader","fpLoaded");    
}    
   
// Hide the navigation controller until after the document is loaded:    
//_root.control_mc._visible = false;      
   
// Create movie clip to hold the document:    
var paper = this.createEmptyMovieClip(
"paper",100);    
// Create movie clip to exchange the depth with the navigation controller clip:    
//var ctrlHolder_mc = this.createEmptyMovieClip(
"ctrlHolder",200);    
   
// Position the document clip on the stage:    
paper._x = 0;    
paper._y = 0;    
   
// Load the FlashPaper document:    
loadFlashPaper(url, paper, this);   

 

 

posted on 2010-04-16 09:42  钱途无梁  阅读(1202)  评论(0编辑  收藏  举报