2013-03-08 76 views
0

所以我有一个使用Adobe导演制作的测验,但我正在为整体环境而苦苦挣扎。Adob​​e Director - Lingo测验

我加入以下的Lingo脚本,每个按钮与一个正确的答案:

on mouseDown 
    global gscore 
    set gscore = gscore + 1 

并在最后阶段,我用下面的Lingo脚本来检查获得的点数,并显示相应的精灵为结果。

on enterFrame 
    if gscore = 0 then set the memberNum of sprite (3) to 154 
end if 
    if gscore = 1 then set the memberNum of sprite (3) to 155 
end if 
    if gscore = 2 then set the memberNum of sprite (3) to 156 
end if 
    if gscore = 3 then set the memberNum of sprite (3) to 157 
end if 
    if gscore = 4 then set the memberNum of sprite (3) to 158 
end if 
    if gscore = 5 then set the memberNum of sprite (3) to 159 
end if 
end 

所以我的错误似乎说没有声明的变量,但它是全球性的权利?那么它怎么会不认识它。第一个脚本附加到对应于正确答案的按钮上,每个按钮都有一个单独的脚本将其发送到下一个问题。用于显示结果的最后阶段应显示一个取决于gscore值的特定自定义精灵。

回答

0

想通了,appologies。

我删除了所有的结束,如果使它成为一个完整的if语句。在第一个使用的脚本中设置全局变量,声明该值为0.然后在增加时将其添加到先前定义的具有相同名称的全局变量中。

我相信我的问题在于全局变量实例默认值为void。

1

很高兴你想出了一个解决方案。另一种方法是根本不使用if语句。你enterFrame事件脚本可能已经阅读这样的:

上enterFrame事件 精灵(3).memberNum = 154 + gscore 结束

0
on exitframe me 
    global gscore 

if gscore = 0 
    set the memberNum of sprite (3) to 154 
else if gscore = 1 then 
    set the memberNum of sprite (3) to 155 
else if gscore = 2 then 
    set the memberNum of sprite (3) to 156 
else if gscore = 3 then 
    set the memberNum of sprite (3) to 157 
else if gscore = 4 then 
    set the memberNum of sprite (3) to 158 
else if gscore = 5 then 
    set the memberNum of sprite (3) to 159 
end if 

end