Oshii
January 10th, 2008, 06:00 AM
Hello,
Hope this post doesn't feel too long for you guys to read. Ill try to keep it short, Ill describe the problem in the first paragraph below. I've attached my files with code.
Im trying to create a custom made accoridion menu. I thought I had it all working they way I wanted, but noticed one bug. When the menu-blocks slide up and down they don't return to the exact same position. Its not noticable at first, but the offset grows if you play around with the accoridion for a while.
The accordion is several boxes (mc: box, in the library), where each box knows of the box below it. When the box slides down it also moves the box below it which creates and accoridon effect. The mc: box, has a linkage to the file Box.as. The file: accordion.fla has actionsscript code on the first frame in the top layer named "actions", all the rest of the code is placed in the Box.as file.
I guess I know why the box positions become desynched, but Im not sure how to solve it. The problem (if I'm thinking correct here) is that the easing function never reaches the exact target position, so when its almost there it stops and the mask is moved the remaining distance but the box/boxes below which moves together with the mask stops where the mask left of. Since the mask and the boxes are located within different movieclips their y-positions aren't the same, so I have to calculate the differnce. Maybe Im just stuck in my old way of thinking but I just cant figure out a good way to solve it.
Ive tried different methods:
- to calculate the difference between where the mask is stopped and where it is placed afterwards.
- to round of the final y-position-value, because its always at a decimal of a pixel.
- to keep track of the parent box and place it just below the parent box's position, with an offset of the content width if the parentbox is expanded.
- to keep track of the starting position of each box, and then adjusting it to the starting position everytime it stops. If any of the above boxes are slid down though, there is an offset to the starting position, which I will also have to keep track of.
The second two approaches, which may have failed because of myself introducing bugs in the code, but they seem a bit far fetched imo, I have the feeling there is both an easier and better solution to it?
Any ideas are appreciated. Thanks!
Hope this post doesn't feel too long for you guys to read. Ill try to keep it short, Ill describe the problem in the first paragraph below. I've attached my files with code.
Im trying to create a custom made accoridion menu. I thought I had it all working they way I wanted, but noticed one bug. When the menu-blocks slide up and down they don't return to the exact same position. Its not noticable at first, but the offset grows if you play around with the accoridion for a while.
The accordion is several boxes (mc: box, in the library), where each box knows of the box below it. When the box slides down it also moves the box below it which creates and accoridon effect. The mc: box, has a linkage to the file Box.as. The file: accordion.fla has actionsscript code on the first frame in the top layer named "actions", all the rest of the code is placed in the Box.as file.
I guess I know why the box positions become desynched, but Im not sure how to solve it. The problem (if I'm thinking correct here) is that the easing function never reaches the exact target position, so when its almost there it stops and the mask is moved the remaining distance but the box/boxes below which moves together with the mask stops where the mask left of. Since the mask and the boxes are located within different movieclips their y-positions aren't the same, so I have to calculate the differnce. Maybe Im just stuck in my old way of thinking but I just cant figure out a good way to solve it.
Ive tried different methods:
- to calculate the difference between where the mask is stopped and where it is placed afterwards.
- to round of the final y-position-value, because its always at a decimal of a pixel.
- to keep track of the parent box and place it just below the parent box's position, with an offset of the content width if the parentbox is expanded.
- to keep track of the starting position of each box, and then adjusting it to the starting position everytime it stops. If any of the above boxes are slid down though, there is an offset to the starting position, which I will also have to keep track of.
The second two approaches, which may have failed because of myself introducing bugs in the code, but they seem a bit far fetched imo, I have the feeling there is both an easier and better solution to it?
Any ideas are appreciated. Thanks!