Could a speed sensor connection just be loose causing a trac light flash plus check engine code?

no, trac lights have to do with traction control, this is part of the A.B.S system, what are the codes that are stored, you could check the connector for corrosion or loosness but I need more info to help.