tyler_eli Wrote:Oh man, it's been ages since I last wrote any programming codes. I'm not sure, but the problem might not even be in that copypaste section you made; you're using a dynamic object (obj), and it has an array Strings, and each of those strings have their own properties that change throughout the whole game, so it's understandable that somewhere in your huge game code something else could have changed it.
No, no, obj is already initialized with this object. I tested it. The code works because the icons become clickable. This is due to onRelease() in each of them.
I will put the main code areas (the function itself). The real problem is with the line with _root.Achievements[f]!
- Code: Select All Code
//PEACH ART/ACHIEVEMENT ARRAY of OBJECTS
_root.Achievements=new Array(); //its not in the same MC, its loaded in scene1, right when game starts (variable loading AS file). It executes once.
...
function achievement_load(obj){
obj.i=(_root.Achievements.length)-1;
f=0;
while (f<=obj.i) { //it should enter 2 times: f=0 and f=1
if (_root.Achievements[f].substring(0,10)=="Screen_art") { //it will search for that pattern, because I have Screen_endings, Screen_medals.... I only want Screen_art !
obj["a"+(f+1)].head.forceChar="Peach";
obj["a"+(f+1)].onRelease=function(){
_root.Level.controlList._instance=_root.Achievements[f]; // THIS IS THE PROBLEM!
_root.Level.controlList.gotoAndStop("art");
}
}
f++;
}
}
So, above, the problem is with: _root.Level.controlList._instance=_root.Achievements[f];
All buttons are clickable and they DO go to "art" label in controlList,
but '_root.Level.controlList._instance' somehow is bugged out! Its like their value is now mangled!F really gets updated (in the WHILE above). I also tried using FOR (to optimize the code more, removing the f++ line), but the same error occurs.
The correct must be:
Achievements[0]="Screen_art_Larry"; //because I've seen him first.
Achievements[1]="Screen_art_Morton"; //Now Peach fucked him in World2.
Then I tried to create a local variable. obj.AchiItem:
- Code: Select All Code
//PEACH ART/ACHIEVEMENT ARRAY of OBJECTS
_root.Achievements=new Array(); //its not in the same MC, its loaded in scene1, right when game starts (variable loading AS file). It executes once.
...
function achievement_load(obj){
obj.i=(_root.Achievements.length)-1;
f=0;
while (f<=obj.i) { //it should enter 2 times: f=0 and f=1
obj.AchiItem=_root.Achievements[f];
if (obj.AchiItem.substring(0,10)=="Screen_art") { //it will search for that pattern, because I have Screen_endings, Screen_medals.... I only want Screen_art !
obj["a"+(f+1)].head.forceChar="Peach";
obj["a"+(f+1)].onRelease=function(){
_root.Level.controlList._instance=obj.AchiItem; // DOESNT WORK!
_root.Level.controlList.gotoAndStop("art");
}
}
f++;
} //while
}
When we have ONE item in the _root.Achievements array (only Achievements[0]), ONE icon is shown in the achievements, and its clickable. You click on it. The screen art is shown. GREAT.
BUT!
When we have TWO items in the _root.Achievements array ([Achievements[0],Achievements[1]), the first one is being populated with the SECOND "Screen_Art" that you have unlocked. So BOTH becomes with "Screen_Art_Morton"! tyler_eli Wrote:On the other hand, achievements are -very basically- static booleans values (i.e. they do NOT change throughout the game. They will only change once, you either did the achievement (value=true) or you didn't finish it yet (value=false). Can't you just make an extra static value (ex: a boolean array, let's call it "crap[]") and add one line of code at each boss sex scene? like (ex:
- Code: Select All Code
FunctionthatwillstartLarryfirstsexsceneloop(){
crap[0] = true; // crap[0] corresponds to "Larry Sex" medal achievement, it will not change throughout the game
~~~~ the rest of your normal code
The problem is that I like to retain more 'verbosity', so I avoid so simple boolean items. If not, I'll have to map them somewhere(comments), like:
- Code: Select All Code
crap[x];
//x=0: Morton Art.
//x=1: Larry Art.
//x=2: All goombas fucked - medal.
//x=3: All toads fucked - medal.
//x=4: Wendy art.
(it will end up mixed up because I am adding features over time).
So, as I work with REGEX all the time in my work, its easy for me to work with them.
But AS2 doesnt like it.
tyler_eli Wrote:When you will need to award a medal, get your value directly from crap (the array! \(`O´ )/), not from the dynamic obj. It sounds weird, but it helped me -sometimes- in these situations and it's much easier than checking the entire game code for the mistake/logic error.
Please trust me, I dont use a dynamic array. 'obj' above is just a way I call the function (achievement_unlock) inside a given Movie Clip. So it will create variables and do work inside that Movie Clip. It really works (because the buttons appear in, with their clicks).