Hi,
the ArcGIS Viewer for Flex is based on the ArcGIS API for Flex. I don't see how your supposed to use the Viewer for Flex together with the JavaScript API.
When you download the Viewer for Flex the API for flex is included, you don't have to download the API separately, just set up the config file with your map services.
The Error you're getting "Invalid tile service" might be that your using type="tiled" on a mapservice that isn't cached. Try use type="dynamic" or make sure the mapservice is cached.