Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




[F8] Arrays: Find The Highest Score AND Tell Me Whose It Was?



I have an array with 5 numbers in it. I need to find the highest number, I can do that part. But I also need to be able to tell whose value that belongs to. Can anyone give me a nudge?

For example:


Code:
FavoriteMeat = Ham, Turkey, Chicken, Bologna, Squirrel
15 25 30 35 115


So I can figure out that the highest number is 115, but I can't figure out how, using a regular array, to show that it's squirrel that equals 115. Especially since array value is [4].

I can't use an associative array.

Please, please, please help!



FlashKit > Flash Help > Flash ActionScript
Posted on: 11-01-2006, 11:49 AM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

List For The Highest Score
i first time come to here, can you tell me how to make a list for the highest mark.

Player Scores, Listing The Highest Score From Top To Bottom (like Leaderboard)
Basically, I have brain frog this morning, and can't sit down and figure this out by myself,

So i'd appreciate it if someone could tell me how to
Make a leaderboard, in a nutshell

100 players,
and I need to list the ones with the highest score at the top, (1st, 2nd, 3rd, so on)

and if 2 have the same score, just sort them by there player number...

using a "for var i:Number = 0; i<100; i++)" statement, i would be the player number...

Any unclarity i'll try and reword

Basically highest score's at the top, 2nd, is at the 2nd spot, 3rd, 3rd spot, so on

the variable im using to score is

playerPoints, and its an array...


Thanks in advance

Is There A Way To Find The Next Highest Level?
The subject basically says the question. I had a controller movie that loads a right side or a left side, and when u click on a button from one of the sides, it loads another movie. Is there a dynamic way to define the next available level? or do i have to keep track manually? thanks.

---
also out of curiousity, can you delete a level? other than loading a blank.swf?

How To Find The Highest Number?
Hi,

Does anyone know a command to find the higher number from a list of numbers?

Thanks,
Rik

Find Highest Value In An Array
Can anyone tell me if there is a way to find the highest number in an array?

numbersArr(314,2613,221,103,77);

is there a way to loop though this, compare all the numbers to each other and find the highest value while keeping the array in order?

Thank you

Finding Highest Values In Arrays
Can anyone help me please?

I have a little nugget of code that finds the highest value in an array. The code works fine when placed in an empty .fla file.

When I embed it into the code I am working on, it just stops responding. Can anyone help me out please.

Thank You,
Tim.



Code:
if (not start) {
// load variables
loadVariables("sampledataset2.txt",_root);
start = true;
trace ("started");
}
// check variables are loaded
if (xyLoaded == "true") {
trace ("loaded");

////////////////////////////////////////////
//This is the nuget of code. try it in an empty .fla and it
//works fine. Here though it doesn't respond
////////////////////////////////////////////
sampleArray = new Array(1,2,3);
arrayHighest = new Array();
//
function highest(array) {
trace ("array: "+array);
var arrayLength = array.length;
var highestNumber = 0;
for (j=0; j<arrayLength; j++) {
if (Number(array[j])>highestNumber) {
highestNumber = array[j];
}
}
arrayHighest.push(highestNumber);
}
//
highest(sampleArray);
trace ("arrayHighest: "+arrayHighest);
//////////End of nugget/////////////////////

play ();
}else{
gotoAndPlay(_currentframe-1);
}

P.S.
The main code has been cropped a bit so I don't post too much, it normaly sits on frame two of a three frame .fla
I have included a "sampleArray" with values of 1,2 and 3. This is just to test the highest() function.

[CS3] Find Highest Point And Farthest Point Of A Parabola
Hi Guys, I've been using for forum extensively over the past few weeks and have found almost everything I needed until now...

I'm moving a ball using something similar to the following code:


Code:
var spx:Number = 3;
var spy:Number = 7;
var g:Number = 0.1;
var bmove:Boolean = true;

onEnterFrame = function() {
if (bmove) {
move_ball();
}
stop_ball();
}

function stop_ball() {
if (ball._y > 350) {
bmove = false;
}
}

function move_ball() {
spy = spy-g;
ball._x += spx;
ball._y -= spy-g;
}
Is there a way to find the maximum height and farthest point of the parabola it describes? I want to display a path guide using curveTo which shows the route of the ball.

Thanks.

Find Highest Point And Farthest Point Of A Parabola
Hi Guys, I've been using for forum extensively over the past few weeks and have found almost everything I needed until now...

