ActionScript 2.0 :: Changing Variables When On A Different Frame

Jul 4, 2009

OK this might take a wile to explain but ill give it a go. I'm trying to make a sort f upgrade menu for my Flash game (AS2) but I'm a bit stuck. Ok my char has got this action script on it.

onClipEvent(load){
_global.speed = 1
}
onClipEvent (enterFrame) {

[Code]....

That all works fine but what i want to do is make it that when you click a button the var speed will change. I can do that quite easily with this code

on(press){
_global.speed += 1
}

and that works fine two but what i want to do is have the button for upgrading the speed on a different frame (ie. the upgrade menu)

So on frame 1 is the moving char and there is a button linking frame 1 to frame 2 (upgrade menu) and on that frame it has the button for upgrading the var speed and then a button linking frame 2 back to one but it doesn't work. I think i no why because on the char is says onClipEvent(load){ _global.speed = 1 }

so that means that the var speed will revert back to 1 when you go back to the first frame.

View 3 Replies


Similar Posts:


ActionScript 2.0 :: Changing A Textfield In Frame 2 From Frame 1

Dec 3, 2004

I know this may seem like a really simple and stupid question. I'm a programmer, but new to actionscript and my main problems are related to the way flash works (not inherent problems, just my lack of understanding). I've modified the XML Tutorial to load more than one XML file. It works well, but the only problem is, I have a textfield on another frame, which I want to load in the frame 1 actions. The XML code isn't the problem, just an a little background on why I am using ".text =". When I do this, as a test, from within Frame 1 of Layer Name Action Layer;

[Code]...

View 5 Replies

ActionScript 3.0 :: Amatur - Access Variables In A Frame On The Stage With Code From A Frame Within A Movieclip?

May 16, 2009

how I access variables in a frame on the stage with code from a frame within a movieclip?(basically passing variables from a stage frame to a movieclip frame)

View 4 Replies

ActionScript 2.0 :: Changing Variables From Withing An MC

Oct 9, 2009

I have a piece I'm working on that loads some copy to the front page. Then when you mouse over the navigation it plays the 2nd half of the MC that makes the copy fade. One of the navigation buttons works to bring the copy to fade back in by playing the first half of the MC.I'm declaring a boolean variable "intro" and setting it to true on load because the copy is visible.Then within my MC at the end (when the copy is done fading out) I set "intro" to false.Then if the user mouses over the nav it runs an "if" and if the intro is true it fades it out, and if its not it shouldn't do anything (stay invisible).The problem is it keeps playing the MC - so you mouse over the nav and it fades out, then you mouse over the nav again and it fades back in, then you mouse over the nav and it fades out again.

View 2 Replies

ActionScript 3.0 :: Changing Variables With EventListener?

Dec 9, 2009

I borrowed a code to give my stage a falling snow effect, and I added on/off buttons. I'm sure there's another way around what I'm trying to do but I'm curious about going about this way. the variable in the code contains:var snowflakesCnt:Number = 180;I added EventListeners for the buttons but don' know the way about changing the variable to 0 and180 upon mouse click.

View 4 Replies

ActionScript 2.0 :: Changing Global Variables?

Oct 21, 2004

I'm trying to create a global variable that initially stores a 0.Then via a function will change the value of that global variable, and allow the other functions to access the new number. I have it working where it adds 1 to the variable, and stores the number 1 however, I cannot get the number to add up beyond 1.I have this in my first layer,frame.

_global.thisSound = 0;
function PlaySound(){
temp = _global.thisSound;

[code].....

View 1 Replies

ActionScript 2.0 :: Passing Variables From Frame To Frame?

Apr 25, 2006

I have a submit section on my flash movie.I also have 3 frames in this movie.

Frame 1:
Yes or No radio button
Comments: text field

[code].....

View 5 Replies

Flash 5: Changing Variables For Dynamic Text

Jul 17, 2009

My .txt file is called my_text.txt

Inside I have:
myText1=This is test 1.
&myText2=This is test 2.

I tested it out with my dynamic text. If I made the variable myText1, it loaded the first line. If I made it myText2, it loaded the second line. All seemed to be fine.

I have a dynamic textbox, variable named names. I want to be able to change the variable in order to get it to load whichever line of text I want.

I tried:

names = myText1;
loadVariablesNum ("my_text.txt", 0);

But that's not working. I've tried playing around with it in various ways, like
names = eval(myText1);

and such, but nothing is effectively getting it to change. I've been trying to look it up and tried all the different ways people told other people to use, but it's not working for me.

Once I get this work I everything should fall into place easily.

View 3 Replies

AS3 :: Changing Stage Variables From Within A Movie Clip

Feb 2, 2012

I want to change variables on the main stage's code from within a movie clip.

Say for example, I want to change a variable called 'chair'

In AS2, this is how I would do it:

(on the main stage)

Code:
chair = 2;
(in the movie clip)

[Code].....

But all I get is a 1119 error saying 'Access of possibly undefined property chair through a reference with static type flash.displayisplayObject.'

View 3 Replies

ActionScript 3.0 :: Using And Changing Externally Defined Variables?

Aug 23, 2009

The problem which i have is about using variables (specifically "myVar") defined in one as3 class file, in a separate class file. After searching for this via google and on this forum i have not (maybe because i have been searching for the wrong thing), so here is my situation which i think should be simple to solve:Inside a fla called "Main" i have 2 MovieClips. The first is called Main and has a class linking to the com/Main.as file which has this code:

ActionScript Code:
package com{
import flash.display.MovieClip

[code]....

View 6 Replies

ActionScript 3.0 :: Variables Not Changing To New Location Coordinates

Nov 4, 2009

I have a simple Actionscript 3 project. The code is on the timeline:
ActionScript Code:
import pti.dmutility.layout.ConfigElement;
//this Class simply extends the fl.controls.Button with variables

Then I put some instances into the stage, and make them Drag&Drop. Here is the Dragging function. I want to remember the item's puck up position when clicked, I use ConfigElement's OldX and OldY properties:
ActionScript Code:
function dragStarterItem(e:MouseEvent):void{
var item = e.target;
item.OldX = item.x;
item.OldY = item.y;
item.startDrag();
item.addEventListener(MouseEvent.MOUSE_UP, dragStopperItem);
}

When I click on the item, the OldX and OldY gets the actual position of the item, BUT after dropping it somewhere else, and picking up it again, the OldX and OldY is still the same! Holds the initial position, and not changing to it's new location coordinates. Every instance remembers it's initial position only. Why not change every time I click? Why remembering the first click's position only?

View 7 Replies

ActionScript 2.0 :: Changing Variables In Dynamic Text?

May 14, 2010

Okay, here is my code which I have in the frame actions:

Code:
char_xp1 = 1000;
char_level = 1;

[code]....

View 1 Replies

ActionScript 3.0 :: Dynamically Changing, Included Variables?

Aug 12, 2011

My problem is the following:I've been working with Flash CS4, and have written a script which creates a dynamic menu based on an array variable. The array variable needs to be located in a separate .as file so that I can use a bash script to create the array on the fly, based on files found in a specific folder. It's taken me weeks of writing both the bash and actionscript to make everything work smoothly. Everything works except for one small thing: when I update the file containing the array, the menu in the .swf fails to update with it. In order to update the menu, I'm forced to re-publish from within Flash itself.

Previously I had used the "include" function to place the array within my script, but I then tried bringing it in with a package as a global variable. Neither method worked. It seems that the file is included during the publishing (that's probably common knowledge). So I'm wondering if there's a way to include the array, or build the array, in such a way that will allow the .swf to update with a simple refresh of the web page.

ActionScript Code:
Package containing array:
package {

[code]....

View 4 Replies

ActionScript 2.0 :: Changing Movieclip Path With Variables?

Apr 27, 2006

If I want to change a set of movieclips that all have the same name except they end in a different number i.e

movieclip1
movieclip2
movieclip3

whats the correct actionscript to refer to a movieclips path in terms of the name plus a numerical variable i.e

movieclip + var

so I can cycle through each one by altering the variable.

something like

var x = 1;
_root."movieclip" + x.othermovieclip.gotoAndPlay(1);

my attempts don't seem to have worked!

View 7 Replies

ActionScript 3.0 :: Dynamically Changing Instance Variables

Jul 3, 2009

In the following code I would like to be able to change which object the code affects depending on which parameter name is passed to it:

Code:
EventCentral.getInstance().addEventListener(ProjectEvent.SOME_EVENT, handleSomeEvent);
function handleSomeEvent($event:ProjectEvent):void

[Code].....

I could write it all out with ifs and else ifs for each parameter but this code is already part of quite a large structure and it would be more elegant to be able to do it with re-usable code.

I'm trying to do it is particularly idiomatic to actionscript anyway

View 1 Replies

ActionScript 3.0 :: Changing Referenced Variables Inside Of Array

Jan 26, 2011

I have an array filled with several pre-existing variables. I want to loop through this array and update each of these variables that way, so that I don't have to do it line by line. My issue is that when I edit the variable inside the array, it is not changing the actual variable that was assigned to it. See Below for example.

Actionscript Code:
var myVar1:uint = 1;
var myVar2:uint = 2;var myVar3:uint = 3;
var myArr:Array = new Array(myVar1, myVar2, myVar3);
for(var a:uint = 0; a<myArr.length; a++){
if(a == 0){ myArr[a] = 9;
}}trace(myVar1); // Still traces "1" instead of "9"

View 6 Replies

Actionscript 3 :: Changing Root Variables From Withing A Function?

Apr 2, 2012

I'm new to Actionscript 3, just started working with it after years of working with AS2,

What I'm trying to do at the moment is to change a variable that's located in the root from a function,

Something like this:
var myVariable:String = "String test";
function testFunction():void
{
myVariable = "new String";

[Code]...

View 2 Replies

ActionScript 2.0 :: Changing A Movie Clip's Local Variables?

Mar 4, 2009

I'm working on a particle system, where each single particle is represented by a movie clip and has it's own behaviors, defined in the movie clip's code in a separate layer from the image. The particle creates local variables, such as it's gravity and color, in the first frame and then uses them to guide it's actions throughout it's lifetime (it fizzles out and dies, eventually).Frame 1 of particle_mc:

Code:
var gravity:Number = 0;
var color:Number = 2;

[code]....

View 2 Replies

Professional :: Dynamic Text Field With Multiple, Changing Variables

Nov 18, 2010

I am at work right now trying to create a power point for our Christmas party.  I know I can do so much more with Flash than I can with any other power point program.  Right now, I'm trying to figure out a way to load a list of names into one dynamic text field that changes at certain time intervals.  I'm using ActionScript 2 right now b/c I haven't learned 3, yet.  Is there a way for Flash to access a word document and load a name say, every minute?  I know I could add a different variable name in front of each employee name, like content, content1, content2, but I have a list of like 300 names here.  That would take up almost as much time as it would creating a slide for each name in Power Point. 

View 2 Replies

Actionscript 3 :: Calling Private Functions By Changing Public Variables?

Jun 13, 2010

i've never tried to do this before, so my head a swimming a bit. i'd like to have a public boolean called enabled in myClass custom class. if it's called to be changed, how do i trigger a function from the change? should i add an Event.CHANGE event listener to my variable?

View 1 Replies

ActionScript 3.0 :: Changing Multiple Variables And Displaying In Dynamic Text?

Sep 15, 2011

I have a question regarding ActionScript 3.0 and using buttons to change numeric values in a Flash project. I am trying to create a program that adds and subtracts numbers when buttons are clicked. Here is the code that I have written for the first button that I want to use:

Code:
//Number values//
var withdraw = 0;
Amount_total.text = withdraw;

[Code]....

However the problem I have is that the K200disp text only displays 1,2,5,10,15 etc while the Amount_total text seems to randomly display 200 or lots of 0s!

View 9 Replies

ActionScript 2.0 :: Changing Values Of Variables That Need To Persist Amongst All Users Of Site?

Sep 28, 2006

I want to know what the best method is for changing the values of variables that need to persist amongst all users of my site?For example, say I have a button that can only pressed 10 times. And not 10 times by a single user during a single session, I mean 10 times between every user who ever visits my site. How would I keep a running count?

View 2 Replies

ActionScript 3.0 :: Mic Level Changing Frame?

Aug 14, 2009

I dont know the first thing about Actionscript, so I dont know if this goes in Newbies or not because I'm not a newbie to Flash, just the programming aspect.Basically what I'm looking for is this script:

m = Microphone.get();
attachAudio(m);
m.setUseEchoSuppression(false);

[code].....

View 4 Replies

ActionScript 1/2 :: Button Not Changing In Frame 3

Oct 23, 2009

I have made a button with sound and a text that I want to change after the user clicks on it. In the button-symbol I have one layer for sound and one for shape. When the user click the sound is OK and the link to the URL I have stated is opened. Fine. But the button do not change as I drawn it in frame "down" in the four-frame timeline - I want the button to have another text when clicked.

View 3 Replies

Professional :: Changing Frame Rate From 12 To 30?

Sep 29, 2010

I recently built a flash movie that I am going to export out into a quicktime movie for YouTube. I mistakenly built it with the frame rate of 12 fps and I need to switch it to 30 to make it compatible for YouTube.
 
My question is:
 
Is there an easy way to change the frame rate from 12 to 30 and keep the same timing that I have with the movie at 12fps? The only way I can think to do it is manually, but I was wondering if there is an easier way.

View 3 Replies

ActionScript 2.0 :: Automatically Changing The Frame?

Jan 8, 2009

i need the Action Script code that will change frames automatically every 3 seconds.I will have 5 Frames each frame having a different picture on. When the visitor visit the page i want the frames to change to the next frame every 3 seonds so it shows the 5 pics independently. I also want it to repeat itself.

View 8 Replies

ActionScript 3.0 :: Frame Changing Error?

Nov 9, 2009

i'm planning on programming an animation but i wanted to set up the card side of things so i made a start and it provides this annoying error. and its causing my mc's not to change frame sometimes. here's my script.

ActionScript Code:
var suit:Number = 1;
var card:Number = 1;

[code]....

View 7 Replies

ActionScript 3.0 :: Changing A MC Frame In Array Map

May 12, 2010

Currently I have code that when called finds and replaces the number 4s in my array map with the number 0. This works fine however these numbers refer to frame numbers in a MC which is used to make the map, I have been unable to make the frame number of the coresponding MC change also so the picture disappears.[code]

View 0 Replies

ActionScript 3.0 :: Changing Value From Function Per Frame

Aug 5, 2010

I have a game and I'm trying to make changes when a thing happens. I want to do this, when the "caught" flies rise up to "50" increase the value for the flies falling frame per frame

So I tried this:
Code:
function crearID():void{
var enemigo:Cayendo=new Cayendo()
enemigo.y=-50;
enemigo.x=Math.random()*stage.stageWidth;
enemigo.addEventListener(Event.ENTER_FRAME,dropEnemy);
addChild(enemigo);
[Code] .....

View 3 Replies

ActionScript 2.0 :: Changing Frame Rate?

Jul 3, 2005

It's possible to load a movie into another movie, with different frame rate, without changing the velocity of the animations of the loaded movie?

View 3 Replies







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