While(range--) What´s This?
I´ve seen this piece of code in another post:
ActionScript Code:
function getRandomNum(range, place, l) { var sourceArray = []; while (range--) { sourceArray.push(place + range); }
What does the while(range--) do?
How can you say the same thing using "if"?
KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 01-27-2004, 05:16 PM
View Complete Forum Thread with Replies
Sponsored Links:
While(range--) What´s This?
I´ve seen this piece of code in another post:
ActionScript Code:
function getRandomNum(range, place, l) { var sourceArray = []; while (range--) { sourceArray.push(place + range); }
What does the while(range--) do?
How can you say the same thing using "if"?
View Replies !
View Related
Range.
I'm thinking about having a go at one of those Tower Defense games (or building as many elements to help make one up as possible).
I have a static non-moving tower that fires at a specific enemy object (bullets never miss, I can change there frequency etc).
But I don't know how to handle "ranging"?, like a circular range around the tower that defines if it should shoot or not (only if the enemy intersects/comes inside of the towers range).
Any ideas?
P.S. I have tried to do a couple simple things like if enemy X/Y is N amount of pixels away but it only ever ends up doing well with 1 particular entry point and not others, there must be a better way of going about this lol.
Oh and if anyone has advice for other elements (that I haven't yet gotten to) concerning tower defense games (ones like Vector TD in particular as I like how that one works), it would be greatly appreciated.
View Replies !
View Related
Time In Particular Range ?
Hi,
Can someone help me with this scripting problem ?
I want to check if the local date and time (.GetHours, .GetMinutes, .Get Day, .GetMonth and .GetYear functions) is part of a specific timerange.
For instance from 20 April 2002 11h p.M. to 21 May 2002 9h a.m. I want to set a particular parameter to a specific value...
Anyone ?
Thanx in advance
r
View Replies !
View Related
_currentframe= A RANGE Of #'s
Here's what i've got in my code
on (press) {
if (_root.sight._currentframe=1 or 2 or 3 or 4 or 5 or 6) { <----This is the problem
_root.sight.nextFrame();
} else {
play();
}
}
I want it to recognize a RANGE of frames.
Also I noticed that even when using currentframe=1 it did not work. do i need to use Frame Labels? what is wrong?
View Replies !
View Related
Range Of ZIP CODES
Hi there,
I have a rang of zip codes where my company can delivery shipments within 24 hours, only in places located in that range of zip codes.
So, based on that information, I´d like to add a search box in the flash movie that I´m working on, this way WE can type the zip code in the search box and press SEARCH. If the user types a zip code that is within that range the actionscript would recognize it and show for example:
"THE ZIP CODE YOU ENTERED IS WITHIN THE 24HS ZONE"
But if the user enters a zip code that is not withing the range codes then show:
"THE ZIP CODE YOU ENTERED IS NOT WITHIN THE 24 HS ZONE"
Example of my range of zip codes:
01000-01099 (any zip code starting in 01000 and ending in 01099)
01500-01599 (any zip code starting in 01500 and ending in 01599)
and so on
Please note that I have more than one range of zip codes.
How do I set my IF actions to work as follow:
if (zipcode >=0100 && zipcode<=01099){
message = "THE ZIP CODE YOU ENTERED IS WITHIN THE 24HS ZONE";
}else if{
and so on
WILL IT WORK??? I HAVE ALREADY TRIED AND IT DIDN´T WORK HERE.
One thing that I don´t understand. What is the difference between = and == ??
In this case, should I use >==???
View Replies !
View Related
Stop Within Range...
Hi everyone. I need some help. I have created a 3 frame looping clip that moves my content around based on which button you click. I have the loop check against an array of positions so it knows where to go to and how far it needs to go from its current position.
Here is the code on the 2nd frame:
accel = .090;
yaccel = (_root.logoNextPosition-_root.mc_logo._y)*accel;
_root.mc_logo._y += yaccel;
if (Math.ceil(getProperty(_root.mc_logo, _y)) == _root.logoNextPosition) {
_root.stopLoop();
gotoAndStop(1);
}
My problem is that I never really get the values to equal each other because of the accel value. Depending on which way it moves sometimes it stops and sometimes it doesn't.
What I would like to do is test if the value is within range of the desired value, then stop my loop.
Make sense?
Thanks in advance everyone.
View Replies !
View Related
Targeting A Range Of MC's
Is it possible to target more than one MC in the same 'If' action. For example:
Say I have 50 movieclips named:
tree1
tree2
tree3
etc...
tree49
tree50
Is it possible to say: 'If this.hitTest(_root.tree[1-50])
or something like that?
Also will this speed up the game as an alternative to having 50 hitTest actions each with a different tree?
Thankyou very much for your help.
View Replies !
View Related
Set A Range For Dragging
Hi I have a movie which I allow the user to drag along _x, but I want to limit the range of the X dragging to within a specific range.
Any ideas on how I would do this?
Here is what I am using for the dragging:
code:
onClipEvent(load) {
drag = false;
}
onClipEvent(mouseDown) {
if (this.hitTest(_root._xmouse,_root._ymouse,true)) {
offset = this._x - _root._xmouse;
drag = true;
}
}
onClipEvent(mouseUp) {
drag = false;
}
onClipEvent(mouseMove) {
if (drag) {
this._x = _root._xmouse + offset;
updateAfterEvent();
}
}
View Replies !
View Related
Defining A Range...
Hi All,
I have a problem. My movie width is 500 pixels, I need this size to represent x size and be able to define the x size so that I can move a line along that line by a user being able to specify a value (x) in a input box.
This is a GPS app, basically I have a city center, the lat and long values have a range of 1500, but my movie is only 500 wide (and 500 high), when I get the lat and long values I need to move 2 lines along the X and Y values to show your location. If you took this example the movement of this would have to be 500/1500 = 0.33 . Does Flash support the ability to move a line by ultra small decimals? (I noticed it rounds decimals up to 1 decimal place)
I hope you understand what I mean.
Cheers
Carl Bruiners
View Replies !
View Related
Range Of Variables
i forgot how to do this.... can someone please remind me how to create a range of variables with just a couple of lines of AS;
i want to tell all my variables (and there's 42 of them) to appear... the script i have is:
ct002._visible = true;
ct003._visible = true;
ct004._visible = true;
but i don't really want 42 lines of script...
View Replies !
View Related
If Number Is Between Range...
Hello...
I need to know how to use ranges and if there is a between operator in Flash ActionScript 2.0.
I have a variable that needs to be compared to a range of numbers. For example...
If varCoverage (is between) 96-120 Then
varRecommend = Option 1
Else If varCoverage (is between) 121-192 Then
varRecommend = Option 2
Etc...
On and on until the end of the ranges. So, once varCoverage is determined, I need to be able to compare it to about 10 ranges and then which ever it fits into, I need to store that ranges option in the variable varRecommend.
Make any sense? =) Thanks for all your help!
View Replies !
View Related
[Help] Variable Range
I have a bar, that when it reaches 0, it plays an animation, but problem is, if someone pushes the button one more time making the value -1 it wiggs out.
How could I set a range? Like if (_root.health = 1-10) {
View Replies !
View Related
Number Range?
Is there a way to target a number range instead of a specific number in an "if" statement?
For example:
Code:
if(myvariable == numberRangefrom 5 to 100){
gotoAndPlay(10);
}
Thanks for taking a look at this.
View Replies !
View Related
Hittest Range
im working on a multi player game, like age of empires, there can be lots of units in the game at a time. when a unit shoots i use:
count += 1;
duplicateMovieClip("shot", "shot"+count, count)
to create a new shot. and when it hits a guy i was using:
if(this.hitTest(shot1) or this.hitTest(shot2) or this.hitTest(shot3)... and so on
is there a way to have a range of numbers in the hittest so you dont have to write them all out somthing like this:
if(this.hitTest(_root["shot"+ 1 -1000)){
View Replies !
View Related
Currentframe Range
Hi!
I have folowing actionscript code:
if (_root.vsebina_program_mc1.vsebina_program_mc3._cu rrentframe == 2 ) _root.vsebina_program_mc1.vsebina_program_mc3.goto AndPlay ("litrasi_down");
if (_root.vsebina_program_mc1.vsebina_program_mc3._cu rrentframe == 3 ) _root.vsebina_program_mc1.vsebina_program_mc3.goto AndPlay ("litrasi_down");
if (_root.vsebina_program_mc1.vsebina_program_mc3._cu rrentframe == 4 ) _root.vsebina_program_mc1.vsebina_program_mc3.goto AndPlay ("litrasi_down");
if (_root.vsebina_program_mc1.vsebina_program_mc3._cu rrentframe == 5 ) _root.vsebina_program_mc1.vsebina_program_mc3.goto AndPlay ("litrasi_down");
if (_root.vsebina_program_mc1.vsebina_program_mc3._cu rrentframe == 6 ) _root.vsebina_program_mc1.vsebina_program_mc3.goto AndPlay ("litrasi_down");
if (_root.vsebina_program_mc1.vsebina_program_mc3._cu rrentframe == 7 ) _root.vsebina_program_mc1.vsebina_program_mc3.goto AndPlay ("litrasi_down");
if (_root.vsebina_program_mc1.vsebina_program_mc3._cu rrentframe == 8 ) _root.vsebina_program_mc1.vsebina_program_mc3.goto AndPlay ("litrasi_down");
if (_root.vsebina_program_mc1.vsebina_program_mc3._cu rrentframe == 9 ) _root.vsebina_program_mc1.vsebina_program_mc3.goto AndPlay ("litrasi_down");
if (_root.vsebina_program_mc1.vsebina_program_mc3._cu rrentframe == 10 ) _root.vsebina_program_mc1.vsebina_program_mc3.goto AndPlay ("litrasi_down");
if (_root.vsebina_program_mc1.vsebina_program_mc3._cu rrentframe == 11 ) _root.vsebina_program_mc1.vsebina_program_mc3.goto AndPlay ("litrasi_down");
if (_root.vsebina_program_mc1.vsebina_program_mc3._cu rrentframe == 12 ) _root.vsebina_program_mc1.vsebina_program_mc3.goto AndPlay ("litrasi_down");
if (_root.vsebina_program_mc1.vsebina_program_mc3._cu rrentframe == 13 ) _root.vsebina_program_mc1.vsebina_program_mc3.goto AndPlay ("litrasi_down");
I would like to know is there a way to join all this lines into one more simple. Like:
if (_root.vsebina_program_mc1.vsebina_program_mc3._cu rrentframe == 2-13 ) _root.vsebina_program_mc1.vsebina_program_mc3.goto AndPlay ("litrasi_down");
But this isn't the way, because it doesn't work.
Tnx for help. (in the word "currentframe" there is a space between "u" and "r". Don't know why )
Blaz
View Replies !
View Related
_currentframe Specifying Range
Say _root.phase1 = 300 frames
on (press) {
if(_root.phase1._currentframe == 1 - 100){
_root.buttons.gotoandStop (2);
}
else{
_root.buttons.gotoandStop (1);
}
}
What I'm looking for is a way to define the range of frames, like:
Frame 1 - 100 = do thing 1
Frame 101 - 200 = do thing 2
Frame 201 - 300 = do thing 3
Anyone have any thoughts?
Thanks a million!
Synth
View Replies !
View Related
Datatype Range
Hi,
Can anyone of you mention or refer any weblink where I could found datatype ranges for flash variable?
I did not find any such info in FlashMx2004 and Flash8 documentation.
Thanks in advance
View Replies !
View Related
How To Check A Mc's _x & _y In A Range ?
I'd like to check if a mc's _x and _y properties are between a certain range, but can't find out how to. Now that I'm typing this (I can't check it in Flash right now at the moment), I'm thinking if this will work:
let's say the mc is called mcMyMovie and it has to be between 90 & 100 (both for x and y)
if(mcMyMovie._x =< 100 && mcMyMovie._x =>90 && mcMyMovie._y =<100 && mcMyMovie._y =>90) {
}
Would this work or is there a shorter way to write this down in code ? In maths I'd write something like 90 < mcMyMovie._x <100.
Thanks!
View Replies !
View Related
Range Within An Array
Hi, I was wondering if someone could help me?
I'm trying to create an simple (yet I still can seem to do it) task where a user has to enter a prevously worked out number into an input box clicks a button and get a correct or incorrect message.
I need the number that they enter to be a numer within a range ie. 1.0 to 1.9
I have 2 text boxs on stage... 1 an input text box (called inputBox) and the other a dynamic text box (called answerBox) also the is a button on stage to exec the script
on the root timeline the script is:
Code:
numbers = ["1.0", "1.1", "1.2" etc etc];
function checkNumbers () {
for (i=0; i < numbers.length; i++) {
if (_root.inputBox == numbers[i]) {
_root.answerBox = "Correct";
} else {
_root.answerBox = "Wrong"
}
}
i}
and on the button is:
Code:
on (release){
checkNumbers()
}
but whatever I do I cant get it to work, can someone help me out here please???
View Replies !
View Related
How To Check A Mc's _x & _y In A Range ?
I'd like to check if a mc's _x and _y properties are between a certain range, but can't find out how to. Now that I'm typing this (I can't check it in Flash right now at the moment), I'm thinking if this will work:
let's say the mc is called mcMyMovie and it has to be between 90 & 100 (both for x and y)
if(mcMyMovie._x =< 100 && mcMyMovie._x =>90 && mcMyMovie._y =<100 && mcMyMovie._y =>90) {
}
Would this work or is there a shorter way to write this down in code ? In maths I'd write something like 90 < mcMyMovie._x <100.
Thanks!
View Replies !
View Related
Getting A Number Within A Range
I'm currently getting the x value of one movieclip and setting the x value of another movie clip to the same x. I want to make sure that the second movie clip does not go off the stage, so basically I was wondering how to set a value (number) but tell flash, that if it's outside a certain range, (a min or max value) then simply set it to that value
THanks!
View Replies !
View Related
Frame Range Action
I'm in need of an action script to tell a roll over button NOT to trigger if the frame is between frames 5 and 9.
Example: If the playback head is in between frames 5 and 9 the roll over button won't trigger, Outside of 5 and 9 the roll over triggers normally.
Thanks for any help!
View Replies !
View Related
LineChart: Range For Y Axis
Hi,
I´ve already charged a LineChart with the data from an archive called graphic.xml, but I don´t like the default values that appear in the Y axis (this default values depend on the values of the X axis, charged via xml in this case).
I´d like to know if there is a posibility to change the range on the Y axis, to define the max. and min. values for this range.
Thanks.
View Replies !
View Related
Defining A Range For _xmouse
Here is what I am trying to do, I know that the code is wrong thats where I need your help.
if (xmouse < 1 but > 10){
gotoAndPlay (2);
}else if (_xmouse <11 but >20){
gotoAndPlay (3);
}
basically I want to define a range for the _xmouse and have the if statement take it to a certian frame.
Any help would be appreciated.
Thank You
MikeMadMan
View Replies !
View Related
Is There Any Way To Give A Range Of Values?
Hi,
I have a movie that consists of 90 instances that I wish to change the colour of with the click of a button. I know how to set the new colour, but is there any way of scripting a range of numbers instead of having to type out the set new colour for each one of the 90 clips. For instance this is how it looks to change just one clip.
c = new Color(_root.movie1);
c.setRGB(0x203F00);
Is there a way to
c = new Color(_root.movie1to90);
c.setRGB(0x203F00);
Any help would be much appreciated.
View Replies !
View Related
Playing A Range Of Frames
Hi
I am building a bar chart graph.
All is going well, I have built the graph - all the axis and bars are in place and all variables load in from my ASP page.
Each bar is a separate movie clip containing 100 frames, each frame representing 1% of the graph results. I have 5 bars and when the scene loads I want each bar to move to the frame corresponding to the value pulled in from the ASP file.
So if the ASP file values are 10 and 90 the first two bars will move to frame 10 and frame 90 respectively. I want the bars to move up the screen animated as in the motion tween, not just jump to that frame
The difficulty I am having is getting each bar to play until it reaches a specific frame, not gotoAndStop().
So if the value for the first bar is 50, I want the move clip called bar_1 to play until frame 50 and then stop.
As I said earlier I can load the variables fine, just need help making a movie clip play a specific amount of frames and then stop
At the present I have this for the actions on each bar, but using the gotoAndStop it will jump straight to the frame given, not play each frame upto a number and then stop:
onClipEvent(load)
{
loadVariables("poll.asp",this);
}
onClipEvent(data)
{
/* votes1 is the value from the asp */
var v1 = Number(votes1);
this.gotoAndStop(v1);
}
Thanks
Dean
View Replies !
View Related
Random Number In A Range
I am looking for a simple piece of script. I would like to assign a random number, from a range (ie. 20–250) to a function.
Example:
variable = random number between 20 and 250
Any help? Thanks so much.
View Replies !
View Related
Finding A Range With Code
hi all,
how can do this??
* i have a button, and a couple of movie clips inside each other.
* how can i make an 'if' statment to query if i am on a specific frame eg 20 to 25? inside one of the mc's?
* i have this so far, but it only does frame 20
//----code------------------------
on (press) {
if (_root.mc1.mc2._currentframe == (20)) {
stopAllSounds();
}
}
//end code////////////////////////
* also instead of saying frame 20, can i use a frame name? eg
"helloImFrame20" - "helloImFrame25"?
thanks for your help
Aiden
View Replies !
View Related
Frame Range Or Delay?
okay heres the deal im trying to get a button to continue playing the movie and then when thats done go to and play scene of my choice
heres what ive tried...i cant just put a goto and play at the end of the first scene because then it would only work for one of the buttons and i have 6 =
on (release) {
gotoAndPlay("Scene 1", 16);
stop("Scene 1", 29);
gotoAndPlay("Scene 2", 1);
}
on (release) {
gotoAndPlay("Scene 1", 16);
wait(13) (also tried delay(13)
gotoAndPlay("Scene 2", 1);
}
on (release) {
gotoAndPlay("Scene 1", 16-29); (i really wish this would work =()
gotoAndPlay("Scene 2", 1);
}
im not familiar with the advanced options so if anyone could help me out that would be great
toast
View Replies !
View Related
Clickable Range In A Movie ...
I've made a movie that simply rotates images but I am interested in having a getURL() function for each image. I didn't want to put the movie clip in a button because I didn;t think that would work so each picture has it's own layer and I know how to write the getURL portion of the actionscript but when I tried i wouldn't do anything. Each picture's effects last about 70 frames. Do I need to specify a range of frames to go to the URL when clicked?
Thanks for any help.
-B
View Replies !
View Related
Expressing X-position As Range?...
Hi,
I'm trying to lower the sound object volume based on the x-position of a horizontal slider. The slider's horizontal range is from "-45" to "5" :
on (press) {
startDrag("", true, -45, 0, 5, 0);
}
on (release, dragOut) {
stopDrag();
}
The following lowers the volume down to 80% when I drag the slider a little to the left (below "0"):
on (press, release, releaseOutside, dragOver, dragOut) {
with (this) {
if (_x>=0) {
_root.mySound.setVolume(100);
}
if (_x<0) {
_root.mySound.setVolume(80);
}
}
}
Question: How would I have my slider, for example, set the volume to 40% when my horizontal slider was greater than or equal to "-35" and less than "-25"?
Thanks
-Todd
http://www.toddlerneradvertising.com
View Replies !
View Related
Ease Out After Mouse Out Of Range
peepz,
i have a script that moves a mc in the opposite direction of the mouse (only on "_y") but if i point my mouse out of the range i defined it needs to ease out a bit...
i tried something but i couldn't get it work:
my code:
code:
onClipEvent (load) {
delay = 10
}
onClipEvent (enterFrame) {
if(this._parent._ymouse >= 141+this._height or this._parent._ymouse <= -139 or this._parent._xmouse <= 0 or this._parent._xmouse >= 490)
{
// i need the CODE in here?! thanks!
}
else
{
y = this._y
_y = Math.round(((-this._parent._ymouse-y)/delay)+ (y +1.08) +2);
if(_y <= -139)
{
_y = -139
}
if(_y >= 141)
{
_y = 141
}
}
}
View Replies !
View Related
[F8] Expand Button Range
Hello
I have a series of buttons that load text from an external file. Right now it is set for 7 buttons. But I want to expand it to over 100 or so. How would I do that wit this script. I believe it has something to do with the last line ("(-1)-1]") but I don't really understand this script. Can some one show me how to expand it to a larger number of buttons pleas.
Thanks. Code follows
stop();
var my_array=new Array();
dtext.html = true;
var buttonText:LoadVars = new LoadVars();
buttonText.onLoad = function(success) {
if (!success) {
dtext.htmlText = "<b>FAILED TO LOAD</b>";
} else {
for(var i=1; i<7; i++) {
mc=eval("this.button"+i);
my_array.push(mc);
_root["mcbutton"+i].onRollOver = function(){
this.gotoAndPlay(2);
assignText(this);
}
_root["mcbutton"+i].onRollOut = function(){
this.gotoAndPlay(21);
dtext.htmlText = "";}
}
}
};
buttonText.load("buttonText.txt");
function assignText(who){
dtext.htmlText = my_array[who._name.substr(-1)-1];
}
View Replies !
View Related
Switch With Range Rather Then Single Value ?
Switch with range rather then single value ?
Hi all,
I have an input textfield (input_txt) and a btn (range_btn). I want to use a switch to check if the number input into the textfield falls within certain ranges.
code:
range_btn.onRelease = function() {
var range = input_txt.text;
switch (range) {
case (range>=1 && range<=5) :
trace("1-5");
break;
case (range>=6 && range<=10) :
trace("6-10");
break;
case (range>=11 && range<=25) :
trace("11-25");
break;
case (range>=26 && range<=50) :
trace("26-50");
break;
case (range>=51 && range<=100) :
trace("51-100");
break;
case (range>=51 && range<=100) :
break;
}
};
View Replies !
View Related
[F8] How To Randomly Place MC's Outside Of Specified Range
I threw this together earlier and am having trouble really making it do what I want. I'm trying to place an n number of clips off stage based on some variables that can be tweened in later. I made a little function that sort of does this but it only sticks the clips in either the top left or bottom right. I would like it to put them in a little more random areas than that. Here's the function:
PHP Code:
function keepOffStage(left:Number,right:Number,top:Number,bottom:Number):Number{
var x:Array = new Array();
var y:Array = new Array();
x[0] = -(Math.ceil(Math.random()*left)+left);
x[1] = Math.ceil(Math.random()*right)+right;
y[0] = -(Math.ceil(Math.random()*top)+top);
y[1] = Math.ceil(Math.random()*bottom)+bottom;
sides = (!sides)? true:false;
trace(sides);
if(sides)
num = [x[0],y[0]];
else
num = [x[1],y[1]];
return num;
}
pos = keepOffStage(200,600,150,450);
trace(pos);
this.attachMovie('clip1','clip1',this.getNextHighestDepth(),{_x:pos[0],_y:pos[1]});
View Replies !
View Related
Random Color Range
i have this code:
Code:
currColor = Math.round(Math.random()*0x0011AA);
var mcColor:Color = new Color(eval("_root.shell.mc"+n));
mcColor.setRGB(currColor);
which generates nice random colors all in the hue of dark blue.
now i'd like to add red hues to the color range, but i can't do it without adding the full color spectrum.
is there a way of restricting the range to dark blues/purples & reds? should i use a different method?
View Replies !
View Related
Switch With Range Rather Then Single Value ?
Switch with range rather then single value ?
Hi all,
I have an input textfield (input_txt) and a btn (range_btn). I want to use a switch to check if the number input into the textfield falls within certain ranges.
ActionScript Code:
range_btn.onRelease = function() {
var range = input_txt.text;
switch (range) {
case (range>=1 && range<=5) :
trace("1-5");
break;
case (range>=6 && range<=10) :
trace("6-10");
break;
case (range>=11 && range<=25) :
trace("11-25");
break;
case (range>=26 && range<=50) :
trace("26-50");
break;
case (range>=51 && range<=100) :
trace("51-100");
break;
case (range>=51 && range<=100) :
break;
}
};
View Replies !
View Related
ComputeSpectrum, Values Out Of Range?
I'm using SoundMixer.computeSpectrum(), and have followed pretty much the most basic way of implementing it.
Code:
SoundMixer.computeSpectrum(ba);
for (var i:uint = 0; i < 256; i++) {
var lev:Number = ba.readFloat();
if (lev > 0) {
trace(lev);
}
}
Right now I'm just trying to see what kind of values I get out of this... and then I'm home-free from there.
Problem is, instead of seeing values from -1.0 to 1.0, I'm actually getting trace data from 0 to 1.7, 1.3, 1.2. This doesn't happen that often, but it happens - and is totally killing my animations. As I'm expecting to use the 0.0 to 1 value as a scale factor.
Has anyone encountered this?? Could it be the sound file and not the coding? I'm playing a 192k sampled 44.1kHz clip.
View Replies !
View Related
Random Color Within A Particular Range
HI,
I'm trying to figure out how to generate random colors but within a particular range.
In my application I have to allocate a random color to an unknown number of movieclips.
I can do this ok but sometimes I'm wind up with a very ugly combination of colors like bright yellow and purple for examples.
How can I generate random colors within a particular "range" I guess is the word for it?
ActionScript Code:
for (var h:int=0; h<noOfUniqueClips; h++)
{
var myColor:Number = Math.round( Math.random()*0xffffff );
var uName:String=noDuplicateArray[h].Name;
var colorObject:Object=new Object();
colorObject.Name=uName;
colorObject.nColor=myColor;
uniqueColorArray[h]=colorObject;
}
View Replies !
View Related
Ease Out After Mouse Out Of Range
peepz,
i have a script that moves a mc in the opposite direction of the mouse (only on "_y") but if i point my mouse out of the range i defined it needs to ease out a bit...
i tried something but i couldn't get it work:
my code:
ActionScript Code:
onClipEvent (load) {
delay = 10
}
onClipEvent (enterFrame) {
if(this._parent._ymouse >= 141+this._height or this._parent._ymouse <= -139 or this._parent._xmouse <= 0 or this._parent._xmouse >= 490)
{
// i need the CODE in here?! thanks!
}
else
{
y = this._y
_y = Math.round(((-this._parent._ymouse-y)/delay)+ (y +1.08) +2);
if(_y <= -139)
{
_y = -139
}
if(_y >= 141)
{
_y = 141
}
}
}
View Replies !
View Related
Random Odd Number With In A Range
as title, what i wanted is any odd number being randomly picked from 3-38, and thats the code i have, to let the mc randomly select a frame to go
2nd question for input boxes, how can you add value?
ex:
LE.text = LE +"1" does this work?
Attach Code
var n:Number = Math.round(((Math.random() * 36)+3));
var p:Number = Math.floor(((2 * n + 1)/2));
if (a == "18") {
gotoAndPlay(39);
} else {
gotoAndStop(p);
}
View Replies !
View Related
*simple* How To Write Range
I am creating a flash game, and I can't seem to get a range to work correctly. I have an object that needs to be collected. once you touch it, it randomly regenerates on the y axis. That all works fine, however I'd like it to regenerate between lets say 20 and 500 because otherwise it overlaps a menu bar.
Here's what I have
Attach Code
onClipEvent (enterFrame) {
if (hitTest(_root.super_fister)==true)
{
trace("hit")
_root.score.text = Number(_root.score.text) + Number(25)
gotoAndPlay(1)
_root.point._x = (0)
_root.point._y = random(400)
}
}
View Replies !
View Related
How Do I Make A Range Of Numbers?
I am creating a flash game, and I can't seem to get a range to work correctly. I have an object that needs to be collected. once you touch it, it randomly regenerates on the y axis. That all works fine, however I'd like it to regenerate between lets say 50 and 400 because otherwise it overlaps a menu bar.
I think I could use the Math.random() method, but I can't figure how to get it to work in the sense I'd like it to. What should I change what I have to?
Attach Code
onClipEvent (enterFrame) {
if (hitTest(_root.super_fister)==true)
{
trace("hit")
_root.score.text = Number(_root.score.text) + Number(25)
gotoAndPlay(1)
_root.point._x = (0)
_root.point._y = random(400)
}
}
View Replies !
View Related
|