I'm moving a ball using something similar to the following code:


Code:
var spx:Number = 3;
var spy:Number = 7;
var g:Number = 0.1;
var bmove:Boolean = true;

onEnterFrame = function() {
if (bmove) {
move_ball();
}
stop_ball();
}

function stop_ball() {
if (ball._y > 350) {
bmove = false;
}
}

function move_ball() {
spy = spy-g;
ball._x += spx;
ball._y -= spy-g;
}
Is there a way to find the maximum height and farthest point of the parabola it describes? I want to display a path guide using curveTo which shows the route of the ball.

Thanks.

Quiz -- Arrays -- Random -- Score -- Help
I've got a main swf that has 11 frames.
I've got an array that has a list of 18 possible swf's to be loaded externally.
I've got another array that holds 9 of the 18 swf's chosen at random.
As the user advances from frame to frame, the external swf is loaded into the main swf based on it's position in the random array. giving a totally unique experience each time the quiz is taken.

This all works great! Here's where I'm having trouble... each external swf has a list of 5 answers, each with a point value. How can I keep a running total of the point value in the main swf, keeping in mind that a user may want to click back to change their answer? I'm guessing I create another array for the answers and add them up for a running total. However, I can't see how to do this, when the files are loaded in a random order.

I hope I make sense... I appreciate any ideas/help.

-B

Keeping A Bowling Score (Using Arrays/ Functions)
Hello,
I'm new to the array and function features of Actionscript. When using them in Java or C++ I know how to use them, but I am not quite sure.

Could someone give me a brief little coding on how to use arrays to make 21 variables for each of the 21 balls that you roll, and then be able to work out the score?

Right now I have been working with variables
_root.f11 (means that frame 1 bowl 1)
so _root.f22 (means that Frame 2 bowl 2)

If you could help me out, I would really appreciate it, you could check out the game at: http://brady.8m.net/bowling.htm

It is done except for the scoring (the most important part).
My bro says that it would be really easy if I could incorporate arrays and functions into keeping the score rather than just typing up each frame individually.

I'd like to see this work out, and I'd gladly appreciate any help.

Thanks,
-Brady White

Setting Variable Score = Score + 1 Justs Adds Another Digit With 1
I am trying to work on how to add 1 each time to a text. I used the variable name score and a button has this command :
(on pressing the button) score = score + 1

It changes the text of score but each time you click it, it adds a new digit. this is the example of the first four times.

0 01 011 0111

Can anyone help me? My goal is to make it become

0 1 2 3 and so on.

Thank you

Save Score And Put In Array To Pull Up All Score Later
Can you help please. I am new to this.
I have a list of people who answer 3 questions on 5 different topics. I can total their scores on the topic individually.
How do I total the first topic and show them and save their answers and go to the next topic and show their answers and next and so on and then get all the questions they answered for each of the 5 topics and their final score?

with thanks

Best Way To Add A Score To A Score Box And Total It Up.
I am creating a game for children to make good food choices for breakfast, lunch, dinner, and snacks. I need to have the food choice add a value to a score box when clicked onto the plate and subtract the same amount when clicked off. So far, all I have been able to do is get the score to appear in the upper left hand corner. When I can get the pancakes working properly, I will be adding other foods which will do the same thing with different numbers. The total score cannot go over 100. I am attaching the .as code, but it is separate from the .fla and I'm not sure if I can upload the .fla here.







Attach Code

