mercredi 30 septembre 2015

AS3 bug (does not evaluate expressions/variables inside array)

I've stumbled onto yet another fatal Flash bug, which I barely nauseous enough to describe.

Storing things in array such as below is common. level_Data_Edible is an array containing strings. You access it to find out a string based on the current level. This has worked until suddenly, without reason.

static public var comboType_14:Array =



static public var level_Data_Edible:Array = [ null, "Fish", "Golfball", "Gloves", "Logger", "Burger", "Beer", "Snowshoes", "Smore", "Pontoon", "Binocular"];

You have to dynamically create the variable. Access it by [classname][match]. In this case ScoreKeep[match]

var match:String = "comboType_" + String(Constants.currentLevel);

Then, what's new and changed, is that now the result is always for currentLevel = 1. Even if currentLevel = 5 or 7.

Flash does not evaluate variables inside of arrays based on their current state. I don't know what it does, but this works fine in dozens of other areas of the game. For some malicious reason, not here.

Amazingly, I can't even engineer a workaround. I've tried putting a function in the array that returns the string for the currentLevel, and instead of the string it returns "Function() function" or some nonsense.

I even tried converting the array into a vector, duplicating the array, copying the string values to another array, no matter WHAT I do, Flash figures out a way to stop me. It's really, truly something else. Inhuman, malicious.

Aucun commentaire:

Enregistrer un commentaire