ActionScript 3.0 :: Setting Variables For Timer Function

Jan 1, 2011

I'm making an animation of calculating a projectile motion with air resistance based on Python code from [URL]. I include the relevant portions of codes as follow. I'm not familiar of the vector object in AS3 so I translate them into variables as follow:

Actionscript Code:
//timer related variablesvar
fps:uint = stage.frameRate;var interval:Number = 1/fps;
var myTimerYes:Timer = new Timer(1000/fps);
//air resistance timermyTimerYes.addEventListener(TimerEvent.TIMER, startSimYes);
function startSimYes(e:TimerEvent):void{
[Code] .....

The timer activates when the user clicks the start button. The start buttons set the variables for the timer function. The variables are created at the start of the actionscript file. The code of the start button is:

Actionscript Code:
start_btn.addEventListener(MouseEvent.CLICK, goTimer);
function goTimer(e:MouseEvent):void{m = int(airText_mc.mass_txt.text);
A = int(airText_mc.refA_txt.text);
Cd = int(airText_mc.Cd_txt.text);
rho = int(airText_mc.density_txt.text);
[Code] .....

The result I get is the aX = 0 all the time, even after the update I specified in the timer codes. I can't understand what's wrong with the code, it's supposed to be updating every time the timer goes on.

View 1 Replies


Similar Posts:


ActionScript 2.0 :: Countdown Timer - Setting Specific Date?

May 16, 2004

I am having some problem understanding the codings for the countdown timer tutorial. [URL]. How do I set a specific date of, maybe a date which is 2 years later or so?

View 3 Replies

ActionScript 3.0 :: Turning A MouseClick Function Into A TIMER Function?

Oct 30, 2009

I had a function that occured on mouseclick called go_out. I want this function to occur when the timer fires after 5 seconds. After the 5 secons I receive this error:

TypeError: Error #1034: Type Coercion failed: cannot convert flash.utils::Timer@3fe4561 to flash.display.MovieClip.
at home_flash_fla::MainTimeline/go_out()
at flash.utils::Timer/flash.utils:Timer::_timerDispatch()

[code]....

View 1 Replies

Flash :: Use Variables To Set Timer

Apr 13, 2010

How can I use variables to set my timer? I want to control delay and repeat as variable. My output acts as if there is nothing set in the timer.[code]

View 1 Replies

Flash :: Use Variables To Set Timer?

Jan 20, 2003

How can I use variables to set my timer? I want to control delay and repeat as variable.My output acts as if there is nothing set in the timer.Not working variables

var timer:Timer = new Timer(delay,repeat);
var delay:uint = 100;
var repeat:uint = 60;

[code].....

View 3 Replies

ActionScript 2.0 :: (MX 04 Pro) Setting Variables For An Mc?

Dec 12, 2004

What i need is to set some values for a few movie clips and then use them all at once. Eg, i'll have 5 mcs in my movie, each with either variable = 1 or variable = 2 etc assigned to each of them differently. Then i want to run some code kinda like

if (the variable on mc_one < 4){
do some stuff
}

Im not sure if im going about it the right way, but i think its fairly obvious what im trying to do

View 5 Replies

ActionScript 2.0 :: (MX 04 Pro) Setting Variables For A Mc?

Dec 12, 2004

What i need is to set some values for a few movie clips and then use them all at once. Eg, i'll have 5 mcs in my movie, each with either variable = 1 or variable = 2 etc assigned to each of them differently. Then i want to run some code kinda like

if (the variable on mc_one < 4){
do some stuff
}

View 5 Replies

ActionScript 2.0 :: [F8] Setting Variables From External Txt?

Feb 20, 2009

I am trying to control some of the global variables in my script through an external text file.I have a variable called "_global.scrollOrNot", which determines whether I want flash to use the text window with a scroll-bar or the one without a scroll-bar. I am trying to control that through an external text-file called "ScrollCommand.txt". Here is my code:

the external txt states:

&sb1WindowScroll=yes
frame1:
_global.scrollOrNot;

[code]....

this is were I have a problem. It will always choose "MCtextFeldSB1noscroll". I have tested the whole thing with other variables, which were not changed by any LoadVars function and it works just fine then. As soon as I change the variable using the LoadVars function it will not work any more.

View 2 Replies

ActionScript 3.0 :: Setting Variables In A FOR Loop?

Apr 23, 2009

I used to dynamically set some variables using a FOR loop kinda like so PHP Code:

//Sorry, from memory
var possibleValues:Array = ["red","green","blue","yellow"];
for (i=0;i<possibleValues._length;i++){
_root["colorNumber"+i] = possibleValues[i];
}

Second question, using that code in a function would set the variables at the root level making them available throughout the timeline. Without "_root" how do I get that variable available to everything?

View 7 Replies

ActionScript 3.0 :: Setting Variables In Different Classes?

Aug 13, 2009

I am trying to set the variable to classes in the loader like this

loaded_swf.content.classname.code = "AS3";

But that wont work for some reason?

View 1 Replies

Flash8 :: Setting Up Variables In Different Levels?

Dec 25, 2010

Actionscript Code:
if (Key.isDown(attack2Key)&&shot2reload == 0) { for (i=1; i<2+1; i++) { shot2++; shot2reload = 30 var newname =

[code].....

View 1 Replies

Actionscript 3 :: Setting Flash Variables Not From VB?

Oct 9, 2011

I'm trying to pass flash variables to SWF file from my VB application.It worked in AS 2.0 using:SetVariable method of ShockwaveFlash object but it doesnt' work in AS 3.0.

View 2 Replies

ActionScript 3.0 :: Setting Variables To Parent?

Feb 8, 2010

I have loaded a movie clip into the "root" from the library using addChild. Inside this loaded movieclip, I need to populate a variable, but this variable is in the main time. The value must be sent when the user click on the clip that has been loaded. I have tried the following using a mouse click event listener.

MovieClip(this.parent).currentScore = 20;

but it won't work.

View 6 Replies

ActionScript 2.0 :: Setting And Then Checking Against Variables?

Jun 14, 2005

how I could somehow create an "if then" statement with variables for my website.

Basically I just want to have a button that checks for a certain variable when you click it (I want it to check if a movie, lets call it "movie1" is already loaded). If it comes back false, then movie1 and movie2 both get loaded.

This way, after movie1 is loaded for the first time, it wont be loaded again. Basically, movie1 is just my background for all my other movies. So clicking button1 for the first time would load movie1 and movie2. Clicking button2 AFTER button1 was clicked would only load movie3.

View 1 Replies

ActionScript 2.0 :: Setting Variables With Checkbox?

Dec 18, 2009

let's say 30. they are nothing less than colors of different shades/tints. firstly i need to randomize the loading of one of those movieclips when i push a button and secondly i want to control that randomization with a couple of check boxes. let's say i have a first row of checkboxes which control the particular color that is going to beoaded(red,green,yellow,blue) and a second row that controls the shade(extremely dark,very dark,dark,light dark,neutral,light bright,bright,very bright,extremely bright). for instance if i choose yellow and green from the first row of check boxes and neutral and light from the second row i want the movie to load randomly yellow and green movieclips with those particular shades(neutral and light).

View 2 Replies

Flex :: Setting Variables During Component Initialization

Oct 25, 2010

I am loading a component which makes a HTTPService call to get data that will then be used to set certain variables in the component. I make the HTTPService call in an init() function (for the initialization event) and then set the variables according to the data received in the HTTPService result handler. However, the variables are still null at both the initialize stage and at the creationComplete stage. If I try and read the variables in a creationComp() function (for the creationComplete event), those variables are still null. Is this correct?

I guess I don't understand the flex initialization cycle very well. When are those variables actually set and available to be used? I need to manipulate those variables automatically after the component loads. Is there an event that comes after creationComplete that is appropriate or some other way to approach this? I am using Flex 3.

View 2 Replies

ActionScript 3.0 :: Setting Multiple Variables Dynamically?

Nov 10, 2009

I've automated a lot of my script, but cannot automate the very beginning where one sets the variables. I have the following script that I'd like to put in a "for" loop :

private var aliPlane1:Plane3D;
private var aliPlane2:Plane3D;
private var aliPlane3:Plane3D;

[code]......

View 9 Replies

ActionScript 2.0 :: Setting Flash Variables From Javascript

Jul 7, 2004

Does anyone know the correct syntax for setting a variable on _root using Javascript?

The Macromedia site says:

<!-- javascript
movie.SetVariable("/:varname", "varvalue");

However, this notation is quite old. I haven't been able to get it to work.

View 1 Replies

ActionScript 2.0 :: Using Set And Eval Functions Setting Variables?

May 12, 2006

I'm having problems in setting three variables using a for loop and then passing these variables to my function. I think it's something to do with the set function I'm using, because my colorFadeTo function claims it's being passed an undefined variable.

Code:
for (var i=0; i<circles.length; i++) {
var current = circles[i];

[code].....

View 1 Replies

ActionScript 2.0 :: Setting Variables In A Loaded Movie

May 22, 2003

Can anyone tell me how to set variables in a child movie from a parent movie?[code]but it doesn't work!txtChild is a variable in the child.swf movie. (A dynamic text field with instance name "ChildText")

View 1 Replies

ActionScript 3.0 :: Setting Global Variables Within MovieClips

Dec 9, 2010

I'm working on a Flash game (AS3) and have come to a point where I need to change the value of a global boolean variable from within a movieclip. After searching all over I have yet to find a solution. Essentially, the problem is that I have a movieclip that contains a section of animation for my game. When this movieclip is told to begin its animation, it checks these global variables to see which of six animations to play. When it finishes any of these animations, I need to set the associated variable and increase the score.

View 2 Replies

ActionScript 2.0 :: Setting Flash Variables From Javascript?

Jul 7, 2004

Does anyone know the correct syntax for setting a variable on _root using Javascript? The Macromedia site says:

<!-- javascript
movie.SetVariable("/:varname", "varvalue");

However, this notation is quite old. I haven't been able to get it to work.

View 1 Replies

ActionScript 2.0 :: Setting Variables On Press And Release?

Oct 14, 2002

I am trying to create a scrolling text section for a cd-rom I am creating.I have created buttons for the scroll up and scroll down and so far all I am able to get is a click click click to scroll up and down 1 line at a time.Would prefer to make a loop so when you hold down the button it "scrolls" until you release.Have had no luck in setting variables on press and release.

View 6 Replies

ActionScript 3.0 :: Make The Timer Fire All Variables In Strict Sequence?

Mar 17, 2010

I'm looking for will all happen in about two or three seconds. I'm re-building my own website using AS3 package classes. When the API loads I want everything to appear in sequence from invisible to visible. First the logo, a few lines drawing themselves, then all the navigation buttons at the top appearing in a quick-fire horizontal row, then the content rolls in, etc. I want strict, accurate control over about two or three seconds, of how and when everything on stage goes from invisible to visible in a quick-fire sequence. I know it can all be done with several timers for each alpha going from 0 to 1. But can all the variables going from alpha 0 to 1 be bundled into an Array? And the Array fired by ONLY ONE Timer using a For Loop? Or am I just barking up the wrong tree? Should I just use a bunch of Timers? I want to avoid a Tween because I want very accurate control of the quick-fire invisible to visible effect. And I want it to be easy to change later. Can this effect be done by ONLY ONE Timer rather than several Timers? And if it can, how do I make the timer fire all variables in strict sequence? Do I use an Array with a For Loop? Or something else? I've been looking for a couple of days but still haven't found anything close.

View 2 Replies

Actionscript 3 :: Setting Multiple Variables Of An Object In An Array Possible?

Jan 25, 2010

Right now, I have many MovieClips's in my array. I want to update all the alpha values of the MovieClips in my array. Right now, I am using a for loop but this is not the fastest way to do it.

View 3 Replies

Flash :: Actionscript 3 - Setting Color Of Variables In A String

Nov 29, 2011

I'm pretty new to Flash and I'm struggling with defining the text-color of a variable within a compound String. Here's what I have so far:

[Code]...

View 1 Replies

ActionScript 2.0 :: Setting Variables Using Input Text Boxes?

Oct 27, 2004

Setting variables. Have a look at the file. Current height and width are both set at 200. I dont think i got the scripting right, or it may be in the wrong place.

View 4 Replies

ActionScript 3.0 :: Setting Flash To Demand Type On Variables?

Dec 2, 2009

Being a code purist, I always set Flash to demand that I declare all variables/functions with a type. Like this:var myVar1:int = 14; //Okvar myVar2 = 18; //Compiler ERRORMy problem is that I just reinstalled my computer (including Flash) but I've forgotten where I do this setting. Anyone here with a better memory than me?

View 4 Replies

ActionScript 2.0 :: [CS3] Setting Variables Through Button Press For Scripted Animation?

Jun 3, 2009

getting the following working:

Code:
stop();
import mx.transitions.Tween;
import mx.transitions.easing.*;

[code].....

What's supposed to happen is when you click button "go_0", the object "square" will animate moving down.

View 2 Replies

ActionScript 2.0 :: For(); How To Add A Timer Function

Aug 22, 2006

I have a for() statement performing a loop that attaches a movieclip each time it's executed. The variable "maximumBloodBurst" defines how many times the loop cycles (the amount of movieclips to produce).Here's the script:

Code:
createBloodCells = function () {
var g:Number;

[code].....

View 12 Replies







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