From the "How do I FAQ"
[quote:1q65lczx]
Navigation through layouts/levels (single event sheet) - LINK
Navigation through layout (with demo capx) - LINK
This is a basic idea.
In your case, you want the action of taking the pill to set a specific value for the "end variable" that determines what layout you are going to.
So in pseudo code:
Global Var EndLevel as number
On collision with Blue Pill => Set EndLevel value to 1 ; Destroy Red Pill and Blue Pill
On collision with Red Pill => Set EndLevel value to 2 ; Destroy Blue Pill and Red Pill
On end of level => Go to "Layout " & EndLevel
Considering your layouts are named "Layout 1"; "Layout 2", and so on.
This way, when picking a specific pill, you set a value to a variable that will be "directing" toward a specific layout when the actions of end level happen.
This is pseudo code (the actual logic supposed to happen), as the actual implementation depends a lot on what you actually already did in your project.
If you have issues with concrete implementation, do post your existing capx it will be easier to let your know directly what implementation is appropriate in regards to how you did things so far.