ActionScript 3.0 :: Collision - Why Variable Not Changing

Jun 21, 2011

I'm working on code for collision. My question isn't about how to make it work. I have a bizarre problem with a variable that is NOT changing when I want it to.

ActionScript Code:
public function movement(e:KeyboardEvent){
var yesobject:Number = 0;
var thecode:Number = e.keyCode;
if(thecode == Keyboard.LEFT){
[Code] .....

I've had this problem before. the trace(); commands outputs so why does the variable not change even though it's in the same if statement?

View 1 Replies


Similar Posts:


Flash :: Changing The Direction Of A Ball On Collision Base On Speed

Jan 4, 2010

I am creating a ping pong game. And I want to create the ability to control the direction of the ball based on the impact on the paddle. If the ball is coming down at vy = 4; vx = 4;

and the paddle is moving to the left at vx = -5; I want the ball to slightly change its course depending on how fast the paddle is moving. It would probably reduce the balls vx speed on collision, therefore making the ball move more straight (close to the Y axis) when it is moving back up.

I figure the solution for probably doing this would be to measure how fast the paddle is going. My problem is the paddle is controlled by the mouse and has no certain speed. I am trying to figure out how I can measure the speed of my mouse traveling on the x axis.

I am probably going to create a timer that fires every few seconds to determine where the mouse was and where it is at. figure the difference and that will be the speed

View 3 Replies

Collision Detection Incorrectly Detecting Collision?

Oct 16, 2009

In my file (AS2), I have a small square at the middle of the page. Diagonally to the right, I have a vertical wall which is a rectangle. Pasted inside my small square, I have the code:

onClipEvent(enterFrame) {
if (Key.isDown(Key.RIGHT)) {
if (this.hitTest(Wall._x, Wall._y, false))  _x =

[code]......

View 1 Replies

ActionScript 3.0 :: Changing Variable In Other Mc

May 3, 2010

I have a movieclip called 'Sitecontent'. Within this movieclip I'm using a variable to determine on which page my website is. The pages are seperate movieclips which I load throug addchild.When I load (for example) page 1, it start playing a openingAnimation which stops at a specific frame. After it stopped, I want to update my variable in the SiteContent mc. How to acces the variable from a other movieclip?

View 4 Replies

Variable Changing But Then Resetting

May 25, 2011

I'm very new to Flash, but I have been learning loads and getting some good results so far. Browsing these forums has been a massive help. However today I have hit a problem in what should be almost the simplest line of code I know how to write (variable = x), and could do with some advice. I have a simple program containing a button which will change a variable when pressed. There is also a text-box that will output that variable. However when I press the button, the variable will change, but then immediately revert to it's previous value.

[Code]...

View 3 Replies

ActionScript 2.0 :: Changing Of A Value Through A Variable?

Jun 16, 2010

I have used setProperty up till now, and it have met my needs needs so far.However, this one thing it cannot help with:

I have several different textfields all within different movieclips. I want to only change the content of only one of these textfields, however which textfield is changing all the time. Therefore the path of the textfield that needs changing has been put into a variable. Now I need to change the text of this textfield by using the variable(tempRevis1). i placed the path of the textfield within a variable:

_root.tempRevis1 = "_root.level1a_mc.AIRB237_mc.textMe1_txt";

Now this is what I hoped to have done:

setProperty(_root.tempRevis1, text, newTextValue);

View 0 Replies

ActionScript 2.0 :: Changing Value Of Variable In Mc From Another Swf?

Mar 29, 2004

I have one swf file that containes a mc using an easing function to move an arrow around.That mc has the instance named myruler. The arrow moves based on the value of a variable named "y". This swf also has a mc that I use as a container to load movies into.The movies that are loaded into the container mc have buttons that I would like to use to change the value of the variable "y" in the movie clip named myruler found in my base swf. Did that make sense? The code I'm trying to use on those buttons goes as follows:

on(release){
_root.myruler.y = 300;
}

The my ruler movie is in the swf that loads the swf with these buttons. So how do I point to that original swf.myruler.y?

View 2 Replies

ActionScript 2.0 :: Changing The Value Of My Variable?

Apr 29, 2003

I�m having some trouble with changing the value of my variable.I declare my variable in the first frame of the _root timeline.

currentSlide = 1;

When the _root movie plays it stops on a movie clip that contains four sub movie clips each is labelled sequentially( slide1, slide2, slide3 and slide4).I would like to know how to increase the value of my variable by 1 each time it progresses to the next slide. I can�t seem to get the variable currentSlide to change its value.

View 1 Replies

Changing The Value Of A Variable By Pressing Keys?

Jun 18, 2010

There is probably a better way to do what I'm trying to do, but I simply want to make a variable change its value when I press the arrows keys. For example if I wanted to cycle through weapons, if weapon=0 then the character is holding a certain weapon, then I press the down arrow key and weapon=1 and if weapon=1 the character is holding another weapon. And if I press up weapon=0 again so he's holding the first weapon again. And say there's 8 weapons, if weapon>8 then weapon=0 again so its a cycle. I tried arrow key functions and all they worked for was making a symbol move. I think I knew how to do this stuff in gamemker pretty well but Flash is very different.

View 2 Replies

ActionScript 2.0 :: Can't Add With A Constantly Changing Variable

Jul 10, 2010

I am making a game in flash, that uses several resources to build different buildings, that help you to gain resources, etc. I'm trying to make it so that the more "_global.food" you have, the faster your resources will go up. I have it so that the variable "_global.woodBoostMeter" goes up as fast as "_global.woodBoostSpeed" and when it reaches 500, it gives you 1 wood. I want it so that "_global.woodBoostSpeed" is modified by "_global.food" divided by whatever 200 is. (So that you will get resources faster for the more food you have)

Here's the code I'm using:

Quote:

_global.woodBoostMeter =0
_global.woodBoostSpeed = _global.food / 200
_global.woodBoostObtainRate =1

[Code]....

I think the problem seems to be with the "_global.woodBoostSpeed = _global.food / 200". it doesnt go up slow like it should, since "_global.food" starts out at like 200.

View 3 Replies

ActionScript 3.0 :: Swf In IE 7 Not Changing Value When Variable Value In Flashvar Changes

Sep 3, 2010

Below is decription of the file

1. I have a flash file which is loading php variable through flash vars.
2. The flash var variable contains the .txt filename in which data is kept.
3. When I open the php page the swf loads with variable having .txt filename and value containing swf path.
4. I have created timer in flash which check for change of value.
5. When value changes the other flash file loads.
6. All this works fine in all browsers except IE 7

View 1 Replies

ActionScript 2.0 :: Flash Changing A Php Variable?

Feb 16, 2009

im making a achievements page and i want flash to change a variable to 1 how do i do it

View 9 Replies

ActionScript 2.0 :: Changing Scene With Variable?

Jan 11, 2012

trying to make my first game using flash. I have done the main thing, setup a character which can be moved by the user to catch some falling balls. Every time a ball is caught, the score goes up by 1. To count and display the score, i have used a number variable called "caught" defined in the main timeline with initial value 0. The main timeline has only 1 frame and stopped by codes in the level "action". The "caught" variable is used in many movieclips in the scene and its value changes as the character catches the ball.

Now when the score is 10, i want to go to a new scene that shows a "congratulation you win" animation. For this, I have wrote the following code in the movieclip of the main character -

onClipEvent (enterFrame) {
if (_root.caught == 10) {
gotoAndPlay ("Scene 2",1);
}
}

But this does not work. The score goes upto 10 and then beyond 10.Is there anyway I can use the value of a number variable to determine when to play a particular scene?

View 4 Replies

Actionscript 3.0 :: Changing A String Into A Variable Name?

Jul 9, 2010

To avoid a large segment of code I've set up button names that correspond with movieclips that are located in my library and exported for use with the code. I want to replace the movieclip currently on stage with another movieclip from the library depending on which button you click on. The code works fine, I'm achieving all the values I want, except for the fact that since the variables in the function are strings it gives me a coercion error saying that they're strings and not objects.

Here's the code:
Code: Select all// Holder
var holder:MovieClip = new MovieClip();
holder.x = 122;

[Code].....

View 4 Replies

ActionScript 2.0 :: Changing A Variable After A Certain Time?

Jun 5, 2006

I would like to have a button that when clicked changes a variable for 30 seconds and then changes it back. For example:

[Code]...

View 1 Replies

ActionScript 2.0 :: 'For' Loop Not Changing ._y Variable?

Jul 7, 2004

I have the following code:

PHP Code:

on (release) {
cNum = cNum+1;
for (b=1; b<8; b++) {
trace(["box"+b]);
["btn"+b]._y = ["btn"+b]._y+25;

[code]....

on release, the objects labeled btn1, txt1, box1, btn2..... should all be shifting 25pxs. It doesnt do anything.

View 5 Replies

ActionScript 3.0 :: Accessing / Changing Variable Across Frames

Sep 8, 2009

Its a simple adding "game" where 2 numbers are randomly generated and you have to input what you think the answer is (userAnswer). Then it adds the two numbers it just generated to produce correctAnswer, and checks it against userAnswer. When you hit the check answer button, it moves the the score dialog frame and says whether its correct or not. But I am having 2 problems I think - 1 - I can't get the input textfield to assign the typed-in value to userAnswer (I'm trying userAnswer = inputAnswer.text; )  and - 2 - the second frame that has the score and "Correct!" / "Incorrect!" dialog can't seem to access any variables from the first frame. I've tried using two layers and keeping the variables on the second layer that spans both frames, but then the functions in the frames that you actually see can't change the variable to update it with the user's input.

View 3 Replies

ActionScript 1/2 :: Changing The Value Of A Variable In Movieclip From Scene?

Nov 13, 2009

i have a probleme changing the value of a variable in movieclip from my scene. i explain: I have combobox on my scene containing categories,and in the scene i load an xml file containing links to php files that work with the combobox.Also on the scene i have a movieclip "filmstrip", inside this movieclip on the first frame i have a script loading the php file selected in the scene. i use a load() function with a variable "theUrl" inside like this : T.load(theUrl);.In my scene i want to change the value of "theUrl" inside the movieClip filmstrip. I tried filmstrip.theUrl = url; But it doesnt work
 
the xml file
<?xml version="1.0" encoding="ISO-8859-1"?>
<slideshow>[code]....

View 7 Replies

ActionScript 2.0 :: Retrieve A Value From A Variable Who's Name Is Dynamically Changing?

Feb 13, 2009

I have a problem with setting dynamic variables. How do I retrieve a value from a variable who's name is dynamically changing?

Example:

variable1 = 1,
set variable2 = variableList(variable1);

so...

if variable1 = 5,
then variable2 = variableList5

How do I do that?

View 0 Replies

ActionScript 3.0 :: Changing Variable From Inside Of Function?

Jan 9, 2010

I have a code, it is below. And i have two vars: coordx and coordy they both are 0 but when up button is pressed, coordx should change into 1 x remain 0 just like map scrolling and if pressed down it should return to default position, but instead of that variables keeps reseting and it starts from beggining. Here is the code:

ActionScript Code:
var coordx:Number = 0;
var coordy:Number = 0;[code].......

View 3 Replies

ActionScript 3.0 :: Changing The Html <title> Tag Through As3 Variable And Xml?

Sep 3, 2010

I have a website that I have to alter the <title> tag that shows up in the browser as the sites name through using Flash as3 and xml. I was wondering how to access the <title> tag so that I can create a variable in flash, that retrieves whatever string is within the <title> tag of the current xml document that is being accessed? All pages need to have the same title, so it doesn't need to be too complicated, I just need to be able to alter the tag through xml and as3.

View 1 Replies

ActionScript 2.0 :: Dynamically Changing Variable Calling?

Jan 27, 2011

Beginner question here. Basically I have the following code:

if (_root.obj1 == 1) {
n = _root.invArray.length;
_root.obje1._y = _root.inve(n)._y;

[code].....

View 1 Replies

ActionScript 2.0 :: Changing A String Variable To A Number?

Sep 24, 2009

I want to add some input fields together and can't seem to do it..

test_btn.onRelease=function(){
total = Number(input1) + Number(input2);
}

In the total field I get 'NaN'

View 4 Replies

Data Integration :: Storing And Changing An External Variable?

May 4, 2007

I need to hold a couple of variables in an outside file that can be incremented by user activity -- not just during one interaction with the swf, but with every one.I have no problems with using loadVars and I get the loadandsend process; it is just that I have
no background in cgi or asp for holding the variable and being able to update it.I know I cannot write to a txt file -- that is what I have been using thus far with loadVars for importing values, but this will not help me here. I know it should be a fairly simple script -- I also know I ought to pick up php, but for the moment -- until a greater amount of time comes my way -- I turn to you.

View 3 Replies

ActionScript 1/2 :: Changing The Color Of A Movieclip With A Variable Sent From Javascript?

Jan 11, 2010

I'm trying to change the colour of a movieclip.I want to send a variable from Javascript within the html that the swf will be embeded in.I'm not quite sure where to start with this but this is my code:
 
[code]...

View 3 Replies

ActionScript 3.0 :: Variable Is Changing Back To Initial State

Jun 30, 2010

I set a variable var currentPage:String = "b1"; When I click a button, the click should change the variable currentPage to the event.currentTarget.name and it does

[Code]....

View 9 Replies

ActionScript 3.0 :: Changing A Variable In A Class From A Movie Clip On The Stage

Jan 14, 2012

I'm trying to change a varialbe in a seperate class from inside a movieclip that I have on the stage in the timeline, but the variable I'm trying to change keeps coming up as null instead of what I am trying to change it to. How is this usually done?

View 6 Replies

ActionScript 3.0 :: Flash Changing Variable Values Inside Of An Array?

Aug 28, 2011

I am trying to create a dialogue system for a game that references lines of dialogue to be displayed from an array.Example:

var myArray:Array = new Array("My name is David.","I am a noob at actionscript.");

This all works fine, but what I really want to do is have the name "David" be a variable so that the user can change. The issue is that the array seems to convert any string variables into their string value so when they are referenced they only appear as the initial value of the variable.

Example:
var myName:String = "Empty";
var myArray:Array = new Array("My name is "+myName+".","I am a noob at actionscript.");
//user does something to change the variable myName

[code]....

Output: My name is Empty.,I am a noob at actionscript.When what I want is for it to say: My name is Jones.

View 4 Replies

ActionScript 3.0 :: Menu Buttons - Changing Variable Loader On Main Timeline

Oct 22, 2008

I am creating a very basic menu. My project consists of a main file that then calls other swf's to fill in the rest of the content. My main timeline is this. There is an preloader which hasn't been built yet, a intro section that is two movie clips (one loads the layout, one fades in my buttons). Then when all this loads, I load the first swf. My difficulty is that I am trying to get my buttons, which are held in mc_buttons, to change the variable myLoader on the main timeline. So when you click on a button, it swaps in a different swf for the current loaded one. I have tried calling the following code attached below.

My error is:
"1119: Access of possibly undefined property myLoader through a reference with static type flash.display:DisplayObjectContainer."
Now, if I define the myLoader variable in the mc_buttons and do an addchild() there, I get the correct content, it just is on top of the old content which isn't what I want...

View 12 Replies

ActionScript 3.0 :: Changing Variable Values In One Class From Another Class?

Sep 7, 2010

I have two document classes. One is Main.as the other is Step2.as. I want to declare a public variable in Main.as then need to give it a value from Step2.as. That value will later be used in my next Document class Step3.as How would I write the code that gives the value in my Step2.as and then how would I write the code that retrieves the value in my Step3.as?

Note I can't import my Step2/ or Step3 document class into my Main.as.

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved