如何在JS中转换此AS代码?

时间:2014-11-18 18:37:03

标签: javascript actionscript-3

大家好我有这个AS代码,我想在JS中有任何机会不用编写整个代码就可以了。我知道这些代码非常相似,但我不知道应该将其改为JavaScript

/ LOCATIONAL
var locationDefinesStandard:Boolean = true
if(slideFrame.beachCheckBox.currentFrame == 2) locationDefinesStandard = false;
if(slideFrame.parkCheckBox.currentFrame == 2) locationDefinesStandard = false;
if(slideFrame.mountainCheckBox.currentFrame == 2) locationDefinesStandard = false;
// standard, mpw, trekking
   var suggestedCar:String;
// DAD
if(parent_Gender == 'Daddy'){
if(number_Kids < 3){
suggestedCar = 'trekking'
}else{
suggestedCar = 'mpw'
}
// MUM
}else {
if(number_Kids > 2){
suggestedCar = 'mpw'
}else{
if(locationDefinesStandard == true){
if(live_location == 'Rural'){
suggestedCar = 'trekking'
}else{
suggestedCar = 'standard'
}
}else{
suggestedCar = 'trekking'
}
}
}
//show result
if(suggestedCar == 'trekking') trekkingFrame.visible = true;
if(suggestedCar == 'standard') largeFrame.visible = true;
if(suggestedCar == 'mpw') mpwFrame.visible = true;

1 个答案:

答案 0 :(得分:0)

语法几乎相同。你应该只需要改变这些

var suggestedCar: String;
var locationDefinesStandard: Boolean = true

到这些

<击> var suggestedCar = '';

var suggestedCar = null;
var locationDefinesStandard = true;

然而,引用了大量其他对象,我怀疑无缝地工作。但是对于这个片段,这就是你需要的所有JS。