ActionScript 2.0 :: Using Time As A Variable?
Oct 29, 2005
I've just taken and slightly modified a tutorial from actionscript.org. IT explained how to show the time in flash. I completed it and modified it to just show me the hours, minutes and seconds. I'm using it for a site I'm workin on. It was a tutorial for mx though, so I made a seperate swf an had it load into my site's mian swf using the loadMovie script. Now I want to take the time experiance and push it farther. I want to know how I can take the time from the loaded swf (which has a dynamic textbox ofcourse) and use it as a variable. I want to basically two things:
how to get the variable from a loaded swf
How to have a variable control the tint of one MC and the rotation of another.
I'm having a MC fill the whole screen and tint to represent the darkness/brightness of the day and I'm going to have a sun/moon MC rotate past the screen.
View 3 Replies
Similar Posts:
May 26, 2010
I want to have a variable which changes from time to time based on certain parameters.
For Example:
var poop:Number;
onEnterFrame = function(){if(donkey==1){poop = 2;}
if(donkey==2){poop = 5;}
}
But it doesn't work. I can't seem to change the value of "poop" with code. It only accepts a value that I place, ex. var poop = 2, but that doesn't let me change it.
View 2 Replies
Apr 11, 2006
ok so this is probably really easy. But how do you add a random end to a variable like say
Code:
for(i=0; i<5; i++) {
d = i;
}
but I want the variable not to be d but it create a new variable each time so I can
[Code]...
View 3 Replies
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
Jan 7, 2010
how to set variable time for a single timer, like I first setup this timer:
private function timer():void{
var randomTimer:Timer=new Timer(time,0);
randomTimer.addEventListener("timer", somefunction);
[Code].....
So how can I influence the time inside the timer? Do I create a global timer, remove the listener and recall the timer function? Would this work since the timer has already been declared, I a re-declare a timer?
View 1 Replies
Dec 13, 2011
I'm making an Elder Scrolls type game and I want my enemies to hurt me after a certain time.So pretend like 5 seconds after they come on the stage they would take 5 hp off me.Then when one of the enemies die it stops until another enemy comes on the stage then it counts how long its been on the stage.This is what I have so far:
Actionscript Code:
var tmr1:Timer=new Timer(2800); var tmr2:Timer=new Timer(5000);
[code]...
View 1 Replies
Apr 8, 2010
I've migrated from AS1 to AS3, and boy, a lot has changed... Anyhow, to learn and understand AS3, I'm modifying a slideshow I found through thetechlabs. I want it to play SWF as well as JPG. These files are passed through an XML file. I added an element called <delaytime> to the XML file that replaces the standard time a photo is shown in the slideshow.
I modified the onSlideFadeIn() function as follows:
function onSlideFadeIn():void { slideTimer.removeEventListener(TimerEvent.TIMER, nextSlide); slideTimer = new Timer(xmlSlideshow..file[intCurrentSlide].@time); slideTimer.addEventListener(TimerEvent.TIMER, nextSlide); if(bolPlaying && !slideTimer.running) slideTimer.start();}
However, when I run it, I get this error message:
## [Tweener] Error: [object Sprite] raised an error while executing the 'onComplete'handler. TypeError: Error #1010: A term is undefined and has no properties.at slideshow_fla::MainTimeline/onSlideFadeIn()at Function/http://adobe.com/AS3/2006/builtin::apply()at caurina.transitions::Tweener$/::updateTweenByIndex()at caurina.transitions::Tweener$/::updateTweens()at caurina.transitions::Tweener$/onEnterFrame()
It stops at the first picture of my slideshow. When I push the 'next' button it displays the next pic, but I get the same error message again.When I comment out this line:
slideTimer = new Timer(xmlSlideshow..file[intCurrentSlide].@time);
the slideshow runs OK, but without the delaytime specified in the XML file.
[code]....
View 14 Replies
Sep 14, 2010
I am trying to use the "define" mxmlc compiler option to embed compile-time constants into my SWF files.
<mxmlc ...>
<define name="NAMES::PluginCompileTime" value="Hello World!"/>
</mxmlc>
I can access this variable if I "hardcode" it into my codebase, as so: public static const PLUGIN_COMPILED_TIME:String = NAMES::PluginCompileTime; However, I would like to be able to do this at runtime using something like getDefinitionByName(): var value:* = flash.utils.getDefinitionByName("NAMES::PluginCompileTime"); This throws the following error: ReferenceError: Error #1065: Variable PluginCompileTime is not defined. Does anyone know of a way to accomplish loading a compile-time constant in a namespace at runtime?
View 1 Replies
May 3, 2010
Basically im making a completely flash/as3 website.I have a transition effect which lasts 2 second which is triggered every time some buttons are clicked.
My problem... The transition effect includes variables for x,y, size etc etc and if the button is clicked again inside these 2 seconds these values have not reset to their starting values and the effect gets screwed up.
I know it is unlikely that a user will click another page within the 2 second bracket, but they may double click the button by accident or decide quickly they want another section (and be a fast clicker ) etc.Is there anyway to 'lock' these variables until my effect has completed ?
View 3 Replies
Oct 7, 2008
I've been trying to create a script that pulls the current time and turns it into a variable, the problem is the variable keeps updating as the time changes, where as I need it to remain static as the time that is was when the variable was first created...it's just a simple:
Code:
var theTime = today.getTime();
View 2 Replies
Oct 22, 2002
Is there a simple way to create a variable that contains the date & time such as:
October 23, 2002 4:45 pm
View 12 Replies
Jan 24, 2010
Basically, I wanted to 'save' the time thats been recorded in each of the 5 'games', so at the end there is a 'scores' page, with your times for each of the games.
I have managed to get the timer working for the games itself, but cannot find / work a method which saves them to the last frame?
I thought possibly converting the 'elapsed_time' into a different var (t1,t2 etc..) for each of the games? - doesn't seem to work timer_not_saving.fla
View 1 Replies
Feb 28, 2012
When the button is first pressed, I can see in my debugger the data LocalID has a value, but why doesn't it write to the _root.PrimaryID until I press the button a second time?
submit1.onPress = function(){
getDatax.UniqID=UID;//Long string version of ID
getDatax.sendAndLoad("GetID.cfm", getDatax, "POST") ;
getDatax = new LoadVars()
getDatax.onLoad = function(){
if(this.writing=="Acquired") {
_root.PrimaryID=this.LocalID;
}}}
View 1 Replies
Feb 13, 2011
I have a problem with listed code that every time I click on btn1 the variable (num) will be initialize to 1. so what is the best practice in my case to initialize the variable (num) for only one time when the flash loaded.
stop();
var num:Number =1;
function b1(event:MouseEvent):void[code].........
View 1 Replies
Feb 4, 2009
I pass an image ByteArray to PHP.Along with the image ByteArray I would also like to pass a single string variable to the same PHP script.[code]
View 2 Replies
Dec 8, 2010
I've been working at this for hours and still no luck what I'm trying to create to have 8 buttons on one frame leading to different scene each. In the scene different things happen and then eventually it leads you back to the first scene without the pressed button there anymoreFirst I tried this:I've been try to do this for a while now and seem to be really stuckIn my movie I have 2 scenes in the first one there is a button that is flashing using tween and alpha. in this scene I'm using this code:
stop();
btn1.play();
btn1.onPress = function()
[code].....
View 5 Replies
Dec 15, 2010
working on my website and I'm trying to figureout how to go about creating a script the moves an item based on system time. Basically I need a Sun Mclip to move based on time, to create a sunrise and sunset based on the actual sunset and sunrise time.
View 1 Replies
Sep 17, 2008
I have an equation that needs to calculate variables as it receives them and output the value to a dynamic text field. I have successfully created a function passed values to it but after the first calculation it wont do anything else. [code]...
View 3 Replies
May 23, 2009
I am using the attachMovie script in as2 and I want to use a counter variable to increase the depth each time so it doesn't replace the last one. Every tutorial i've seen for attachMovie mentions this but I can't find any information on how.
Also is it possible to use a different counter variable to change to y position of the attached movieclip, so that it adds another beneath the last every time.
View 2 Replies
Jul 8, 2011
I know how to stop and start a timer, but how can you capture the timer value to a variable and resume it from there at a later time? I tried capturing the currentCount of the timer to an integer variable, but i cant modify it.....it says its read only.
View 1 Replies
Oct 2, 2009
in my class I declare a linked movie clip:
a_mc = new LinkedMC ();
trace(a_mc.testString);
and on the time line of LinkedMC: var testString = "test string"; but I can't access testString.
View 3 Replies
Jun 2, 2009
sample codes. In those codes they are using a verticalChange variable for the time-based character movement.But I can't figure out how this code works and why we needthose calculations - char.dy*timeDiff + timeDiff*gravity?So here is the code:
Code:
// assume character pulled down by gravity
var verticalChange:Number = char.dy*timeDiff + timeDiff*gravity;
[code]....
View 4 Replies
Dec 21, 2009
on my stage i have 24 instance MC Page created at runtime (when cliked the button execute 24 instance MC Page from the library). Each of those MC Page create an xml with infos (not important), this variable_XML created is nested inside each MC Page.. From my stage i want to call each XML from each MC Page for make 1 unic big xml, then send it to the server.
So from the main stage i created a button that call each xml of each MC Page (there is a definit number of Page only 24, no more, no less). So when the 24 instances of the MC Page are created I push there instance name inside an Array "Page_Array". Now in my function exportxml i use get ChildByName(Page_array[number]) for find them then i can apply my method to the according MCPage.. Until here no problem, trace(dispObject.name) work. but when i try to get my variable inside the MC Page : trace(dispObject.my_variableXML), it doesnt work..
here is my function (only 1 page for this example ):
function exportxml(evt:MouseEvent):void { dispObject=getChildByName(Page_Array[0]); trace(dispObject.name); //trace Page1 trace(dispObject.my_variableXML);// here it dont trace the variableXML
}
normally if i trace(Page1.my_variableXML); , it should trace "my_varableXML" no ??
View 2 Replies
Jan 3, 2006
f you know PHP...then you know that you can create a string variable...and then use the value of that variable to declare another variable. like this:
PHP Code:
<?php$foo = "haha";$i{$foo} = "success";print $i{haha};?>
and it would display "success"...or like this:
PHP Code:
<?php$foo = "haha";$$foo = "success";print $haha;?>
and it would also display "success".
View 6 Replies
Apr 9, 2009
I have this clock code and would like to know what needs to be added or changed for it to reference the time off the server and not the local computer time (and preferably reference the server just once and not repeatedly). I already have a file on the server "time.php" that is providing the milliseconds. I know it should be fairly simple, but I just can't wrap my head around it.
[Code],,,
View 2 Replies
May 5, 2010
I use CS4.
Code:
package {
import flash.display.Sprite;
import flash.events.Event;[code]...........
Both of these are saved in files with the name same as the classes.
Both are saved a folder which also contains an fla file name hello.fla.So,when test the movie(hello.fla),after choosing the document class as WavyBall,I get these errors: 1046: Type was not found or was not a compile-time constant: Ball.
Source: var Ball:Ball;
1120: Access of undefined property stage.
Source:Ball.x=stage.stageWidth/2;
1120: Access of undefined property stage.
Source:Ball.y=stage.stageHeight/2;
5000: The class 'WavyBall' must subclass 'flash.display.MovieClip' since it is linked to a library symbol of that type.What is wrong?
View 3 Replies
Dec 11, 2009
I have a fairly complex animation movie clip within my main timeline in a Flash file. When you click a button, it plays the movie clip, then goes back out to the main timeline. The first time the movie clip runs, it plays choppy and slow, but if I play it two or more times, it plays correctly (smoothly). Is there some actionscript I need to preload the movie clip, or some other solution to the first-run slowness?
View 2 Replies
Aug 24, 2009
I'm testing Live streaming with FMSS. The stream is pushed to FMSS buy Adobe FMLE software. Streaming works fine until I reach 1300-1400 simultaneous connections.No matter what the encoding ratebit is (150kbps or 2000kbps) the stream is no longer play from time to time (5-8 seconds).
The CPU (2xIntel Quad) is loaded less than 20% and memory used is about 2 GB (there is plenty of memory installed 32G). The OS is RedHat 5.3 64bit platform. Network uplink maximum rate is 4Gbps.I disabled the Queue but the problem still persist.
View 1 Replies
Jul 29, 2010
I added in my application universal time, and I gave start and stop time. The process is going smoothly, but if I change my system (local) time, the entire time will be changed. Is there any solution to solve this problem?
[Code]...
View 6 Replies
Aug 27, 2010
I am working on a site that has a clock but it displays in military time, is there a way to change it to regular time. The following is the Action script:
[Code]...
View 8 Replies