Up to my Flash shenanigans again. haaallllppp!
- Started
- Last post
- 7 Responses
- CygnusZero4
Well I have to create a prize wheel before and it turned out great. Now I have an unrelated Flash project. Its funny that Flash is basically dead but it's still really useful for things at events.
I have to create a scoreboard, with 10 fields for names, and 10 fields for scores. When you enter the scores for each person, the Flash needs to rearrange them to be in the correct order.
Sounds super complicated to me, and I cant even find much on how to do this, so if anyone can point me in a good direction it would be much appreciated. I found this, which seemed to really be heading in the right direction, except that the part after this vid isnt posted on his page, and he doesnt even provide the php file that he references. smh
- CygnusZero4-1
*had to create a prize wheel. that project is done now. this is a different project.
- feel1
arrays can be sorted by crescent or decrescent values, maybe that's a approach you can take
or you can check every time a score is updated and sort them vertically
idk, it's been a long time since I've coded in flash, or anything else for that matter
- monNom0
Off the top of my head: keep an array of scores on the root. Better yet, an array of objects so you keep the player name associated with the score.
Make each player/score as a movieclip and add an action on that movieclip to continually set its y postion to its height * its order. Have it poll the root for it's position within the array and move itself accordingly.
Then on the root, every time a score updates, do a sort() on your array to get the new order.
- fyoucher10
Yep, arrays and objects. Create an object, give it a score property, sort by score property. Create new array based on sort method (highest score). Specifically, use sortOn() method to sort by highest score. Then rearrange by new array order.
- CygnusZero40
Man this is going to be tough for me to figure out. I'm not an expert AS guy. I guess I'll just start by looking to arrays and see how they work. Never did anything like this before.
- ORAZAL1
var users:Array = new Array();
users.push(new User("i", 10));
users.push(new User("yurimon", -50));
users.push(new User("cygnus", 4));trace(users);
// i:10, yurimon:-50, cygnus:4users.sortOn("name");
trace(users);
// cygnus:4, i:10, yurimon:-50users.sortOn("upvotes", Array.NUMERIC | Array.DESCENDING);
trace(users);
// i:10, cygnus:4, yurimon:-50class User{
public var name:String;
public var upvotes:Number;public function User(name:String, upvotes:Number) {
this.name = name;
this.upvotes = upvotes;
}public function toString():String {
return " " + name + ":" + price;
}
}- Translated from:
http://help.adobe.co…ORAZAL - lol yurimon -50...fyoucher1
- Translated from:
- CygnusZero40
^ Is that as2 or 3? When I paste it into an as2 file, and publish it, I dont see anything.
- Scene=Scene 1, layer=Layer 1, frame=1, Line 17 Classes may only be defined in external ActionScript 2.0 class scripts.CygnusZero4
- also getting that errorCygnusZero4
- It's AS3. Just an example on sorting arrays. I don't have Flash installed, otherwise I would have something. Sorry.ORAZAL
- No problem. I wouldnt know how to implement something like that. I'll keep looking around.CygnusZero4