ActionScript 2.0 :: Edit A Variable In _root From A Function?
Apr 8, 2010I want to edit a variable in _root from a function
it should look like this:
Code:
var index:number = 0;
function fnct (root_counter){
[Code]....
I want to edit a variable in _root from a function
it should look like this:
Code:
var index:number = 0;
function fnct (root_counter){
[Code]....
In the code below i want to change the _root.broj and _root.logo variables inside the function which returns values from .php file. Inside the function everything works fine and all values are correct but when i trace var broj outside the function it's still 0.
var result_lv:LoadVars = new LoadVars();
var send_lv:LoadVars = new LoadVars();
var broj:Number=0;
var logo = new Array();
[Code].....
I need some help with some variable problems. (AS2)
Code:
if (_root.Block+blockUpOne.dead == false) {
surroundingBlocks++;
}
I'm targeting a duplicated mc from another duplicated mc. The 'blockUpOne' is the variable of the number on the end of the duplicated mc (the "i" variable when the mc was created 20, the amount of blocks in the grid across). Basically I'm trying to target a block on top of the one with the code on. I need to add the blockOneUp variable to the _root.Block to made a string which targets a duplicated mc above the one with the code. Even more basically, I want to target an mc by adding a variable to the targeting code.
Example:
Block above: Block34
Block with code: Block54
if(_root.Block+(54-20) is alive){
do stuff
}
I was wondering, is it possible to call a function in a MC from the _root of the movie?
I have an MC called timer, linked aswith a function in it,
Code:
testFunc = function(){
trace("It Worked!");
}
On the _root in the first frame I have this,
Code:
_root.attachMovie("timer","t",5);
_root.t.testFunc();
I was following a tutorial and input the AS code :
_root.onEnterFrame = function(){
if(_root._xmouse<50){
imgBar.prevFrame();
}
}
and im getting this : ReferenceError: Error #1065: Variable _root is not defined.
at Sliding_fla::MainTimeline/Sliding_fla::frame1()
i have a:
Code:
_root.onMouseDown = function(){
someAction
[code].....
I am trying to make a game to learn actionscript. my game is going to have multiple keyframes, ie one for dungeon, 1 for a large map yadda yadda yadda. Things like the character i would like to be available to all keyframes. i am assuming i put the character variable and info in the first keyframe and refer to these via _root in any frame. However if i want to make a dungeon and use the dungeon scene variables i would use this.
right now since i am only on the making a dungeon part i can refer to anything using this or _root. Case: my dungeon scene consists of walls and paths. right now i can do something like if(_root["path" + yPos + xPos]) _root["path" + yPos + xPos].removeMovieClip;
i can also call the same code using this instead of _root and it works. when i add a main new main frame and move the dungeon scene from frame 1 to frame 10, will i still be able to inter use _root and this and have the same effect, or once i move the dungeon scene from frame 1 to frame 10 i will no longer be able to use _root. also i only have 1 layer.
im lookin to make this so that the points taken from the _root.cargo are multipled by 10 and added to _root.totalscore
[Code]...
if a condition is true, then:_root.(MC with instance name that is the value of "_root.eelmine").nextFrame(); is this correct?_root._root[eelmine].nextFrame();
View 16 RepliesI have a public variable and I am trying to set it, then read it from a different function:
public var str:String;
public function DailyVerse()
{
function create() {
[Code]....
My trace results says null. Why does it not give me "hello"?
I have a single movieclip named button, and I want to use a "for" to multiply that movieclip, that way I can have multiple buttons and edit them all in a single function.
It would be something like this:
var _button = new button;
for(i=0; i<5;i++){
_button[i]:button = new button;
addChild(button[i]);
}
I just recently began migrating from AS2 to AS3, and I have of course realized that I can no longer move the "_root" by changing the _x and _y positions of the _root (which no longer exists in AS3). How can I do this in AS3 (specifying _x, _y, _z possibly of the "_root")?
View 2 RepliesI admit I'm fairly new to flash, but I've almost finished an entire RPG battle system complete with music [etc. etc.] - but my problem is trying to add a preloader.. I have a basic page which says "Loading" and has a Dynamic text box below which should read the Variable "_root.loadText". In the first frame I have this code:
[Code]...
and in the second just "_root.gotoAndPlay(1);" for the updating process. I'm sure that's all okay. But when I export it, then upload the swf file to somewhere like SwfCabin to show people for testing purposes, they have to wait on just a blank white screen for 1~3 minutes.. -note: I use both Adobe flash CS3 [at home] and Macromedia Flash 8 [at school] - I can stick to just CS3 if needed.
In actionscript 2.0, I can call the global variable using "_root."
ActionScript Code:
var str1="global"
function a(){
[Code].....
But it seems that I cannot do the same in actionscript 3.0 by using "root."
i want to access variables from within movie clips, and my question is, when declaring variables from the root, is it necessary to add the _root? e.g.:
Code: var _root.imgSource:String = "img001.jpg"; or would it be sufficient to declare the variable in the root timeline, then refer to it in child clips as _root.imgSource?
I'm cheating and using lockroot function atm
but how do I set "_root" of a swf to a local variable?
localroot = this ?
I'm trying to edit some flash to make an external javascript function call, but with no success. Here's my actionscript 2.0 code:
[Code]....
I've seen lots of examples and I'm mainly confused about the use of ExternalInterface.addCallback. I don't need the javascript to return anything to flash, so is this necessary? For whatever reason, I never see the alert. Does anyone see any problems in my code? Is there some ExternalInterface library I don't have? Also, what's the BEST way to use ExternalInterface (ie; error checking, etc.)
I'm actually relatively new to flash and actionscript but I could say I have fair knowledge about them. So anyway, I usually build flash websites the traditional way using timeline animation and scripting. Today I had a job interview and they said they're looking for someone who can develop any web design into a Flash CMS with a back-end office for the client to edit the content without having to edit the FLA file or any code.
Accordingly, I'd like to know where and how to start. What are the main concepts I should follow/adapt?
how you would target a function's local variable through a concatenated variable string.For example:
var txt = "Hello World";
function testing(msg) {
var test1 = msg;[code].........
I'd expect the trace to be "Hello World" but rather is given "undefined". So if variables created outside functions are created on the main timeline, where are local function variables created and how would you access them?
I'm trying to combine PHP/SQL and Flash. I've got a problem now. I want to load a variable that contains an url to an image. so the variable is like this: [URL] Now I want flash to load the image, not the text. The variable is called 'img1' but the loadmovie function doesn't work when I put it in.
View 2 RepliesI want to monitor a variable. Whenever the variable value changes I want to call a function. In actionscript 2 I can use "watch" but in as3 what can do ?
View 1 RepliesI have a set of Cue Points in an FLV I'm playing. It's an interactive quiz, so the idea is that flash will change a variable, theAnswer, to a different letter depending on which question it is. The answer to question 1 is B, question 2 is D, etc. Either the cue point event listener isn't working, or else it is working and Flash isn't declaring the variables. 1120: Access of undefined property theAnswer. I literally can't find a single problem with my code. I have an almost identical Event Listener further down which works.
[Code]...
is it possible to declare function this way
ActionScript Code:
function startShake(e:MouseEvent, num1, num2):void
what i mean is it possible to send to the function not only en event but also a variable and a second question how can i access
ActionScript Code:
function stopShake(e:MouseEvent):Array
this array that function return.
I need to pass a variable to a function inside a function. However this parameter (i) seems not to be passed (to function ...onRollOver). This is required to attach a textfield to a movieclip (reading the adress and showing it as a tooltip).
ActionScript Code:
for (i=0; i<array_BE_ElecCities.length; i++) {
var attachElecCity = mc_map.mc_places.attachMovie("Plant",
[code].....
I want to create a vector, then call a function that populates that vector with arrays. Fine. The only catch is the function itself will declare new array variables to put into the vector, but are these new array variables private to the function only?e.g. something like this
ActionScript Code:
public var vec:Vector.<Array> = new Vector.<Array>();
private function populateVec():void {
[code]....
Is this "kosher"? a was declared in the private function but added to something outside the function..?
I'd like to control a movie clips current frame by another movie clips action script.I realise the following controls the outside (root) frame time line:
on(release){
_root.gotoAndStop(1);
}
but I'm not sure how to apply that to my other movie clip. I'm guessing it would be something like this:
on(release){
_*movie_clip_name*.gotoAndStop(1);
}
I have taken variable in one function and want to use that value in another function.
View 2 Replieshow to get variable value from a function to a text box here is the code :
import fl.controls.ComboBox;
import flash.events.Event;
import flash.events.MouseEvent;
TxtAnswer = Array();
[code]....
.. i want that variable "sk1" to next scene text box ..i putted the code like this :
q1.text = sk1;
but it is not working..
me how I can use the variable from one function in another function?
For example:
function init():void {
var test:Number = 1;
}
[Code].....
I have created an actionscript function which stops an animation on a specific frame which works fine. I have then loaded in a php file with a variable which will contain the number for the frame i want the animation to stop on. This has loaded in fine and i have loaded it in a function. what i cant seem to do is to get the variable into the function which tells the animation to stop playing.
here is my code:
//load variablesvarReceiver = new LoadVars(); // create an object to store the variablesvarReceiver.load("http://playground.nsdesign6.net/percentage/external.php");//load variables
[code]....