2010-01-29 58 views
0

您好我已经创建了一个动作函数,停止在一个特定的框架,动画工作正常。然后我用一个变量载入一个php文件,其中包含我希望动画停止的帧的编号。这已经加载罚款,我已经加载它的功能。我似乎无法做的是将变量放入函数中,告诉动画停止播放。已经加载了一个PHP变量到闪存,但不能应用它在一个函数

这里是我的代码:

//load variables 
varReceiver = new LoadVars(); // create an object to store the variables 
varReceiver.load("http://playground.nsdesign6.net/percentage/external.php"); 
//load variables 



//function1 
varReceiver.onLoad = function() { 
//value is the var that is created. 
var paul = this.percentage; 
} 
//function1 


//function2 
this.onEnterFrame = function() {  
if(this._currentframe==(percentage)) { 
this.stop(); 
this.onEnterFrame = undefined; 
} 
} 
play(); 
//function2  

欢呼 保罗

回答

0

我认为这个问题是percentage不函数2的范围内定义。

尝试这样:

//function1 
varReceiver.onLoad = function() { 
//value is the var that is created. 
var _level0.paul = this.percentage; 
} 
//function1 

//function2 
this.onEnterFrame = function() {  
if(this._currentframe==paul) { 
this.stop(); 
this.onEnterFrame = undefined; 
} 
} 

另一个要注意的是,你已经通过你的onLoad函数被调用的时候一对夫妇帧,所以也许你应该以防万一paul是一个小数字,将函数2中的测试更改为if(this._currentframe>=paul)

+0

您好我试过你说什么,但它不工作,并与下面的错误出现: 场景=场景1,图层=图层1,帧= 1:第12行:';'预计var _level0.paul = this.percentage;场景=场景1,图层=第1层,帧= 1:第14行:出现意外的'}'遇到} – 2010-02-01 12:37:28

0
//load variables 
var paul; // <- !!! 
varReceiver = new LoadVars(); // create an object to store the variables 

varReceiver.onLoad = function() { 
//value is the var that is created. 
    paul = this.percentage; // <- !!! 
    play(); 
} 
//function1 


//function2 
this.onEnterFrame = function() {  
    if(this._currentframe==(paul)) { // <- !!! 
     this.stop(); 
     this.onEnterFrame = undefined; 
    } 
} 
//function2 

varReceiver.load("http://playground.nsdesign6.net/percentage/external.php"); 

或更好:

//load variables 
varReceiver = new LoadVars(); // create an object to store the variables 

varReceiver.onLoad = function() { // onLoad 
    if(this.percentage!=undefined){ // check if percentage exist 
     _root.onEnterFrame = function(){ // register event function 
     if(_currentframe == varRecivier.precentage) { // function body 
      _root.stop(); 
      _root.onEnterFrame = null; 
     } 
     play(); 
    }else{ // no variable "precentage" in loaded data 
     gotoAndPlay("error"); // loading error handling 
    } 
} 
相关问题