ActionScript 3.0 :: Object Sending Its Name To A Global Function

Jun 22, 2009

I'm trying to send an object's name to a global actionscript function. It works with a listener in the action layer:

_root.ButtonName.onRelease = function() {
trace(this._name);
}

But there will be hundreds of these objects, so I'd like to have each one call a global function, so I tried code for each button like this:

on (release) {
GlobalFunctionName(this._name);
}

But for some reason, the value being passed is null. (Although if I switch "this._name" for a string, that works correctly.) Question: How can a drone object pass its name to a central function? Should I be using "on (release)" or should I use a listener within each object instead? Also, is it best to make them Buttons or Graphics or Movie Clips since there will be so many of them?

View 3 Replies


Similar Posts:


ActionScript 3.0 :: Sloppy Global Function By Calling Global Function Class

May 14, 2009

I'm try to calling my sloppy global function by calling my global function class as u can see below.[code]

View 2 Replies

ActionScript 3.0 :: Is A Global Function The Same As Plublic Function

Dec 9, 2009

I have a bunch of movie clips which I am adding to my stage using addChild, I need each clip to "fade in" when it is added. I made it work for one movie clip using this function on the movie clip itself

Code:
this.alpha = 0;
function imgAlpha(e:Event):void {

[code].....

View 4 Replies

ActionScript 2.0 :: Can't Get Global Function To Be Seen

Jan 29, 2009

I have a simple banner which rotates through three different movieclips. I would like to create a function on the main timeline that controls the length of delay for each of the clips.

So far this is what I have on the main timeline, which is a single frame:

_global.displayTime = function () {
startTime = getTimer();
MovieClip.prototype.onEnterFrame = function() {

[Code]....

The function works when everything is on the main timeline, but not when I want it to drill down into a movieclip.

View 2 Replies

IDE :: Referencing A Global Var Within A Function

Apr 18, 2009

I'm an old C programmer been away from programming for years. Now we have a project requiring Flash and I've been elected. Just installed CS4. I have 16 panels in 4 sets of 4 that rotate left to right. (Big learning curve on that one - fading transitions in the right order...). Each panel must have a unique url when clicked. (16 urls).I've looked through many solutions, most of which seem unduly complex. I think that the simplest short of going to onRelease() with AS2 (Later I have to add mouseover changes in the graphics) is something like this:[code]I haven't found this solution out there. Is there a gotcha because the a#Link vars are accessed as global within the scope of handleLink? It doesn't feel right, but it works fine and 16 global variables doesn't seem too bad.

View 2 Replies

ActionScript 3.0 :: Global Variable Within Function?

Aug 24, 2009

I'm having an issue with a global variable. I'm trying to give it a value within a function and it isn't working.The variable is imageList. It's an XML List. I'm making it global so I can use it anywhere in my project. I suppose if someone has a better idea to avoid the global variable, I'm up for that too. But for now, it seems like the way to go.
 
Here's my .as file:
package
{
public class MyGlobal
{

[code]....
 
It's giving me the same same Error #1009 as above. It seems like a scope problem, but why? Shouldn't it work since it's a global variable?

View 6 Replies

ActionScript 3.0 :: Global Function For Textfield()?

Nov 7, 2011

I am currently creating a calculator in AS3. Since i need to create a lot of buttons, i need to make a function, so i dont have to write everything into the variable again and again.

View 2 Replies

ActionScript 2.0 :: Declare A Function As Global?

Apr 16, 2008

I was wondering something to do with global functions, it seems if you declare a function as global inside the first frame of a movieclip...and try call it from the first frame of the _root timeline it does not work.

Example.

This code is in a movieclip on the first frame of the timeline called "my_mc";

Code:
_global.Test = function(){
trace("Test ok!");
}

Then the code on the main timeline, first frame would be a call like this.

Code:
Test();

View 3 Replies

ActionScript 2.0 :: Make Flash8 Global Function?

Sep 11, 2010

I have a function in a mc and I want to use it in another mc.

But I does not seem to call it.

I guess I can make the function global in some way, or?

View 1 Replies

ActionScript 3.0 :: Modify A Global Variable Within A Function?

Sep 24, 2009

I've currently got this script (see below). What I'm trying to do is make it so I can load several images from a loop. I've played with a few different things, but I'm not completely understanding how the listener works as it relates to the loader. It seems when I try and add a second image, it only enters the onComplete function 1 time, therefor i only get one Image loaded. As a side note, I've also been trying to dynamically change the x and y position, but I'm not sure how to modify a global variable from within that function, or better yet, pass in the arguements during the eventListener call to onComplete.[code].....

View 2 Replies

ActionScript 3.0 :: Accessing A Global Variable In A Function

Jan 9, 2012

I have a global var

[Code]...

The only problem is it can't "see" myGlobals. I was wondering if someone could tell me why it can't see it! I'm sure it has something to do with scope.

View 3 Replies

ActionScript 2.0 :: Creating Global Variables In A Function?

Jul 15, 2009

I have a function in which I declare a bunch of variables that I need to be globally accessible from outside the function.[code]I need numVals to be accessible from outside the function.I tried changing the name to _global.numVals and it didn't work

View 4 Replies

ActionScript 2.0 :: Passing A Variable To Global Function In Another Mc?

Sep 17, 2009

After having recently just discovered the delights of actionscript, I am at a loss to work this out. I'll explain:I have a series of buttons which, when each one is clicked, need to grab their instance name (this._name), strip the first three characters from it and send it to a global function in another mc within the swf.Instead of stripping the characters, I am happy to do:

if (this._name == dot1) {
dotVar = 1;
} else {

[code].....

View 1 Replies

ActionScript 3.0 :: Reference To A Global Function With The Name Same As Class?

Feb 4, 2011

How would one get a reference of String global function (not class). According to language reference this function does exist (and I'm ready to believe it does), but, say and you have a:

Code:
function foo(bar:Function):void { ... }

How then would you pass that String to it?

View 9 Replies

ActionScript 3.0 :: Access Global Object With Another One Of Different Class

Aug 30, 2011

I have 2 classes:
bullet class:Extends MovieClip and stores information about bullets while handling their movement and properties. enemy class:Extends MovieClip and simply so far stores the x,y co-ordonates of the enemy. I want the bullet to home onto the enemy object in the movement function by referencing the x and y position of the enemy.

Here's the code:
//Main as3 file
stage.addEventListener(MouseEvent.MOUSE_DOWN,clk);//stuff that happens on click
function clk (e:MouseEvent){
shotcnt += 1;
shotobj.push(new pshot(player.x,player.y));
addChild(shotobj[shotcnt]);
[Code] .....

View 3 Replies

ActionScript 3.0 :: Global Variable Not Accessible From Nested Function?

May 13, 2009

i need to assign a value to a global variable from within a nested function, but my code's not working, any clues? this is within a class definition:
 
// begin code
var numGlobalNumber:Number;
outerFunction();

[code]...
 
i want the text within the dynamic text field to be "1" but it comes up "NaN"

View 4 Replies

Flex :: Increment A Global Variable Inside A Function?

Oct 31, 2010

The variable currentIndex is declared globally and initialized with a certain value say '0'. How do I hold the value of currentIndex which is incremented every time the function is called? In the given code, every time the function is called, the value is reinitialized.

function nextSong(e:Event):void
{
sc.stop();

[code]........

View 2 Replies

Actionscript 3 :: Assign Global Variables Inside Function?

Sep 11, 2011

I have an AS3 function that runs when a URLRequest fails. I need to be able to use this function to assign global variables that I can then check against using other functions. How do I assign global variables inside of a function?

Edit:This is the variable (soundFile2Exist) I am trying to get outside of my function:

function onIOError(e:IOErrorEvent):void
{
var soundFile2exist = null;[code]...............

View 2 Replies

Actionscript 3 :: Calling A Global Function With Out 'new' Or Having A Static Method

Sep 27, 2011

I'm creating a utility function for debugging/logs, which I access by importing the class and calling

new Log(params);

Alternatively I change the function to a static, and rename it to It,

then I can call it by Log.It(params)

I'm wondering if it possible to set it up so I can simply call Log(params) similar to the trace command?

function:

package
{
public class Log
{

[Code]......

View 1 Replies

ActionScript 3.0 :: Create A Global Variable From Inside Function?

Oct 11, 2011

I have a primary function that calls upon other functions, which call upon other functions, etc, each one creating different objects. I need to delete everything eventually and was thinking the easiest way to do this would be to have a global array to push() each object into. It would be easy to just put garbageArray.push(thisCreatedObject); into the for() loops of every function to grab all the objects so a deleteFunction() could just cycle through garbageArray to remove and null everything cleanly.

What I want to do:I could easily just create a global array to do this (code example 1), but I would prefer to be able to recreate this global array and delete it every time this primary function is called (code example 3) since it will be called upon a lot. It would be cleaner code to have it created from within the function as opposed to outside of it because I will have a lot of primary functions doing similar things that would require a global array like this.

I also know I could create one and simply pass it as an argument to every function (code example 2), but I would have to pass it to every single function. There are a lot of functions and a lot of calls to them, so this would require rewriting a lot of code and would be more work than it's worth. Making a global array outside of the function would be easier than doing this if it came down to it.

ActionScript Code:
//example 1 of global array. No passing as argument from
//primary to secondary functions. Multiple global arrays
//required for multiple primary functions in the future.

[code].....

View 6 Replies

ActionScript 3.0 :: Global Function To Stop/start Timelines?

Jun 2, 2009

I was wondering if someone could shed some light in helping translate a AS2 function to AS3. It stops the movie's timeline from where you called the function.

Code:
MovieClip.prototype.wait = function(n:Number) {
this.stop();
this.myInterval = setInterval(mx.utils.Delegate.create(this, function () {

[Code].....

View 2 Replies

Flash :: Accessing Uza's Global Object From A Loaded External Swf?

Mar 4, 2010

I am using the 1.2 version of Uza's Global singleton (http://www.uza.lt/codex/as3-global-object/). The container swf stores some data and a link to a function in the "global" object.

Then another swf is loaded inside the container, it gets it's global instance with Global.getInstance();, and i suppose i can access the data and function stored in global by the container swf.

This works perfectly on localhost served by a webserver, but when i put the files on my external production server the loaded swf's global appears to not have anything stored by the container.

View 1 Replies

ActionScript 3.0 :: Shared Object For Global Variable Control?

Oct 6, 2009

The project I'm working on has grown to include multiple swf files of different types. However, the client wants the sound of all swfs controlled from the main swf. After some Google searches I came across examples of local Shared Objects and have attempted to implement what I found. However, the satellite swf in my prototype only registers the data from the LSO as "null."

I think what I need to do is encapsulate the code that defines, writes and clears the LSO in a separate .as file, call it from the .as of my main file (which already has a Document Class defined), and define the satellite files as having the LSO's .as as a Document Class. Am I correct in this line of thought?Using this article as a reference, my SO class would look something like this:

ActionScript Code:
class SO {
private var shared:SharedObject;[code]........

I'm also thinking the satellite files will mostly be using the "returnString" function, since I don't want them to write to the LSO, just to reference it.

View 6 Replies

ActionScript 1/2 :: Global Counter - Put An Animation In A Page And Call Or Use The Function?

Mar 17, 2009

I downloaded a free fla file open source for pageflip. It uses a global function which is this:

_global.mcnt = 0; //counter (used on a page where is an animation).

So now I want to put an animation in a page and i assume that i have to call or use this function. the problem is that i don't know how.

View 4 Replies

ActionScript 2.0 :: Global Variable - Enable / Disable Function Within Game

Oct 23, 2004

I have a button that I would like to enable and disable a function within my game. The button is called "flashBang". I'm thinking this may need to be done with global variables to make the switch do this procedure. How would I go about scripting this variable? Also I want to be able to target this function during gameplay, if this function is enabled do this line of code - _root.gotoAndPlay("flash");

The code needs to fit somewhere in here i guess.
//hitTest top + bottom wall
if (_root.ball.hitTest(_root.topwall) or _root.ball.hitTest(
_root.bottomwall)) {
_root.yspeed = -_root.yspeed;
_root.audio.gotoAndPlay("flash_bang");

View 3 Replies

ActionScript 2.0 :: Sending Function Name Via Parameter

Dec 16, 2006

I am sending a name of a function via parameters to another function. This allows more usage of a single function. However, the button commands work every-so-often. The message appears everytime with no problem.

Code:
_root.msgReveal("This is just a random message. Click the ok button to close.", false, true, false, false, _level0.msgHide(), false);

Code:
function msgReveal(msgString:String, btn1B:Boolean, btn2B:Boolean, btn3B:Boolean, command1:Function, command2:Function, command3:Function) {
msg.messageBox._visible = true;
msg.messageBox.textF.htmlText = msgString;
msg.messageBox.btn1._visible = false;
[Code] .....

View 14 Replies

ActionScript 2.0 :: Sending The Object Properties?

Feb 23, 2009

I'm working on a project that has to pass variables to (and later read them from) a URL encoded text file.

Code:
getURL("process.cgi", "", "POST");

This has worked until now, dumping all of _level0's variables into the document, retrieving the relevant ones on load.I've recently made some modifications so that I'm no longer storing all the variables in _level0, but some of them as custom properties of objects, e.g.:

Code:
t1c1r1.customproperty = 6;
t1c2r1.customproperty = 5;

In these cases, the properties are not being passed to the process.cgi, and not getting recorded in the text file.

I suppose I could flatten the variables out, record them on _level0,

Code:
t1c1r1_customproperty = 6;

but I'm wondering if there's a way to send these variables as is.

View 3 Replies

ActionScript 3.0 :: Can Pass Touch Event To Class Defined 'global' Function

May 12, 2011

I have a class file defined in my package as MyGlobals.as.[code] (I have tried adding/removing "static" and "dynamic" to no effect.)I am trying to call a touch event from the main timeline in this way:myObject.addEventListener(TouchEvent.TOUCH_BEGIN, MyGlobals.myFunctionName);(I have tried removing the class name to no effect.)When I compile I get the error 1046: Type was not found or was not a compile-time constant: TouchEvent. This error occurs on function definitions in the class file.What syntax/concept am I getting wrong? The functions were working fine when I was using constants in the timeline, but I need to be able to reuse these functions over and over again, so I wanted them to be able to take touch event variables so that I didn't have to write a different function for every touch event.I tried googling "error 1046" but I can't find anything useful.

View 3 Replies

Flex :: Incrementing A Global Variable In A Function Which Is Called Multiple Times?

Oct 31, 2010

I am trying to make a simple mp3 player using flash. The songs are loaded using an XML file which contains the song list. The following code is inserted into a new keyframe.

import flash.media.Sound;
import flash.media.SoundChannel;
import flash.events.*;
import flash.events.MouseEvent;

[code]...

The problem over here is in the nextSong() function. I am unable to preserve the value of currentIndex. Although I am incrementing currentIndex every time the function is called, but the value remains unchanged.

View 1 Replies

Flash :: Call JQuery Plugins Without A Wrapper Function In Global Scope From It?

May 8, 2011

Calling jQuery Function from Flash

if we have a jQuery plugin of the following style[code]...

Could anyone point me in the right direction for how this call can be made directly or clarify if it's just not a supported operation?

View 3 Replies







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