ActionScript 2.0 :: Changing A Variable After A Certain Time?
Jun 5, 2006I would like to have a button that when clicked changes a variable for 30 seconds and then changes it back. For example:
[Code]...
I would like to have a button that when clicked changes a variable for 30 seconds and then changes it back. For example:
[Code]...
basically when you load the .swf it changed everytime u re-load it , i want it to keep on changing even when the user hasnt reloaded the image
[Code]...
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.
I have an set of images (all icons) which I want to be able to change during run-time. I already imported all of them into my FLA into the library and already instanced one of them as a MovieClip (right click -> convert to MovieClip).
How to change the image associated with my movieclip instance in code, so I can change the image to any other of the images that were imported into the FLA's library?
Is there a way to make many movieclips change the same way, off the same line of code.. rather than having to write them all out seperatly?
eg.
If this was the original code...
clip1_mc.onRollOver = function () {
clip2_mc._visible = false;
clip3_mc._visible = false;
[Code]....
The above doesn't work... but i'm wondering if anyone knows of a method that will work... saving me from having to write so much code in future?
I want to show images that am calling from xml file into flash, I want to show them each after a certain time interval, I want to do this in AS3 How it can be done?
View 1 Replieswriting a code that will change a picture base upon the time.
i want to have a picture of the sun rising between the time 6am to 11 am
then from 12pm - 5 pm a pic of the ocean showing
from 6 pm - 10 pm- a pic of the sun setting...
then from 11pm- 5am a picture of the northern lights..
ohh yeah i have the time being called in a # from 1-24, = var = hour
idk if u can write if statments with a range of numbers . ex. if (hour > "range of time/#'s") ....
or have a shape in the backround and have it change as the time changes??
I'm building a site that will change the background depending time of day. I do want to show the time in the top of my page. What are good codes for showing a time and date in Flash and what would I use to change background depending on if the time is past 7PM or before.
Example.
If the time is before 7PM I want it to show a background with a clear blue sky. If not then the background will be a starry night. I'm using CS3.
How can I change border color of tab in tab navigator control at runtime? I am trying to access it with its id "mytab" and update it's style.
this.mytab.setStyle("bordercolor","red"); A TabNavigator has multiple tabs and I have to change style of few tabs based on some logic. StyleDeclaration is applicable for all the tabs under tab navigoter but how can use CSSStyleDeclaration based on componentid? The only shortfall with this approach is that Style can not be changed for individual tab.
This is a 2 part question really:
1) I'm trying to change the position of two different MovieClips instances to the same .x position. It works individually, but as soon as I put this code in, it says that it cannot assign it to a non reference value:
ActionScript Code:
coinArray[1].x && coinShadowArray[1].x = -591.5
2) I have a whole load of variables which are all going to different .x positions at the same event trigger - something similar to this, but there's around 30 of them:
ActionScript Code:
object[1].x = -560
object[2].x = 764.45
object[3].x = 700.45
object[4].x = 740.45
I'm trying to get the time from the server (php) and then display a different flash movie (via either a different swf or frame on timeline) accordingly.
Unfortunately I haven't found anything that relates to this using as3.
I am working on doing a hitTest using one attachMovie and one repeating movieClip. I am running into trouble because the movie clip is changing it's name every time it's created (panda1, panda2, panda3, etc...) and the attachMovie, fire, is not recognizing the created MC's. here is the code to create the movieClips:
[Code]...
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 RepliesI'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]...
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);
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?
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.
I'm creating sort of a game in Flash, which requires invisible hotspots changing their position in time, relative to the stage. The question is: can I simply keyframe the hotspot position and have it work, or is there something that I should consider?
View 5 RepliesI created a auto scroller which works fine but I would like to change it so that I can reuse it without changing different values each time.The movie consist of a scrollmc and a maskmc (just a rectangle)
[Code]...
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 RepliesI 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.
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
im making a achievements page and i want flash to change a variable to 1 how do i do it
View 9 RepliesI'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?
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?
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].....
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.
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 Repliesi 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]....
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?