PDA

Volledige versie bekijken : Al mijn code in 1 frame plaatsen.


Crypt36
%Europe/Berlin %316 %2009, 08:35
Ik heb een geprogrammeerde animatie die loopt over 18 frames met daarin 4 keyframes. Deze animatie bestaat uit 4 plaatjes die elk weer onderverdeeld zijn in 16 kleinere MC's. Mijn probleem is nu dat ik op elke keyframe van de hoofdanimatie mijn hele code weer moet herhalen om de boel te laten werken en ik zou liever alles gewoon op de eerste keyframe hebben?! Hier een voorbeeld hoe het werkt voor de 3 van de 16 kleinere MC's.

In de eerste keyframe:

xicehndr;
xiceoarmr;
xicechest;
onEnterFrame = function() {

if (xhandvisible == 1){
icehndr._visible=false;
icehndr2._visible=false;
icehndr3._visible=false;
icehndr4._visible=false;
}
icehndr.gotoAndStop(1);
icehndr2.gotoAndStop(1);
icehndr3.gotoAndStop(1);
icehndr4.gotoAndStop(1);

iceoarmr1.gotoAndStop(1);
iceoarmr2.gotoAndStop(1);
iceoarmr3.gotoAndStop(1);
iceoarmr4.gotoAndStop(1);

icechest1.gotoAndStop(1);
icechest2.gotoAndStop(1);
icechest3.gotoAndStop(1);
icechest4.gotoAndStop(1);

if (xicehndr == 1) {
icehndr.gotoAndStop(2);
icehndr2.gotoAndStop(2);
icehndr3.gotoAndStop(2);
icehndr4.gotoAndStop(2);
}
if (xiceoarmr == 1) {
iceoarmr1.gotoAndStop(2);
iceoarmr2.gotoAndStop(2);
iceoarmr3.gotoAndStop(2);
iceoarmr4.gotoAndStop(2);
}
if (xicechest == 1) {
icechest1.gotoAndStop(2);
icechest2.gotoAndStop(2);
icechest3.gotoAndStop(2);
icechest4.gotoAndStop(2);
}
}

icehndr.onPress = function(){
xicehndr = 1;
}
iceoarmr1.onPress = function(){
xiceoarmr = 1;
}
icechest1.onPress = function(){
xicechest = 1;
}

En op de tweede keyframe:


xicehndr;
xiceoarmr;
xicechest;
onEnterFrame = function() {

if (xhandvisible == 1){
icehndr._visible=false;
icehndr2._visible=false;
icehndr3._visible=false;
icehndr4._visible=false;
}
icehndr.gotoAndStop(1);
icehndr2.gotoAndStop(1);
icehndr3.gotoAndStop(1);
icehndr4.gotoAndStop(1);

iceoarmr1.gotoAndStop(1);
iceoarmr2.gotoAndStop(1);
iceoarmr3.gotoAndStop(1);
iceoarmr4.gotoAndStop(1);

icechest1.gotoAndStop(1);
icechest2.gotoAndStop(1);
icechest3.gotoAndStop(1);
icechest4.gotoAndStop(1);

if (xicehndr == 1) {
icehndr.gotoAndStop(2);
icehndr2.gotoAndStop(2);
icehndr3.gotoAndStop(2);
icehndr4.gotoAndStop(2);
}
if (xiceoarmr == 1) {
iceoarmr1.gotoAndStop(2);
iceoarmr2.gotoAndStop(2);
iceoarmr3.gotoAndStop(2);
iceoarmr4.gotoAndStop(2);
}
if (xicechest == 1) {
icechest1.gotoAndStop(2);
icechest2.gotoAndStop(2);
icechest3.gotoAndStop(2);
icechest4.gotoAndStop(2);
}
}

icehndr2.onPress = function(){
xicehndr = 1;
}
iceoarmr2.onPress = function(){
xiceoarmr = 1;
}
icechest2.onPress = function(){
xicechest = 1;
}

Is er een mogelijkheid dit aan te passen zodat het gewoon allemaal werkt vanuit de eerste keyframe? Als ik andere stukjes code wil toevoegen verder in de tijdslijn moet ik weer keyframes toevoegen en weer alles herhalen en dit wordt een zootje. Heb ik een keuze?

En dan de 2de vraag:
ik wil aan een MC een actie toevoegen vanuit mijn maintimeline dus zoiets als dit:

MC1.removeMovieClip(this._parent);

Alleen wil ik dat dit pas op keyframe met naam 3 gebeurd, hoe schrijf je dat?

Midas
%Europe/Berlin %383 %2009, 10:11
Doe het dan op deze manier:



Een aparte layer (hieronder 'as') voor je main code. En laat die volledig doorlopen met frames.
Een aparte layer voor de kleine dingen die je wil laten gebeuren per frame ('as2').
Een layer voor je prenten.


http://www.flashfocus.nl/forum/attachment.php?attachmentid=8777

Crypt36
%Europe/Berlin %464 %2009, 12:09
Ik heb een aparte layer voor de code.

Op elke keyframe staat een nieuwe mc, daarom herhaal ik de code ter hoogte van elke nieuwe mc anders werkt de boel niet, ik snap eigenlijk niet waarom. Als ik alle OnPress functies samen schrijf in de eerste frame en de layer zonder keyframe over de gehele MC lijn laat lopen werkt alleen de OnPress op de eerste MC op dezelfde hoogte als de code en niet op de andere 3 verderop.

Jan
%Europe/Berlin %471 %2009, 12:19
Als ik alle OnPress functies samen schrijf in de eerste frame en de layer zonder keyframe over de gehele MC lijn laat lopen werkt alleen de OnPress op de eerste MC op dezelfde hoogte als de code en niet op de andere 3 verderop.
Lees hier voor uitleg en oplossingen:
http://www.flashfocus.nl/forum/showpost.php?p=359490&postcount=5

Groeten;
Jan

Crypt36
%Europe/Berlin %481 %2009, 12:33
Bedankt Jan, ik denk dat het idd niet anders had gekund in mijn game.