Not just an inanimate object - an idea that that object is meant to represent! We're about one level of abstraction away from the pledge of allegiance becoming a meaningless mantra of words with no meaning or relation to one another strung together to make a pretty song that is always sung off-key by grade school children.
I mean bag on the pledge of allegiance all you like, but using the flag as a synecdoche of the nation as a whole doesn't seem like it is as great a leap of logic as you are making it out to be.