package
{
//import any class being used by this package
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.events.MouseEvent;

public class MealGame extends MovieClip
{

//altered version
var pancakes1:Pancakes;
var offPlate:Boolean; //variable for food off the plate
var gameScore:int = 0;

public function MealGame()
{
//Create a score field for the pancakes.
var gameScoreField:TextField = new TextField();
//Show the score field
addChild(gameScoreField);
var tf:TextFormat = new TextFormat();

//Create a new instance of the Pancake class.
var pancakes1:Pancakes = new Pancakes();
//Display the pancakes on this stage.
this.addChild(pancakes1);

//Position the food item.
pancakes1.x = 11;
pancakes1.y = 42;
offPlate = true;

//make the food item a button
pancakes1.buttonMode = true;
pancakes1.addEventListener(MouseEvent.CLICK, onClick);

//toggle the food item to put on plate or off the plate
//toggle adding to the score or removing from the score
function onClick(event:MouseEvent):void
{
if(offPlate)
{
pancakes1.x = 119;
pancakes1.y = 380;
//add to score
gameScore = gameScore + 50;
gameScoreField.text = " " + String(gameScore);
tf.font = "Arial";
tf.bold = true;
tf.color = 0x000000;
tf.size = 22;
//tf.x = 426;
//tf.y = 530;

//Take this text formatting object; apply it to the textfield
gameScoreField.setTextFormat(tf);

//toggle the offPlate value
offPlate = !offPlate;
}
else
{
pancakes1.x = 11;
pancakes1.y = 42;
//remove from score
gameScore = gameScore - 50;
gameScoreField.text = " " + String(gameScore);
tf.font = "Arial";
tf.bold = true;
tf.color = 0x000000;
tf.size = 22;
//tf.x = 426;
//tf.y = 530;

//Take this text formatting object; apply it to the textfield
gameScoreField.setTextFormat(tf);
offPlate = !offPlate;
}
}
}
}
}

The Highest Var
does anyone know how to detect the highest number of some variables for example:

myvar1=10;
myvar2=11
myvar3=7;
myvar4=11;
myvar5=12;

the highest number is the one done by myvar5
but how to write the code to detect it???

Getting Highest Value
I have 3 movieclips and inside them loads external txt.files .
To MovieClip number one loads 1.txt, to number two loads 2.txt and to number three loads file 3.txt.

Allright everything works, but...
...what if I wantet to load the txt-file that has the highest number to the first movieclip example 65.txt, and to number two the 64.txt, and to movieclip 3 txt-file 63. And when there is txt-file called 66 in the folder it loads to movieclip one, and 65 loads to movieclip 2 etc... I think everybody gets the point.

Is it possible, that Flash look up the txt file that has the highest value?

Thanks

Which Variable Is The Highest
I've got yet another problem...(if any of you were readin my posts in the official Macromedia Flash forum)...

How to get the Flash Player to work out which variable (of a set of 11) has the highest numerical value.

Tnx
W3bdevil

Getting Highest Value From The Array?
Let's imagine that I have the array with five numeric values: "10, 5, 2, 13, 9". How is it possible to get the highest value from that array? (The value "13", of course...) ...and the order of those values should remain "unsorted"! (...meaning that value "10" should remain the first value and so on...)

Any hints...? Some mathemathic "tricks"? I would need this highest value to compare it with another value not located in any array ...and for example to see if those two values are equal or not. Solving this would help me a lot in one actionscript-filled Flash-project.

Highest Level
Is there a way to load external swf's on the highest empty level available?

I've got 13 different buttons wich load 13 different swf's. The latest pressed button should load the swf on top of the already loaded. Each loaded swf can be closed at any time (I work in Flash 5).

At the moment I don't have a clue how to script this one and where to implement it; in the scripting of the button or in the swf.

Thanx already!

Highest Value Method(s)
I'm creating a series of dynamic textfields with varying heights using autoSize.
Has anybody got suggestions as to how I can best return a value as to the _height value of the highest textfield?

I was thinking of using an array, but I'm unfamiliar with creating a dynamic one.

Highest Of Four Variables
Hello. I'm trying to get flash to print the highest of four variables, I've tried Math.max(w, x, y, z), but it doesn't seem to handle more than two variables. Suggestions?

