A model for the solar coronal magnetic field is proposed where multiple directed loops evolve in space and time. Loops injected at small scales are anchored by footpoints of opposite polarity moving randomly on a surface. Nearby footpoints of the same polarity aggregate, and loops can reconnect when they collide. This may trigger a cascade of further reconnection, representing a solar flare. Numerical simulations show that a power law distribution of flare energies emerges, associated with a scale-free network of loops, indicating self-organized criticality.