ActionScript 3.0 :: Adding Value To Variable From Within MovieClip
Dec 24, 2010
Using AS 3.0 I have declared a variable on the main timeline
var thescore:int=0;
From within a movieclip I now want to increase the value of that variable and display it in a text box.
var thescore:int=thescore+10;
Object(root).myscore.text=thescore.toString();
The above code only displays ten and doesn't increase when the movieclip loops.
If I change the code to
thescore=thescore+10;
Object(root).myscore.text=thescore.toString();
I receive an error undefined property.
View 1 Replies
Similar Posts:
Mar 21, 2010
I have the following code: Can the following code:
globals.data.goal = globals.data.player1/5 be converted to something like: globals.data.goal = globals.data.player(globals.data.clk)/5
[code].....
View 3 Replies
Nov 5, 2010
I have a movieClip button in my library that I dynamically add multiple instances of to the stage using code (so each instance has a unique name). The button has two frames, so it has a basic rollover effect (just changes color. To make the rollover work, I've had to dynamically add an event listener to each new instance of the movieclip, which triggers the rollover function.
I was wondering, instead of adding an event listener each time, can I somehow have an event listener within the movieclip to take care of the rollover? Or will it not make any difference to the number of event listeners, as it will still add a listener with each new instance of the clip?
View 1 Replies
May 31, 2002
I have a variable i that I'm setting to 5. i = 5. Simple enough, I have a dynamic box on the screen so I know that's working.
On the same screen, I have a button, that when you click it, it should do the function i = i + 1. I know this isn't working because when I click it, the number on the screen doesn't change.
Also I have a second button that is a collection of if/else if statements. Basically, if i=1, goto 10, else if i<1, goto 40, else if i>1, goto 40. I know that since I'm setting the initial value of i to 5, it's impossible for i to be equal to 1. Yet every time I click this button, I goto 10 even though i doesn't equal to 1.
View 3 Replies
Aug 21, 2009
I want to declare a variable on the main timeline that can be called from anywhere in my movie. So, _global var should be the right approach. I want to declare a movie clip 'MC1' "open", or "closed" so that when it is revisited, my flash file knows the user has been there before and performs a different task from the one it does when 'MC1' was first encountered. So, i need a 'if' statement to run from the variable, when the playhead encounters the movieClip.
[Code]..
View 2 Replies
Jun 23, 2010
Ive made a movie but i want to get someone to add a picture of themself in an swf (either through a browse button OR simple paste into a variable box) and it appear later in this electronic card im trying to make.
*edit* . . i dont what this to be done in the flash file, on the opening screen i want the user to locate a pic on their hard drive and then slave this picture througout the swf movie ive already created all the tuts im looking at seem to have the images already in the library and they are clicking buttons to display them, i DONT want this . .
View 8 Replies
Apr 15, 2012
im using PHP with MySQL to send information to my flash file using GETs.Using FlashVars i have managed to get the users 'id' with this i can send my questions/searches to a PHP script which access the database and returns the information to the html page.What i would like to do now is add the information sent back to the html page to a variable inside flash for example:
var usr_name = get_user_name(id) || 'Unknown'; // "Unknown" should just be for offline use.
but this just returns 'Unknown' this is the function used:
public function get_user_name(usr_id){
loadData('search.php',"quest=name",'usr_id='+usr_id);
}[code]......
If i just type the URL into a web browser i get the name outputed.
View 2 Replies
Mar 25, 2012
I have a scrollpane in my library.Inside a movieclip, I create an image gallery and add it to the scrollpane.I do this in this function.[code]Now everything works fine, and no problems occur.I do however get the runtime error TypeError: Error #1009: Cannot access a property or method of a null object reference. at fl.containers::ScrollPane/endDrag()It doesnt seem to affect my file, but I am sure it would be better to try and get rid of it.I think it has something to do with adding my movieclip to the main movieclip, and maybe.I am not removing it when I add a different movieclip.Whenever I add a movieclip to the main one, I use container_mc.addChild(...);Does addChild check to see if a movieclip already exist, and remove it if it does? Or do I need to remove my clips beforehand?
View 2 Replies
Feb 28, 2011
I have a MovieClip called chipmovie which I have exported to a class method called ChipMovie, when I try and add it to another movieclip, for some reason it doesn't display.
I have checked Export for ActionScript and Export in Frame 1.The code that adds it to the MovieClip is as follows:
public function addChip(chip:Number)
{
var newChip:ChipMovie = new ChipMovie();[code].....
In the output it says:
init y = -151 height is 0
for all the ChipMovie objects I try to add.
View 2 Replies
Oct 10, 2008
I have been banging my head against a brick wall regarding the following problem which must be very simple to fix, just can't see the answer.I have a class assigned to a movieclip called canvas. The class is called drawClass. I have called the instance of canvas on the stage 'drawingCanvas'.When I trace "drawingCanvas" I get object drawClass] which is fine. Tracing drawingCanvas.name gets me the instance name 'drawingCanvas'.This is a String variable.Basically what I am trying to do is pass the MovieClip name to another class. In my example the class 'toolBar', which can then interact with the MovieClip.
The problem is passing 'drawingCanvas.name' results in a String, so I get an error saying :TypeError: Error #1034: Type Coercion failed: cannot convert "canvasArea" to flash.display.MovieClip.I can't for love or money find a way to convert a String variable to a MovieClip variable! I have the name of the MovieClip, I just need to tell the toolbar class. But I can't find a way of doing this as the instance on stage is an object of drawingClass, not a MovieClip (unless MovieClips with attached classes are not treated as standard MovieClips?).
View 9 Replies
Feb 18, 2009
Basically, I have an input box on a widget that sends information via PHP.
One of the input boxes is phone number. Everyone inputs number as normal, but without the country code.
Is there a way of me taking their normal number from the input box, removing the '0' and adding the country code before sending it (i.e. within a calculation/function/formula).
View 1 Replies
Dec 6, 2009
I'm trying to apply a tween fade in effect to 3 objects, it's hard to explain but here's what i have
function goDown2(e:MouseEvent):void {
var tweenfadeIn:Tween = new Tween(graphic_btn, "alpha", None.easeOut, 0, 1, .1, true);
[Code]....
I wanna apply this tween to illustration_btn, and resume_btn
View 3 Replies
Feb 10, 2010
Is there a way to add an event listener to a variable?
View 4 Replies
Mar 31, 2010
I have the following working line:
moveMC.y = twn.bounceBall01.y
It successfully gets the y value of bounceBall within the MC twn, and applies it to the y value of moveMC. How do I replace the 01 in bounceBall with the following global variable: globals.data.clk? I've tried using a way that Ned successfully showed me for a different situation, plus tried some other permutations, but Flash says "no way dude".
View 1 Replies
Dec 19, 2011
The Code bellow is a simplified version of what I am trying to do. My actual code involves copying an item from one array to another (which I am able to do). Then displaying the contents of both arrays on the stage.
//blueCircle is a library object with proper linkage set up.
var ball = new blueCircle();
ball.x=100;[code]....
When I run this code only 1 ball appears on the stage at (200,200).Is there another way to assign one value to another so that it will be duplicated rather then just adding a pointer to the original variable? if not is there a way to copy the instance of ball and add it to them memory location of another ball?I know that I could call:
var anotherBall= new blueCircle();
but this won't work for the application I am writing because the contents of the array I am trying to copy from are all different types of objects.
View 4 Replies
Mar 15, 2012
So basically I've got a MovieClip called Jug and when the egg is clicked and dragged to the Jug I want it to disappear and then re-add itself in the place it first started. Aswell as this I want a variable to be added by 1 in value. I have tried fiddling around with this for a while now and I can't figure it out since when I remove child it gets errors. Here's the code:
[Code]....
View 2 Replies
Oct 22, 2009
All I want to do is have a textInput Field on my stage called 'countdown' to display the value of a variable.
I want a variable I have in the document class called 'minute' to basically display its value in the text field on my stage.
This is what I have in my document class, obviously the text part is wrong can anyone point me in the right direction?
var minute:int = new int (60);
this.countdown.text = "";
I also have a textInput box on my stage with an instance name of countdown.
View 1 Replies
Oct 3, 2002
How do I add a variable name to the tick boxes within the flash MX components?
View 9 Replies
Feb 19, 2005
I've been trying to add quotation marks to a variable for the past hour or so, but I haven't been having much luck. Basically, here is what I am hoping to create:
Code:
blarg = W71;
temp = magic code that I can't figure out
trace(temp); // displays "W71"
I stumbled on a previous case of this [URL], but that method didn't work for variables when I tried it. Adding a + symbol before and after blarg gave me an error.simple way to incorporate quotation marks around my variable?
View 6 Replies
May 8, 2011
I can't figure out what the syntax is for this in Actionscript. Basically, I have a variable I want to add into a string that will call a certain frame based on user's language selection.
[Code]...
View 5 Replies
Jan 11, 2009
I working on a flashbanner. It is a dynamic textfield called "regnr" where the user is supposed to add a registration number (of their car) before clicking the send button. This code is on the button:
Code:
on(release){
//getURL("[URL]"+regnr.text);
getURL(_root.clickTag+regnr.text,"_blank");
}}
It works when the domain is hardcoded but doesn't work when I am using the clickTag. Is it possible to add variables like this to a clickTag? How could this be done to actually work?
View 4 Replies
Oct 20, 2009
I have a dynamic text box displaying a variable, and I want to add a label of "ft" (without the quotes, obviously). How do I go about doing it?
View 1 Replies
May 8, 2009
On my stage I have 5 items labeled item1_mc, item2_mc, item3_mc and so forth...they all have two keyframes on their respective timelines, one labeled "active" and the other "inactive". My code contains 2 arrays, inactiveArray and activeArray and a variable known as energy that regularly goes to and from 0 - 100.What I am looking to achieve is basically the function of...if energy >= "insert given items 'active threshold' 20, 40, 60, etc..." then add it to the activeArray, if it is not, remove it and add it to the inactive array.
all objects in activeArray gotoAndStop("active");
all objects in inactiveArray gotoAndStop("inactive");
I have tried many different ways of achieving this effect but I always end up with duplicates and extras or something doesn't move when it's supposed to, where it's supposed to, it just ends up into a giant cluttered mess and I start from scratch.
View 2 Replies
Mar 23, 2012
The portal in my game is suppose to be unlocked after you collect all the coins. The portal is locked but when I go over a coin it neither adds to the variable or removes the movie clip by instance name of coin1 coin2 and coin 3.also if the remove movie clip doesnt need _root I've already tried it without it I know that is not the problem.
var openportal = 0;
function moveStuff() {
//-Very long code that is working. [code]..........
View 1 Replies
Jun 13, 2006
all I want to do is add a variable to a getURL line of code.EG:getURL("/index.asp", "_self");I need to add a variable (_root.myvariable) to the end of the link so that it goes to:index.asp?myvar=thevalueofmyvariable
View 3 Replies
Feb 10, 2008
I have a client who wants to add something to a flash presentation that is almost done. There is a root swf that is pulling in a nav screen swf, which in turn is pulling in the text screen swf of that corresponding nav swf. So at the start, the root swf automatically loads nav1.swf, and nav1.swf automatically loads text1.swf. Once that plays, the next button loads nav2.swf into the root swf, and in turn, nav2.swf automatically loads text2.swf onto it. I hope that makes sense. So all the text is going to be on the screen with pix, etc, and we are going to have a VO speak the text. The VO will be on the text swf files since there is fading of pix, text, etc and we need it to match. With it almost done, the client wants a mute button added to the thing.
The question is, if the mute button is on every text swf file, is there some variable that I can pass that would keep the next text swf file from playing it's VO? The client doesn't want people to have to keep clicking the mute button with every page. I know, I know, if I knew they wanted a mute button, I never would have built it this way. It's going on the web, and I figured for loading purposes, this was the best way. Now I think Im screwed... Or rather, they are. They approved this. But can it be done? Can I pass a variable from either the root swf or the navs swf files that tells the incoming text swf files to stay muted?
View 5 Replies
May 8, 2009
So a small example of my situation...On my stage I have 5 items labeled item1_mc, item2_mc, item3_mc and so forth...they all have two keyframes on their respective timelines, one labeled "active" and the other "inactive". My code contains 2 arrays, inactiveArray and activeArray and a variable known as energy that regularly goes to and from 0 - 100.
What I am looking to achieve is basically the function of...
if energy >= "insert given items 'active threshold' 20, 40, 60, etc..." then add it to the activeArray, if it is not, remove it and add it to the inactive array.
all objects in activeArray gotoAndStop("active");
all objects in inactiveArray gotoAndStop("inactive");
I have tried many different ways of achieving this effect but I always end up with duplicates and extras or something doesn't move when it's supposed to, where it's supposed to, it just ends up into a giant cluttered mess and I start from scratch.
View 8 Replies
May 22, 2009
I can add them to the set variables in a literal string such as [code]but that affects the variable when I want to call it into a dynamic and gives me a NaN.is there way to add and subtract these strings to it will not affect the actual input when I need to call it to add it another number variable?
View 5 Replies
Oct 4, 2006
Is it possible to add code (...html or php?) to an html link (i.e the link will be featured in an html website) that passes a variable into the flash site it links to (just something simple like '_root.pageChoice = "home3" '? So when the site opens the swf turns to a certain page?This will be necessary as there will be links to the site from different html sites and each will need to see a different version of a certain page.
View 4 Replies
May 17, 2011
I am brand new to AS3 and just about muddled through with AS2. I have a problem which should have a simple solution but everything I try gives errors.I had a load of buttons on the main timline which worked fine. I have moved a load of them into another movieclip called flyoutMenu. Now none work and I get the error:Error #1065: Variable about is not defined.This is the code stripped down to one button:[code]
View 2 Replies