ActionScript 2.0 :: Can't Access Value From Inside Of Function
Aug 17, 2011I want Access to value of a variable from inside of Function like this simple example
function test() {
a = 10;
}
trace(a);
// return undefined
I want Access to value of a variable from inside of Function like this simple example
function test() {
a = 10;
}
trace(a);
// return undefined
I am trying to have the function name from itself.It will be really cool to automate something like this:
obj.addEventListener( Event.COMPLETE, myFunction );
private function myFunction( e:Event ):void {
e.currentTarget.removeEventListener( e.type, currentFunction ); // where currentFunction should be myFunction}
i am trying to access a variable from inside a function like this:
ActionScript Code:
var X:Number=1;
function hello(event:event){
trace(X)
}
or something like that... does anyone know why i don't get "1" in the output panel when i run the code?
I have difficulty accessing a function inside a child object from parent.I've created an object named "dot" which has the following code in it:
ActionScript Code:
import com.greensock.*;
import com.greensock.easing.*;
[code].....
Is there a way to call a function inside a loaded SWF file?
Basically, I have a .swf file (A) that loads another .swf file (B)...I would just like to treat B as if it was any other instance added to my class .swf "A"...
Have to recast "Loader" with the name of your .swf file class:
Loaded .swf class:
package src {
import flash.display.MovieClip;
public class LoadedSWF extends MovieClip {
[Code]....
I have attached the actionscript file on stage, however I can't access function or variables inside movieclip. Instead I can access them on main timeline, is there a way to access function and variables inside movieclip
View 2 RepliesHow can i access a function, from the root, that is inside another movie clip?
_root.mc_1.mc_1_1.mc_1_1_1
Inside of the mc_1_1_1 is a function called test_me.How can i call that same function from the root?
I have a simple quesiton about class, method and functions inside a method and class properties. I created a new class form my custom component.. But upon developing it I found out that you can not access a property inside the function which is also inside a method..
Example
Code:
class myClass{
private var myProperty:Number = 1; //default is 1
//constructor
public function myClass(){
}//Method
[Code] .....
What I want to do is to access the property inside the method.. I also have a work-around still i cannot point a certain variable to a property of my class inside the method's function..
I have done this same thing in ActionScript 3, but am not familiar with ActionScript 2, which I am forced to use for this project. I am loading products into a SWF via XML and attempting to add a click event to each dynamically-created movieclip. Simply tracing the text from a node in XML will do for now. I'd like to assign a property called "desc" or "description" to each movieclip and have it trace that property's value when clicked. Here is the relevant portion of my code as it stands:
ActionScript Code:
var iXML:XML = new XML();
iXML.ignoreWhite = true;
[Code].....
var speed:int = 4;
addEventListener(Event.ENTER_FRAME,MoveRight);
function MoveRight(event:Event):void{
[code]......
I have an AS3 function that loads and audio file and then plays it. I have the pre-loader for the first audio file working - now I need to run the pre-load function before the 2nd audio file starts.
myMusic.addEventListener(ProgressEvent.PROGRESS, onLoadProgress2, false,0, true);
myMusic.addEventListener(Event.COMPLETE, playMusicNow, false, 0,true);
myMusic.load(soundFile, myContext); //This code works
[code].....
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].....
in this case this.name return me root1
i was expecting the name of the function caller witch is a btn dynamicly created on stage (see exemple)
var facebook:SimpleButton = new socialIconFacebook();
addChild(facebook);
facebook.x = 134;
[Code]....
i know i could put the url right there instead but i have a lot of btn who would use that function
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 have a class Debug with a function called trace inside it which puts a TextField on the stage and outputs the text. Now I am trying to get the Debug.trace() function to do a "normal" debug trace as well from within side itself. of course this causes a recursive loop. I am trying to figure out how I can access the top level separately. I tried using namespaces such as AS3::trace but to no luck.
I know a solution is to rename my function to stop the conflict, but I would like that to be a last resort. It is being used in quite alot of places throughout my entire code so replacing it everywhere is going to be a ballache.
Is it possible to access a function within a function in a parent swf from a loaded swf?
View 6 Repliesfunction test1():void
{
function test2():void {..}
[code].....
I need to activate some lines of code inside a function because that is where the object name has been made.Would a boolean work well? If so how exactly would i implement it? I tried booleans but had no success because i am not experienced with them..
Heres some code:
public var myboolean:Boolean = new Boolean();
public function Function_One()
[code].....
if I add a button to open a uiloader with a marker google with a xml dataprovider in data grid, how can I set this function?
function completeHandler(event:Event):void { var myLoader:URLLoader = event.currentTarget as URLLoader; var xmlDP:XML = new XML (myLoader.data); XML.ignoreWhitespace = true; dp = new DataProvider(xmlDP); dp.sortOn("name", Array.CASEINSENSITIVE); aDg.dataProvider = dp;
[code]........
let's say I have 3 functions like this.
ActionScript Code:
function function1(e:event):void{
//code
[Code]....
Can I somehow, stop the enter frame in function 2 with some code in function3? I know that is not the better practice, but in this case is really needful to have a function inside another.
how can i call a function that is inside another function.like:
Code:
function abc() {function uvw() {
}
function xyz() {[code].....
I'm using OOP code only, no frames nothing.
I have a movieclip called "test" which contains another movieclip called "subtest" inside.
Now, on my code I have:
Code:
var _test:test = new test;
Now, I want to access the MC "subtest", how do I do that?
I gave the instance name "subtest", if I do something like below, it says that the type subtest is not found:
Code:
MovieClip(_teste.getChildByName("subteste"));
It seems that I can have a function inside a function and my code compile fine. (by the way, this is a Flex question....not sure if that matters or not on here)But when I try to define a Resize from the inner function it complains....is it possible to do this? I'm really just trying to find a way to contain my functions inside functions that pertain to each other.
PHP Code:
public function Close():void{
function Resize():void{
[code]......
I am trying to make the classic brick breaker game, and i'm stuck at the part that when i lose a life, the game gets back to the beginning, except with one less life. Does anyone know how to make this?
View 2 RepliesCan you have a function inside a function?
View 8 RepliesI am trying to make the classic brick breaker game, and i'm stuck at the part that when i lose a life, the game gets back to the beginning, except with one less life. Does anyone know how to make this?
View 4 RepliesI need some kind of command to access everything inside an array, mabe something like: myarray["everything"]._x=3
View 1 RepliesI have a problem accessing the inside of movieclip i mean child of the movieclip
the code is here
var myMovie:MovieClip = new MovieClip();
addChild(myMovie);
var myChild:Sprite = new Sprite();
[Code].....
how I can access the coordinates of an mc, but its coordinates with respect to the stage.
What I am doing is using a dragging function, but while the mouse is moving I am also trying to trace the position of the mc itself with respect to its position on the stage, but it seems to keep giving me very small numbers, almost like numbers with respect to its original position. I am not sure yet though why this is. Here is my code:
[Code]....
I have also tried to get rid of the this.x = mouseX and the same for y, but then it returns the values as undefined when i trace this.x and this.y
I'm learning a lot by reading the questions and answers that are asked in the Forum. Now it is my turn to ask a question that is probably a rookie, but I have spend 3 days breaking my head to try to find a solution and have not found it yet.
I am trying that the program responds to each click of the player in a box that is white and turns red, with a random click in another box. Something similar to Tic Tac Toe.
My problem is that I can't make te program to access the boxes in the array by programming. When I try the program to access the box with p.ex.: "this.newBox.boxplus30.gotoAndStop (2);" I always get the error "object null or undefined". I have tried everything you can imagine to formulate that line of code, but without success.[code]...