The Highest Number
Hi
I have what I thought would be a very simple problem. I have questions that the user clicks on and then they get an answer based on the question clicked on the most. I have created variables showing how many times each question is clicked on. ( there are only 3 questions) How do I script it so it goes to the highest number. It was simple enough with one question because I could just say
if (on (release) {
_root.totalB = _root.totalB+1;

if (_root.totalB>_root.totalA) {
gotoAndPlay("B");}

else {gotoAndPlay("A");
}
}
But once it becomes more than than 2 I need to know how to script it to basically say go to the highest number (variable)
Any ideas?
Thanks
Ella

Highest Depth
I have a button that calls one of my photos but everytime the photo comes the photo hides my button what is the action to keep my button at layer 2 or something like that

Highest Variable
I need some help with some code that will determine what the highest number out of four variables are. (Don't worry about when it happens). The four variables/scores are:

_root.PlayerOne.PlayerOneScore
_root.PlayerTwo.PlayerTwoScore
_root.PlayerThree.PlayerThreeScore
_root.PlayerFour.PlayerFourScore

So, when a timer ends, I want "the game" to determine what is the highest score is, out of the four players, and tell the text box "_root.Winner" who it is.

I also need something in the same area, except when three scores drop to 0, the remaining player wins. (and is sent to _root.Winner).
I'm not that good at ActionScript, so hopefully any code you provide will be easy to pickup, and expand to other areas.

Thanks in advance for the help!

Get Highest Index
Whats the AS3 equivalent to getNextHighest.... I want one of my children to always be the highest index throughout the movie

Highest Depth
putting a movieclip into highest depth without knowing which clip is in the highest depth

Search For Highest Value
Hi

If I have 4 movieclips that each contains a numeric variable...how could I compare all their values then sort the movieclips in decending order?

I assume I have to use some sort of array and maybe createEmptyMovieClip() but I'm not sure how to go about it...any ideas?

Thanks

Get New Highest Depth
If I want an object to obtain the highest depth onRelease, which method from the following (or any other) would be the best?

Using a createEmptyMC at highest depth and then swap to with that hight or use DepthManager.setDepthTo() ?

Determining Which One Has Highest Value
i have 3 variables and im executing a block of code depending which on has the highest .. how do i determine has the highest and the execute the code which ever has the highest

Finding The Highest Y Value In 2.0
Hi, I have a shape and I want to find out what the highest y value is for an x value.
Example: I have an oval, and with width 200 px. I input an x value like 78 px from the left and I want to know what the highest y value is that matches the x value (the top of the oval at point x) Any ideas? Any help at all GREATLY appreciated.

Next Highest Depth In AS3
I have a test FLA with four movie clips that when the user rolls over them I want them to rise to the top, I have some AS2 code for this but I'm struggling to convert it.

Can any one provide me with some sample code?

Thanks

Ricky55

Highest Depth
putting a movieclip into highest depth without knowing which clip is in the highest depth

Get Highest Value From Array
I have an Array of random numbers, and I need to get the highest value one. I have tried to use Array.sort(NUMERIC) and that only arranges them by 10 digit and some of these numbers can be in the thousands and up.

Getting The Highest Value From The Array?
Let's imagine that I have the array with five numeric values: "10, 5, 2, 13, 9". How is it possible to get the highest value from that array? (The value "13", of course...) ...and the order of those values should remain "unsorted"! (...meaning that value "10" should remain the first value and so on...)

Any hints...? Some mathemathic "tricks"? I would need this highest value to compare it with another value not located in any array ...and for example to see if those two values are equal or not. Solving this would help me a lot in one actionscript-filled Flash-project.

Finding The Highest Number
My question might be a bit basic for this board but...

I am running Flash MX and have an external .txt file containing x and y coordinates.
It looks a bit like this, but much longer.

x=1,2,3,4,5,6,7,8,9&y=3,4,6,8,12,19,5,2,1&

Can anyone suggest how I can find the highest value of y?

Thank You in advance,

Tim.

Finding Out The Highest Variable?
Can anyone help?

I need to get a variable to display the variable with the highest score.

I have 4 options that the user can mark out of 10.

I then need to another variable “winner’ to display the option with the highest score.

For example:

Option01 = 5
Option02 = 3
Option03 = 8
Option04 = 1

‘Winner’ will display ‘Option03’

Does anyone know of the script to work out which of the 4 options is the highest?

Ideally I’m working for Flash 5 but if it can only be done in Flash MX then that’s ok.

Any help would be great

Thanks Dan

Highest And Lowest Vars
I have about 200 variables that create a graph, and the variables come from different categories with different ranges of values. (ex: values ranging from 1-4, values from 23-50, etc.)

What I need to do is get the highest value and the lowest of all the vars so I know the range to dynamically set the graph at.

I know how to do it on vars like this ( var1=5, var2=3) but he var names are very different. What I really want is to dump all of the vars in an array, then get a Math.findMax, and a Math.findMin, checking them at a ++ rate.

Lets see what you Flash kitters can do.

How To Make Something Highest Depth?
I can't figure out the right syntax to make an object in my movie go to the highest depth. I'm doing this inside a swf that is loaded into my main swf.

This is what I have but it's not working
code:
var nextDepth:Number = this.getNextHighestDepth();

targetClip.swapDepths(nextDepth);



I'm wondering since I'm calling this inside of a loaded swf if I should be using "this"? Not sure why it's not working.

[MX04] Get Highest Depth In A Mc
I have a list that adds mcs dynamically on stage. When I click on a mc it get the depth and name of that mc (ie mc4, depth 4 )

I trying to get the highest depth on stage, so if there 20 mcs, I get depth 20

When I click on a mc, that mc is deleted, I then want to target all the mcs from (ie depth 4) to move up in the Y axcess.

So if theres 20 mcs on stage and I click on 4.
5 to 20 moves up say 100px's

Need help with the bits in red

Found the below code to find the highest depth in a mc but could not get it working. Can somebody help me in understand it


PHP Code:




/* gets the highest depth in a movieclip */
MovieClip.prototype.highestDepth = function(){
var curr, high = undefined;
for (var clip in this){
if (!isNaN(curr = this[clip].getDepth()) && this[clip]._parent == this){
if (curr > high || high == undefined) high = curr;
}
}
return high;
}

Which Slot In An Array Is The Highest?
I have a small Array, only four slots; all with numbers.

Eg. [8,2,3,1]

What I need to know is: How can I make Flash return to me the slot number of the highest value.

For example an array of [2,3,5,2] would return 3 (five is highest)
[2,3,5,9] would return 4 etc.

Also, how would it handle if more than one was the highest?
[2,3,4,4] ????

I'm thinking it would have something to do with using RETURNINDEXEDARRY and/or UNIQUESORT. Maybe use the sort method to simply discover what value is the highest, then look for that value in the array to discver the slot number?

Three Mc's To The Highest Depth/level?
hi all,

still wrestling wildly with as3 - i 'do' think it will be worth the migration - but at the moment am trying to get my head around even the simplest of tasks!


okay if i have three mc's on my stage named sprite1 sprite2 sprite3 and i want them to sit above the image wall created by this script how do i do it?


PHP Code:



/*Created by Min Thu    http://www.flashmo.com    AS3 References and Credits    http://blog.papervision3d.org/    http://theflashblog.com/?p=306    http://www.gotoandlearn.com/    http://www.onerutter.com/    http://labs.blitzagency.com/    http://vilebody.wordpress.com/2007/11/29/3d-papervision-plane-events/*/import org.papervision3d.scenes.*;import org.papervision3d.cameras.*;import org.papervision3d.objects.*;import org.papervision3d.materials.*;import fl.transitions.Tween;import fl.transitions.easing.*;import flash.display.Sprite;import flash.events.MouseEvent;var container:Sprite = new Sprite();container.x = 400;container.y = 300;addChild(container);var scene:Scene3D = new MovieScene3D(container);var cam:Camera3D = new Camera3D();cam.zoom = 6;tn_title.text = "";tn_desc.text = "";tn_url.text = "";var p_dict:Dictionary=new Dictionary();var pc:Plane = new Plane();pc.visible = false;cam.target = pc;var numOfRotations:Number = 3;var yPos:Number = 0;var angle:Number = 0;var filename_list = new Array();var url_list = new Array();var url_target_list:Array = new Array();var title_list = new Array();var description_list = new Array();var folder:String = "thumbnails/";var i:Number;var j:Number = 0;var k:Number = 0;var l:Number = 0;var m:Number = 0;var total:Number;var flashmo_xml:XML = new XML();var loader:URLLoader = new URLLoader();loader.load(new URLRequest("thumbnail_list_3.xml"));loader.addEventListener(Event.COMPLETE, create_thumbnail);function create_thumbnail(e:Event):void {    flashmo_xml = XML(e.target.data);    total = flashmo_xml.thumbnail.length();    var anglePer:Number = ((Math.PI*2) * numOfRotations) / total;        for( i = 0; i < total; i++ )    {        url_list.push( flashmo_xml.thumbnail[i].@url.toString() );        url_target_list.push( flashmo_xml.thumbnail[i].@target.toString() );        title_list.push( flashmo_xml.thumbnail[i].@title.toString() );        description_list.push( flashmo_xml.thumbnail[i].@description.toString() );                var bfm:BitmapFileMaterial = new BitmapFileMaterial(            folder + flashmo_xml.thumbnail[i].@filename.toString());        bfm.oneSide = false;        bfm.smooth = true;        var p:Plane = new Plane(bfm, 140, 105, 2, 2);        scene.addChild(p);        var p_container:Sprite = p.container;        p_container.name = "flashmo_" + i;        p_dict[p_container] = p;        p_container.buttonMode = true;        p_container.addEventListener( MouseEvent.ROLL_OVER, p_rollover );        p_container.addEventListener( MouseEvent.ROLL_OUT, p_rollout );        p_container.addEventListener( MouseEvent.CLICK, p_click );                p.rotationY = (-i*anglePer) * (180/Math.PI) + 90;        p.x = Math.cos(i * anglePer) * 480;        p.z = Math.sin(i * anglePer) * 480;        p.y = yPos;        if( (i+1) % 20 == 0 )        {             yPos += 115;        }    }}function p_rollover(me:MouseEvent) {    var sp:Sprite = me.target as Sprite;    var tw:Tween = new Tween(sp, 'alpha', Strong.easeOut, 1, 0.5, 0.6, true);    var s_no:Number = parseInt(sp.name.slice(8,10));    tn_title.text = title_list[s_no];    tn_desc.text = description_list[s_no];    tn_url.text = url_list[s_no];}function p_rollout(me:MouseEvent) {    var sp:Sprite = me.target as Sprite;    var tw:Tween = new Tween(sp, 'alpha', Strong.easeOut, 0.5, 1, 0.6, true);    tn_title.text = "";    tn_desc.text = "";    tn_url.text = "";}function p_click(me:MouseEvent) {    var sp:Sprite = me.target as Sprite;    var s_no:Number = parseInt(sp.name.slice(8,10));    navigateToURL(new URLRequest(url_list[s_no]), url_target_list[s_no]);}addEventListener(Event.ENTER_FRAME, render);function render(e:Event):void{    var dist2:Number = ((stage.mouseX) - 400) * 0.0001;    angle += dist2;    cam.x = - Math.cos(angle) * 150;    cam.z = Math.sin(angle) * 150;    var new_zoom = 5;     cam.zoom += ( new_zoom - cam.zoom ) * 0.06;    scene.renderCamera(cam);}




that script creates a scrolling image wall but the wall sits above the three mc's and not at a lower depth.

do i need to create each mc dynamically? something like

sprite1 = newsprite etc...

or can i just say that sprite 1,2,3 should appear at depth 10,11,12?

i also need the mc's to act as a navigation - so if sprite1 is clicked the swf timeline will go to frame2 - and if sprite2 is clicked goto frame3

how do i do these things in as3? i would be able to do it in as2 but i can't work it out for as3 - some much is different! - anyone shed some light for me? please?

Finding Highest Total
i have jut posted a problem but i will explain a different way in an attempt to get help!

i have imported lots of values using XML, i have put them in variables named as follows
janV
febV
marV... etc

i need to take these variables and find the highest totals from them and display it in a text box? any ideas??

cheers people

Staying At Highest Depth
I have a about 70 movieClips floating about on the stage - all created dynamically using _getNextHighestDepth() to assign depth. The problem is I need a title bar that is always on top of all those movie clips.

The Monkey Wrench: Every 200 frames I create a new clip (a text graphic) and put that over the 70 floaters - using _getNextHighestDepth(). This clip swaps depths with the previous text mc that was there. If I set the title bar to then swap with that it still gets a few of the floaters going over it - but the text graphics ALWAYS stay on top. Why?

Is there a way to always check what the highest depth being used is and then automatically moving a movieclip to that highest depth?

Early on I use:


Code:
_root.createEmptyMovieClip("serviceVals_mc",this.getNextHighestDepth());
this.redV1_mc.swapDepths(serviceVals_mc);
this.serviceTTL_mc.swapDepths(redV1_mc);
The idea is to keep serviceTTL_mc always on top of everything else. Then later I,...


Code:
// Swap new text rectangle with previous

this.redV5_mc.swapDepths(redV4_mc);

// Attach previous value little red rect to newfloater

choiceOfRect = Math.random()*100 + 1;
xballName = "littleRED_3_mc";
_root.attachMovie("littleRED3_mc", xballName, this.getNextHighestDepth());
this.redV5_mc.swapDepths(_root[xballName]);
_root[xballName]._alpha = 35 + (Math.abs(choiceOfRect)/3);
If iI add this to the above...

Code:
this.serviceTTL_mc.swapDepths(this.redV5_mc);
.. it doesn;t work.

Any suggestions?

Next Highest Depth Problem
I'm building a tool that will allow users to draw shapes over another image. I'm importing the image as the background of the stage, and then placing the drawn shapes over that background.

I was successful in importing the background and the shape drawing scripting, however I'm trying to add a control bar over the background image to allow users to choose options before drawing, and I can't figure out how to control it's depth. I placed the control bar on the stage, but it's being hidden by the background image, which is being placed as such:


Code:
var bgImage:MovieClip = this.createEmptyMovieClip("bgImage", this.getNextHighestDepth());
if (!url) url = "http://mysite/image.png";
bgImage.loadMovie(url);
bgImage.moveTo(0,0);
Any tips on how to define the depth of the control bar MC show it will show up OVER the background image?

Thanks in advance you geniuses.

porpoise

Mc's/sprites To Highest Depth~?
hi all,

still wrestling wildly with as3 - i 'do' think it will be worth the migration - but at the moment am trying to get my head around even the simplest of tasks!


okay if i have three mc's on my stage named sprite1 sprite2 sprite3 and i want them to sit above the image wall created by this script how do i do it?


PHP Code:



/*
Created by Min Thu
    http://www.flashmo.com
    
AS3 References and Credits
    http://blog.papervision3d.org/
    http://theflashblog.com/?p=306
    http://www.gotoandlearn.com/
    http://www.onerutter.com/
    http://labs.blitzagency.com/
    http://vilebody.wordpress.com/2007/11/29/3d-papervision-plane-events/
*/
import org.papervision3d.scenes.*;
import org.papervision3d.cameras.*;
import org.papervision3d.objects.*;
import org.papervision3d.materials.*;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import flash.display.Sprite;
import flash.events.MouseEvent;


var container:Sprite = new Sprite();
container.x = 400;
container.y = 300;
addChild(container);

var scene:Scene3D = new MovieScene3D(container);
var cam:Camera3D = new Camera3D();
cam.zoom = 6;

tn_title.text = "";
tn_desc.text = "";
tn_url.text = "";

var p_dict:Dictionary=new Dictionary();
var pc:Plane = new Plane();
pc.visible = false;
cam.target = pc;

var numOfRotations:Number = 3;
var yPos:Number = 0;
var angle:Number = 0;

var filename_list = new Array();
var url_list = new Array();
var url_target_list:Array = new Array();
var title_list = new Array();
var description_list = new Array();
var folder:String = "thumbnails/";

var i:Number;
var j:Number = 0;
var k:Number = 0;
var l:Number = 0;
var m:Number = 0;
var total:Number;
var flashmo_xml:XML = new XML();
var loader:URLLoader = new URLLoader();
loader.load(new URLRequest("thumbnail_list_3.xml"));
loader.addEventListener(Event.COMPLETE, create_thumbnail);

function create_thumbnail(e:Event):void 
{
    flashmo_xml = XML(e.target.data);
    total = flashmo_xml.thumbnail.length();
    var anglePer:Number = ((Math.PI*2) * numOfRotations) / total;
    
    for( i = 0; i < total; i++ )
    {
        url_list.push( flashmo_xml.thumbnail[i].@url.toString() );
        url_target_list.push( flashmo_xml.thumbnail[i].@target.toString() );
        title_list.push( flashmo_xml.thumbnail[i].@title.toString() );
        description_list.push( flashmo_xml.thumbnail[i].@description.toString() );
        
        var bfm:BitmapFileMaterial = new BitmapFileMaterial(
            folder + flashmo_xml.thumbnail[i].@filename.toString());
        bfm.oneSide = false;
        bfm.smooth = true;
        var p:Plane = new Plane(bfm, 140, 105, 2, 2);
        scene.addChild(p);
        var p_container:Sprite = p.container;
        p_container.name = "flashmo_" + i;
        p_dict[p_container] = p;
        p_container.buttonMode = true;
        p_container.addEventListener( MouseEvent.ROLL_OVER, p_rollover );
        p_container.addEventListener( MouseEvent.ROLL_OUT, p_rollout );
        p_container.addEventListener( MouseEvent.CLICK, p_click );
        
        p.rotationY = (-i*anglePer) * (180/Math.PI) + 90;
        p.x = Math.cos(i * anglePer) * 480;
        p.z = Math.sin(i * anglePer) * 480;
        p.y = yPos;

        if( (i+1) % 20 == 0 )
        {
             yPos += 115;
        }
    }
}

function p_rollover(me:MouseEvent) 
{
    var sp:Sprite = me.target as Sprite;
    var tw:Tween = new Tween(sp, 'alpha', Strong.easeOut, 1, 0.5, 0.6, true);
    var s_no:Number = parseInt(sp.name.slice(8,10));
    tn_title.text = title_list[s_no];
    tn_desc.text = description_list[s_no];
    tn_url.text = url_list[s_no];
}
function p_rollout(me:MouseEvent) 
{
    var sp:Sprite = me.target as Sprite;
    var tw:Tween = new Tween(sp, 'alpha', Strong.easeOut, 0.5, 1, 0.6, true);
    tn_title.text = "";
    tn_desc.text = "";
    tn_url.text = "";
}
function p_click(me:MouseEvent) 
{
    var sp:Sprite = me.target as Sprite;
    var s_no:Number = parseInt(sp.name.slice(8,10));
    navigateToURL(new URLRequest(url_list[s_no]), url_target_list[s_no]);
}

addEventListener(Event.ENTER_FRAME, render);

function render(e:Event):void
{
    var dist2:Number = ((stage.mouseX) - 400) * 0.0001;
    angle += dist2;
    cam.x = - Math.cos(angle) * 150;
    cam.z = Math.sin(angle) * 150;
    var new_zoom = 5; 
    cam.zoom += ( new_zoom - cam.zoom ) * 0.06;
    scene.renderCamera(cam);





that script creates a scrolling image wall but the wall sits above the three mc's and not at a lower depth.

do i need to create each mc dynamically? something like

sprite1 = newsprite etc...

or can i just say that sprite 1,2,3 should at depth 10,11,12?

i also need the mc's to act as a navigation - so if sprite1 is clicked the swf timeline will go to frame2 - and if sprite2 is clicked goto frame3

how do i do these things in as3? i would be able to do it in as2 but i can't work it out for as3 - some much is different! - anyone shed some light for me? please?

Highest Quality Video
hi guys,

How can I stream the highest quality video?

Is it possible to connect and use a DV camera or other device and use that as a "webcam"? If so, will this result in higher quality video that the user on the other end will notice?

Any other ideas?

Thanks very much,

artane

MovieClip Highest Depth?
i checked out the movieclip depth range from depthManager

lowestDepth = -16383
highestDepth = 1048574
reservedDepth = 1048575


but why i can create the movieclip depth higher than reservedDepth??

i got tested it can up to 2130690045 depth, and over reservedDepth will be same as negative depth cannot be remove by removeMovieClip.

Sort Values Highest First
I have an array with numbers [3,6,12,78,34,3,2,]

in flash is there a special function that sorts these numbers in the array highest first or lowest first in order? How would one do this?

raskolnikov

Storing The Highest Value Of A Variable
I had a variable called Combo.Score set up to increase when something happens, but reset when something else happens, but I wanted flash to remember what the highest value of Combo.Score was throughout the entire program, so I set up something like


Code:
var objHighest = this;
objHighest.Score = 0;
_root.onEnterFrame = function() {
if (objCombo.Score >= objHighest.Score){
objHighest.Score = objCombo.Score;
}
but the variable objHighest.Score would just reset whenever objCombo.Score would reset..how do I tell objHighest.Score to stay at the same value until objCombo.Score is bigger than it?

How Do I Keep An Object Always At The Highest Depth?
I have a legal disclaimer (symbol text, instance name is internalUseOnly) that must always remain visible in a corner of the stage. It's on the highest layer of the movie, but new objects in child MCs that get drawn or placed on the stage will cover it. How can I control the depth so it's always at the highest level?

I tried assigning a custom class to it (see below), but Flash keeps throwing errors at me. (Including an error that I can't use the this keyword in a class and that I can't use the listener as the method of an object, both of which are baloney. I thought class-based code was supposed to make life easier, not harder.)

Maybe I'm barking up the wrong tree and a custom class isn't the answer. Anybody have an idea?

Here is what does NOT work:








Attach Code

package {
import flash.display.MovieClip;
public class alwaysOnTop extends MovieClip {
addEventListener(Event.ENTER_FRAME, keepTopDepth);
public function keepTopDepth(event:Event):void{
stage.setChildIndex(internalUseOnly, stage.numChildren-1) ;
}
}
}

























Edited: 02/03/2008 at 09:22:41 AM by tunghoy

Copyright © 2005-08 www.BigResource.com, All rights reserved