This content has been marked as final. Show 9 replies
You need to see if you can determine a pattern in the repetitious stuff that you can convert to a more automated computation. In your if(_global.roomslide.... statements I see this pattern...
scrollFace._x = initPosition+(unitWidth*2*(_global.roomslide-1));
contentMain._x = initContentPos-(unitContent*(_global.roomslide-1));
So that would reduce that entire set of if statements to two lines of code. I haven't looked at the first set, but you should try to see if you can find a pattern there.
That's absolutely brilliant, thank you! I'm now developing the design further, and adding a gotoAndPlay to each of the original if statements as follows:
scrollFace._x = initPosition;
contentMain._x = initContentPos;
scrollFace._x = initPosition+(unitWidth*2);
contentMain._x = initContentPos-unitContent;
Can i make this line more generic to follow the same pattern you suggested,
Maybe this should be gotoAndPlay("room"_global.roomslide) ??
I'm gonna assume that _global.roomslide is the right value to use. The correct way to code the gotoAndPlay would be...
Actually, the more correct way would be:
var destination:String = "room"+String(_global.roomslide);
I figure it's better to show the all the pieces than the shortcuts... helps you to see the parts involved.
Briliant, thank you very much for your help! It's helped me reduce the amount of coding, and shown me a few new tricks!
I don't expect there's any way to reduce the amount of coding for the first part, as far as I can see, so I think that's it all sorted!
Is this reverse psychology of some sort? A challenge to me to attack the first pile of stuff too? I'll take a look at it and let you know if I find a way, but I may not tell you what it is if I do. That'd be cheating you of an opportunity to solve a puzzle on your own.
Yep, I can reduce that first batch to the form shown below... though the end points that it deals with may or may not play out. You'll know better than me if you can solve what's in the if(...) line... But if they don't you could still put conditionals on the value of i within the loop to handle them.
I actually hadn't expected a solution, but thanks to your suggestion I came up with the attached code which works perfectly! Thanks so much for your help!
You got it! and you're welcome.