Recently-developed smart grids have a diverse range of load types that makes their energy scheduling different from conventional power systems. In this paper, an energy scheduling is proposed for smart grids to minimize operational cost and energy losses taking into account flexible (adjustable and shiftable) loads, which are used here as network resources. Special attention is paid to Electric Vehicles (EVs) as a sort of flexible loads. It is shown that the Vehicle-to-Grid (V2G) service may intensify power losses by charging and discharging EVs for multiple times and consequently, it is necessary to observe and optimize energy losses while using V2G. Range anxiety, which is one of main barriers to promote EVs, is formulated and optimized in order to address the concern of EV owners in depletion of battery energy and to encourage them to more actively participate in V2G service. Under the proposed scheme, EVs act as distributed energy storage systems to more employ renewables and also to make it possible to take the advantage of lower tariff electric energy from upstream networks. Results from examining the proposed method on a standard test system are presented and discussed.