Math Power Function
I want to make a function like y= (1 - x^z), where both x and z are user input values. How is that possible?
KirupaForum > Flash > ActionScript 3.0
Posted on: 10-30-2008, 08:12 AM
View Complete Forum Thread with Replies
Sponsored Links:
Function To "Constrain Value If Its A Power Of 2"
Last edited by spooky : 2007-08-08 at 13:23.
I'm working with the BlurFilter class in Flash 8.
Making customized transitions with it.
I want it to process as efficiently as possible.
Anybody have a function that will return a given number only if its a power of 2...and return null if not?
//-----------------------------------
var n=0;
var value=n;
var testvalue=n;
while(n < 100){
testvalue=constrainToPowerOf2(n);
if(testvalue != null){
value=testvalue;
}
trace(value)
n++;
}
//---------------------------------
According to the Flash 8 documentation:
"Valid values are from 0 to 255 (floating point). The default value is 4. Values that are a power of 2 (such as 2, 4, 8, 16 and 32) are optimized to render more quickly than other values."
View Replies !
View Related
Math Function
wzup Y'all
I was wondering if flash has a function wich returns the difference between 2 variables.
Example1:
a=200
b=500
function(a,b) - returns 300
example2
a=-800
b=300
function(a,b) - returns 1100
I hope this function excists and I hope you'll tell me where i can find it.
thanks in advance
View Replies !
View Related
Math Function
Hi there!
I wonder if there is a way to "plot" or draw a solid circle
with a function using a specific origine (o), a radius (r)
and an angle that goes from 0 to 360 degrees.
Thanks a lot for all your answers!
View Replies !
View Related
Math.round Function
i'm just messing arround with it but i can't get this thing to work.
if i have some script like
_level0.number=random(51);
how can i then round this number to the nearest 5?
I don't just want to use _level0.number=random(11)*5
cos then i find out how to use round
so far i have something like math.round(level0.number)50; but i can't really remember
plz help if u can (i'm using flash 5)
==================
TiMo
View Replies !
View Related
Some Sort Of Math Function
Hello,
This is my first time on a message board of this type. I am trying to create a function in which a user is limited from going to a particular frame on a scene until they have first clicked on all areas of the scene.
For example - the program I am creating is one in which a user will view a case study. After viewing the case study, they are to click a "next" button to go to the next case study. However, I don't want them to have the option of clicking next until they have first gone to each of five parts that make up the case study, which are individual movie clips.
I don't even know where to start with the coding. If you could please give help, I would appreciate it.
TDP
View Replies !
View Related
Simple Math Function?
Hi
I have 4 txt boxes that will have 0 or 1 depending on a collision or not.
I want to set another txt box to be the total number in those 4 boxes.
ie if the boxes are 0,0,1,1 then the total box would say 2.
I dont know how to do it actionscript but i guess it would be something like this:
total_txt.text = txtbox1 + txtbox2 + txtbox3 + txtbox4
please can someone help?
Thanks,
Dan
View Replies !
View Related
Math Inside Function
I've got a function call that passes a number to the function to be manipulated, for the sake of this question it looks like the following:
function generate_comments(com_num) {
limiter = com_num+1;
com.item_txt.text = limiter;
}
where the passed value "com_num" is equal to 1. Can anyone tell me why, when this function is run, instead of returning the value "2", limiter concatenates 1 and 1 and returns a value of "11"?
View Replies !
View Related
Motion As A Math Function
Hello all.
I would like to change the position of an object as a function of time (or frame...) using script. I just did it using a spreadsheet for the numbers, and typing in positions for every frame, and it looked good, but was a little tedious.
If it helps, y should equal y0 + vt + 1/2gt^2 , where y0 is the starting position, v is a constant, t is the time, and g is also a constant, and t^2 is the time squared.
Any ideas would be appreciated.
BobR
View Replies !
View Related
Help With Math.round Function
Hi there,
I'm not sure about the title of this thread, but I'm assuming that I'll be able to somehow sort my problem with the math.round function.
Screenshot :
I have a small mp3 player. The part with the red outlining in the screenshot shows the current playing position in seconds and minutes. Right now it shows "0:6". What I want to do is to make this "00:06" and then when it reaches 10 seconds, it should show "00:10". How can I do this?
I'm currently calculating it this way :
HTML Code:
var pos_total = song.position/1000;
var pos_minutes = Math.round(pos_total/60);
var pos_seconds = Math.round(pos_total)%60;
...where "pos_minutes" is the minutes and "pos_seconds" is the seconds.
All help will be greatly appreciated! Thanks
View Replies !
View Related
ActionScritp And Math.round Function
I want to create a graph (vertical bars) that i can control by sliding a scroll button up and down (the bar would follow the scroll button). On my scene i have a movie clip (instance name = panel) that as 20 frames. It is controled by the scroll bar.
The button as this script:
on (press) {
this.startDrag(false, 0, MaxX, 0, MinX);
}
on (release) {
stopDrag();
}
This button is then converted into a movie clip and as this script:
onClipEvent (load) {
MinX = -20;
MaxX = 0;
mcFRAME = _root.panel;
}
onClipEvent (mouseMove) {
x = Math.round(this._y);
mcFRAME.gotoAndStop(-x);
_root.bar.input = (-x);
updateAfterEvent(mouseMove);
}
The problem is that when i move the scroll bar (with mouse button down) it works fine, the graph bar will follow. But when i release the mouse button, the panel movie keeps on moving for a very short period (0.5 sec.)when it's supposed to stop. Also, when i use the "trace" function for "mcFRAME.gotoAndStop(-x);" and "_root.bar.input = (-x);" but the values are difffrent until i release the button and wait about (0.5 sec.). I want to know if this problem is comming from the Math.round function, or from a script error ?
This is very bothering, because i want to use that scroll bar so the viewer can set the graph's bar height. But when the disired height is reached, a small modification is made event if the mouse moves even if the button is up.
Thanks
Steve
View Replies !
View Related
Math Function Into Variable For Button... Maybe?
i was wondering if there is anyway to put a math function in a variable to be used in a button so i can click the button and have a different function become active in the code... hmm i can't think of a way of wording this that isn't confuseing both me and probabally you. i'll try this way.
k in this bit of code
Code:
for (i=0; i != Points; i++) {
vertex[i].x1 = vertex[i].x;
vertex[i].y1 = (Math.cos(radx)*vertex[i].y)-(Math.sin(radx)*vertex[i].z);
vertex[i].z1 = (Math.sin(radx)*vertex[i].y)+(Math.cos(radx)*vertex[i].z);
vertex[i].x2 = (Math.cos(rady)*vertex[i].x1)-(Math.sin(rady)*vertex[i].z1);
vertex[i].y2 = vertex[i].y1;
vertex[i].z2 = (Math.sin(rady)*vertex[i].x1)+(Math.cos(rady)*vertex[i].z1);
vertex[i].x3 = (Math.cos(radz)*vertex[i].x2)-(Math.sin(radz)*vertex[i].y2);
vertex[i].y3 = (Math.sin(radz)*vertex[i].x2)+(Math.cos(radz)*vertex[i].y2);
vertex[i].z3 = vertex[i].z2;
this gives this an almost ridgid form where apart from the rotation, not much in actual structure changes. however when the "cos" in red are substituted for "tan" it goes a bit crazy, you can see that by clicking the button on my website labled tan. i was wondering if there was any way i could control this so that you could create a button and have this button substitue the cos and the tan, by switching the contents of a variable that would contain that function. if you haven't already guessed by now i'm pretty new to flash and action scripting. up untill a month ago i'd never even looked at flash before and have virutally no design skills so please excuse my website, its my first go, i'm just experimenting.
thanks, squid.
View Replies !
View Related
How User Put Math Function And Flash Use It
Evening Guys,
Am hoping someone on here is able to help me with this one.
i am want to make user put function such as X^2 +5X +6
in inputtext and user also put the X (number)
i made Button calcate to replace x (number) into the function . what action
script code can i put it? . and can i make it by component?
i attach Calculte.fla for flash mx pro 2004 and attach also calculta2.fla for flash mx
thank you
View Replies !
View Related
Problem With Math.ceil Function
I have recently realized that I cannot place a variable inside the math.ciel function. I can do it on one project but i cant in flash 8? whats going on here? Take a look at the following code. It works in flash 5 and mx. but it doesnt work in flash 8.
sofarframes = 0;
totalframes = _root.getBytesTotal();
sofarframes = _root.getBytesLoaded();
_root.loader.bar._x = math.ceil(sofarframes / totalframes * 200);
trace(math.ceil(sofarframes));
if (sofarframes == totalframes) {
gotoAndStop(3);
}
As you can see - im trying to do a trace on my ceiling function. However - when the movie plays - the trace displays "Undefined". Doing this should at least display a 0 since i defined sofarframes at the top. Please HELP!!!
View Replies !
View Related
Adding Function To Math Object
i have this functions and i want to add to math object but i get this errors
FUNCTION
/*******************************************
* Distance function *
*******************************************/
Math.prototype.distance = function (x1,y1,x2,y2) {
var dx=x2-x1;
var dy=y2-y1;
return Math.sqrt(dx*dx+dy*dy);
};
/*******************************************
* Radians to Degrees *
*******************************************/
Math.prototype.radToDeg = function (angle) {
return angle*(180/Math.PI);
};
/******************************************
* SINE FUNCTION = HEIGHT (_y) *
******************************************/
Math.prototype.sinD = function (angle) {
return Math.sin(angle*(Math.PI/180));
};
ERROR
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 2: There is no method with the name 'radToDeg'.
trace(Math.radToDeg(Math.PI));
Total ActionScript Errors: 1 Reported Errors: 1
View Replies !
View Related
Help Needed With Math.round Function....
Hi,
I have this piece of code :
var c4 = Math.sqrt ((c3*(1-c3)/(num1+num2))+(c3*(1-c3)/(num3+num4)));
When I run my program I get values upto several decimals. How do I use the Math.round to the above piece of code to truncate to say 4 decimal places.
Please suggest.
Thanks.
View Replies !
View Related
Adding Function To Math Object
i have this functions and i want to add to math object but i get this errors
FUNCTION
/*******************************************
* Distance function *
*******************************************/
Math.prototype.distance = function (x1,y1,x2,y2) {
var dx=x2-x1;
var dy=y2-y1;
return Math.sqrt(dx*dx+dy*dy);
};
/*******************************************
* Radians to Degrees *
*******************************************/
Math.prototype.radToDeg = function (angle) {
return angle*(180/Math.PI);
};
/******************************************
* SINE FUNCTION = HEIGHT (_y) *
******************************************/
Math.prototype.sinD = function (angle) {
return Math.sin(angle*(Math.PI/180));
};
ERROR
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 2: There is no method with the name 'radToDeg'.
trace(Math.radToDeg(Math.PI));
Total ActionScript Errors: 1 Reported Errors: 1
View Replies !
View Related
Math Class Function Code
Hey guys
Im making a game at the moment and to optimize its speed i was interested in finding out how the bulit in math functions (Math.sqrt,Math.sin, etc) actually work. Is their anywhere (guessing macromedia.com) where there is a list of these functions. For example
The Math.abs function may be like this:
function Math.abs(number) {
if(number<0) number = -number;
return number;
}
The function im most interested in is the square root function
TY in advance
Mark
View Replies !
View Related
Simple Math Function For Background Image?
i keep thinking about this way too much and ****ing up so i'm coming here for your help
i have a stage, 1024x640, width being 1.6 times the height, and i want to keep my background image at that aspect ratio when the page is resized.
TO CLARIFY: i'm doing this because I want a background image to be resized to fit any window and keep its aspect ratio, exactly the same way a stageListener.onResize function would work if the Stage.scaleMode was set to noBorder. when its set to no border, my image is scaled up perfectly in its normal aspect ratio and is clipped if it expands one side too much.
ActionScript Code:
Stage.align = "TL";
Stage.scaleMode = "noBorder";
setBackground = function ()
{
_root.screen_w = Stage.width;
_root.screen_h = Stage.height * 0.9;
_root.background1_mc._height= Stage.height;
_root.background1_mc._width = Stage.width;
}
;
stageListener = new Object();
stageListener.onResize = function ()
{
setBackground();
}
;
Stage.addListener(stageListener);
setBackground();
stop();
^^this is the code to make my background scale exactly how i want it to, if one side is too short for the aspect ratio it just clips it.
my problem comes from the fact that I only want this type of scaling to happen on my background image, not the whole movie, because if I keep this code in, when I start adding other elements, they also start becoming scaled and i dont want that at all
so any ideas, using if statements maybe, to check for the width of my stage and then compare it to my height so that the height*1.6 = width stays intact??
thanks in advance to anyone who can help, i hope i didn't over-explain myself
View Replies !
View Related
Trig. Function Needed, Not In Math Object
Calling all math club wizards, your help would be much much appreciated.
The Math object doesn't have a "secant", and I'm not math savvy enough to find its equivilant formula, nor have I found one in an exaustive tutorial search.
The problem I have I can't find anywhere online.
I need flash to trace an angle in a right triangle when only the hypotenuse and adjacent sides are known, translated into nice and neat actionscript.
(The pen and paper version is sec(Angle) = hypotenuse/adjacent. I need to solve for "Angle"). Any takers? Much much thanks.
View Replies !
View Related
Easing Function (Math Property Error)
Hello,
i have included an as file with several easing equations. all seems to work in a couple projects i've used them in but the majority wont run due to this error x34 [each for it's respective equation]:: i have used the "ease out elastic " equation as an example.
//My "ease out elastic "equation
Math.easeOutElastic = function (t, b, c, d, a, p) {
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
if (a < Math.abs(c)) { a=c; var s=p/4; }
else var s = p/(2*Math.PI) * Math.asin (c/a);
return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
};
//this is the error that runs for each equation:
**Error** Symbol=main, layer=Layer 23, frame=1:Line 204: There is no property with the name 'easeOutElastic'.
//I add the following code to an actions layer on frame one of my main MC::
#include "easing_equations.as" // includes my 34 equations
MovieClip.prototype.easeProperty = function(p,f,d,e,oc){
if (e==undefined)e="easeOutQuad";//set a default easing equation
this["f" + p] = f;
this["t" + p] = 0;
this["b" + p] = Math.floor(Number(this[p].toString(10)));
this["c" + p] = f - this["b" + p];
this["d" + p] = d;
this["propInt" + p] = setInterval(easeIt,32,this,p,this["f" + p],d,e,oc);
}
function easeIt(mc,p,f,d,e,oc){
mc[p] = Math[e](mc["t" + p]++,mc["b" + p],mc["c" + p],mc["d" + p]);
if (mc["t" + p] >= mc["d" + p]){
mc[p] = this["f" + p];
if (oc != undefined)_root[oc]();
delete mc["f" + p];
delete mc["t" + p];
delete mc["b" + p];
delete mc["c" + p];
delete mc["d" + p];
clearInterval(mc["propInt" + p]);
delete mc["propInt" + p];
}
}
// the following are the symbols on my stage that put the equations to work::
mybutton.onRelease = function(){
mysymbol.easeProperty("_x",425,60,"easeOutBounce");
}
please any input will be much appreciated.
thanks
pete rodin
www.gro2.com
View Replies !
View Related
Controlling The Odds Of Math.floor(Math.random()
Hey,
Is there a way to set a random number in a array to showup maybe once a day. Or every 5000 views or loops, or something like that. I would love to be able to control the odds of a array. Cheers!
ActionScript Code:
var pic_array = new Array();
pic_array[0] = "images/1";
pic_array[1] = "images/2";
pic_array[2] = "images/3";
pic_array[3] = "images/4";
pic_array[4] = "images/5";
pic_array[5] = "images/6";
pic_array[6] = "images/7";
pic_array[7] = "images/8";
pic_array[8] = "images/9";
pic_array[9] = "images/10";
pic_array[10] = "images/11";
pic_array[11] = "images/12";
pic_array[12] = "images/13";
pic_array[13] = "images/14";
ranNum = Math.floor(Math.random()*pic_array.length);
holder_mc.loadMovie(pic_array[ranNum]+".jpg");
View Replies !
View Related
MATH: General Math Ratio Formula?
So I have these sets of values that correspond with other values. But the manufacturer only gave me sets by 5. I need to break it out for every integer. Here's what I got ...
Code:
20=35
25=54
30=78
35=106
40=138
45=175
50=216
55=261
60=310
My question is how do I develop a formula in Flash that can give me values for numbers not divisible by 5? Accuracy to the nth power, figuratively speaking, isn't crucial.
Big thanks,
Layne
View Replies !
View Related
Has Anyone Tested How Random Is The Math.Random() Function?
Just wondering whether anyone out there has ever run any tests on how random the Math.Random() function is as a random number generator?
I've been asked me to test it to prove that it is random and it seems a pointless waste of time, so I'm hoping to get evidence from elsewhere to convince the powers that be that there's no need to run the tests.
I've googled for it but come up with nothing so I'm hoping there might be someone out there who has already done the research?
View Replies !
View Related
Math.ceil Ll Math.floor
Hi there,
I have code to dynamictween my mc's.Works great.I only need the if statement to work so when my square reaches it's new size and position I can load in my content using a holder.Can someone help me out on this if statement.
and instead off scaling the holder,etc I want to control it's xy position when hitting but0,...
but0.onRelease = function()
{
_root.square.dynTween({duration:6, _y:[350, "In", 60], _yscale:[200, "out", 5], callback:"_root.action1"});
if (Math.ceil(this._dynTween) == Math.ceil(_root.square) || Math.floor(this._dynTween) == Math.floor(_root.square)) {
if (_root.squareTrigger == 1) {
if (_root.squareLoaded == undefined)
_root.square.squareHolder.loadMovie("content0.swf" );
_root.square.squareHolder._xscale = 33;
_root.square.squareHolder._yscale = 33;
_root.square.squareHolder._x += 35;
_root.square.squareHolder._y += 35;
_root.squareLoaded = 1;
}
_root.square.squareHolder._visible = true;
_root.squareTrigger = 1;
}
}
}
Grtz,
View Replies !
View Related
Math.atan && Math.atan2
Can someone please expplain to me what does Math.atan2 and Math.atan returns? I made a file to try to understand, but I cant figure out what they do!!!
I saw a lot o fo files wich use those actions, but still couldnt understand.
View Replies !
View Related
Var I = Math.round(Math.random()*1)
this should return either 1 or 0?
but it seems to be returning something else as well and i dont know what it is???
function startXPos() {
var i = Math.round(Math.random()*1);
_root.test1 = i;
_root.test2 = t;
return i;
}
i have this just after
if (startXPos() == 0) {
startX = -500;
endX = 750;
} else if (startXPos() == 1) {
startX = 750;
endX = -500;
} else {
startX = 0;
endX = 0;
}
_root.test3 = startX;
_root.test4 = endX;
As far as i am aware this should never return 0 for these two values but it does?!?
can someone please tell what im doing wrong here?
View Replies !
View Related
Math.round And Just Plain Math
Hi, I'm back with another question.
I want my exam to show a percentage at the end. I guess I'll concatenate a 'percent sign' at the end, but right now I'm having trouble with the math.
There are 13 questions. This is what I have:
score = Math.round(right/13*100);
The scores are coming out all wrong. Any ideas would be greatly appreciated.
Dan
View Replies !
View Related
Math.round() Or Math.random()
Is it better to use Math.round() or Math.random() reason I am asking I think I read somehwere that one was better. My problem is that I have a number of movie clips that are attach dynamically. They move randomly on the stage but for some reason they just stop moving randomly.. I think there was a post somehwere about that but cannot seem to find it.
View Replies !
View Related
Math Questions For The Math Experts :)
Hello there,
I am looking for a way to find a vector if i know one point and 1 angle...
Like i have A(x,y) and a vector starting from A(x,y) with an angle. I would like to know the position on a point X(x,y) that can be anywhere on that vector. I only know the coordinates of A and the angle. Possible?? I guess it has to be a function... ANy help would be appreciated
View Replies !
View Related
Cpu Power
I got a promblem:
on http://home.planetinternet.be/~cp78/test.html I made a site but when the main screen appears the site is very cpu intensive. on a pIII 800 it works fine but on PII's it's slow. Is there anybody who can solve this problem? maybe with actionscripts?
Jdzine
View Replies !
View Related
Wow, This Is Power
I want to share this dev protocol with this community. I think it represents a very powerful and flexible framework for deploying Flash based apps that require server interaction for data.
In my example, I am using the Tabbed Menu component that is freely available for use in the built in "templates" code that comes with MX. This component allows you to set a dataSource. I will be using server side scripts that will query a database and return the data to the component as XML.
In frame1 of my movie I have the following code:
#include "global.as"
stop();
/*
This .as file reads the contents of an XML file that contains all the global variables that I need to use throughout the entire application. Hence, it is loaded into the first frame of every fla in my app. After it has loaded its data, it contains a goToAndStop(2) command that takes the parent movie to the 2nd frame (usually where there will be components that are waiting for the global variables to be declared so that they can get their data from the server path, which is created via a global variable called "appServer"
*/
Then, in frame 2 of this file, I have this simple line of code:
myTabMenu.dataSource = ""+_global.appServer+"/getTabMenu."+_global.appServer+"";
/*
and that's it! The tabbed menu is given its data from the "asp/getTabMenu.asp" file that is represented in the line:
""+_global.appServer+"/getTabMenu."+_global.appServer+"";
since "global.appServer" maps to "asp" in this example.
*/
So, the power is that I can have one fla UI that is capable of talking to any app server setup, just by changing the "global.appServer" variable that is contained in the global.xml file.
ie, If I want to target my app to PHP, then I would create a folder of PHP scripts that grab data for my components and change my global.appServer to "PHP".
*/
What is left to do?
I need to establish a security mechanism. My thoughts are to take place code in the global.as that checks for a session cookie on the client before any further code is executed. Then, if the cookie is not valid, redirect to a login screen. My server scripts would also have to have access to the same cookie(is this possible in Flash?) so that they could not be backdoored by a hacker.
Any thoughts on this approach and suggestions on the security model I am considering are welcome.
View Replies !
View Related
Power Bar
I'm trying to figure out how to get a power bar...for a sports game eventually thta keeps going up and down once u activated it and stops when u press a button to determine the power of ur hit...
It probably has something to do with moving a mask or changing the height
thanks in advance
View Replies !
View Related
Power Bar Help
Hello, I'm working on a game that requires power bar to shoot at somthin'. It's like the longer u hold onto the spacebar, the stronger the weapon becomes. Can anyone help me on this?
I got this script from a friend. But i do not know how to change it to pressing space bar instead of using mouseup n mousedown.
with only a dynamic text box - instance name:txt
i = 0;
powerfunc = function(){
i++;
trace("power : " + i);
txt.text = i;
}
onMouseDown = function(){
pow = setInterval(powerfunc,1000/25);
}
onMouseUp = function(){
clearInterval(pow);
txt.text = "BOOOMM!! (" + i + ")";
i = 0;
}
and how to write the script if i wanna have weapon 1 to appear when i hold spacebar for 1 sec, weapon 2 for 2secs and weapon 3(the strongest) for 3 secs.
Hope ya ppl out there can help me out ^_^
Thanks alot in advance!
View Replies !
View Related
Power To A Power
*flash8
*actionscript2
I've been having problems with this math command
this._xscale = ((2.71828)^(-(this._x-120)/100)^2)+1;
this._yscale = this._xscale;
that it does as the symbols ._x approaches 120 it's scale increases.
When i graph out this function i get the results i want a nice bell shaped curve that increases at 120 to a value of 2 and sloops down to 1 around ~300.
after experimenting with flash it appears that it doesn't like power raised to a power such as 2^2^2 or 2^(2^2).
Anyone have any ideas?
if you would like to see what the graph looks like enter
(2.71828)^(-((x-120)/100)^2)+1
into Java Grapher
note: change Xmax to 500
View Replies !
View Related
The POWER Of AS3
yup as the title says
AS3 is better, I know that
it is more oop and thus is better for programming in some sort, yes I know that
it is oop and run on a new player and about 10x faster, really?
but honestly, I havent feel the power of AS3
is it really faster? people say yes, but i never encounter any formal experiment of proof that it is faster.
Is it better? I am learning AS3 and yes, to an extent it makes your codes twice longer, much less messier.
but overall, if AS3 is oop, like c++, why it cannot be very fast, like c++, and see people start creating half-life3 and DOOM with AS3?
View Replies !
View Related
Power Bar
O.K my brain isent working today so...
I want a power bar.
Like i press the space bar and it goes up a little but if i dont press it it will go down.
So if i get it up to half way it will go down if i dont keep pressing the space bar.
If you dont understand ill explin better.
Please please help
View Replies !
View Related
Power Bar Help
Hi All, I am making a game, based on the principles of curling...I have made a power bar, which for all intensive purposes it works! When the spacebar is depressed a “curved bar” is given a rotational value, this value is then used to move various objects, to create the illusion of movement within the game…here is an example of the code, with all the other if/else’s taken out.
Actionscript Code:
onClipEvent (load) {
this._rotation = 0;
speed = 1;
scale = 0;
pressed = false;
times_pressed = 0;
}
onClipEvent (keyDown) {
if (_root.player._y == 420) {
if (Key.getCode() == Key.SPACE) {
times_pressed += 1;
trace(times_pressed);
pressed = true;
import mx.transitions.easing.*;
import mx.transitions.Tween;
var player_movement:Tween = new Tween(_root.player, "_y", Strong.easeIn, 420, 300, 4, true);
}
} else {
}
}
onClipEvent (keyUp) {
if (Key.getCode() == Key.SPACE) {
pressed = false;
_root.player.gotoAndPlay(2);
var player_movement:Tween = new Tween(_root.player, "_alpha", Strong.easeIn, 100, 100, 1, true);
player_movement.onMotionFinished = function() {
_root.player.gotoAndPlay(5);
};
if (this._rotation<5) {
var floor_movement:Tween = new Tween(_root.camera_shoulders, "_y", Strong.easeOut, -1425, -75, 20, true);
var floor_movement:Tween = new Tween(_root.camera_head, "_y", Strong.easeOut, -1425, -75, 20, true);
var floor_movement:Tween = new Tween(_root.camera, "_y", Strong.easeOut, -1796, 4, 20, true);
var floor_position = _root.floor._y;
var floor_movement:Tween = new Tween(_root.floor, "_y", Strong.easeOut, 600, 2000, 20, true);
floor_movement.onMotionFinished = function() {
if (_root.player, hitTest(_root.floor.target_array.target_1, _root.floor.target_array.target_2, _root.floor.target_array.target_3, _root.floor.target_array.target_4)) {
} else {
_root.game_over._visible = true;
_root.gotoAndPlay(4);
}
onClipEvent (enterFrame) {
if (times_pressed == 1) {
if (Key.getCode() == Key.SPACE) {
if (pressed) {
if (this._rotation<100) {
this._rotation = this._rotation+speed;
}
// end if
if (this._rotation>100) {
return;
}
scale = this._rotation;
}
}
} else {
this._rotation = 0;
}
}
My problem is that if the space bar is pressed multiple times, the game freaks out, which is understandable because it running code in other movie clips over and over. What I would like to find out is how/if I can write an “if/else” statement, that identifies whether the space bar has been released and when that happens disable everything else. If anyone could point me in the right direction I would be forever in your debt. Thanks Jono
View Replies !
View Related
The Power
ok basicly i want to know if you can have php send var to flash to make dynamic flash sites
and for any php guys out there i want to make a mmorpg a vary simple one using php but i dont know how to tell all broswers to update when say guy number 2 clicks a action button so that his/her turn is over or how to test to see if a person is still veiwing the page
View Replies !
View Related
|