android - version request fail error by versions dots? -
i'm trying create version query in as3.
search current version works fine
var appxml1:xml = nativeapplication.nativeapplication.applicationdescriptor; var ns1:namespace = appxml1.namespace(); var current1:string = appxml1.ns1::versionnumber[0];
online search new version works fine
var apploader:urlloader = new urlloader(); var apprequest:urlrequest = new urlrequest("http://xxx/app/version/app.xml"); apprequest.method = urlrequestmethod.post; apploader.load(apprequest); var xml:xml = xml(apploader.data);
i fail @ if statement
if (xml.version > current1) { gotoandstop(3); }
current version 2.0.0
new online version 2.0.1
code in frame 2, when testing movie not stop in frame 3 remains on frame 2
i suspect error dots in version number. possible? how solve problem.
thank (sorry bad english)
i wrote utility function, simple, test versions. compare versions, , result can 1
- if version1 greater version2, 0
- version1 , version2 equal, -1
- version 1 lower version2
private function compareversions(version1:string, version2:string):int { var v1:array = version1.split("."), v2:array = version2.split("."); var i:uint, len:uint = v1.length; (i; < len; ++i) { if (v1[i] > v2[i]) { return 1; } else if (v1[i] < v2[i]) { return -1 } } return 0; }
how use:
var currentversion: string = "2.0.1"; var lastversion: string = "2.0.0"; if(compareversions(currentversion, lastversion) > 0){ trace("current version greater! yes!"); }
Comments
Post a Comment