ActionScript 2.0 :: Make Flash8 Global Function?
Sep 11, 2010I 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?
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?
I'm try to calling my sloppy global function by calling my global function class as u can see below.[code]
View 2 RepliesIs it possible to make global functions, much in the same way you make a global variable, reachable from anywhere in the project?
View 1 RepliesI am trying to to an application to let me pin some areas in a map and the pinned areas should have some information...in a window when I mouse over the mouse.. the 'problem' is to make is Dinamic...The admin area should let users put a pin and add the information, all over the web...
View 5 Repliesi cannot get exactly how to make "global function" for call them so. I want to make a function in my MainMovie.as class that can be call from MyButton.as class. Or declare a function in any class and use it from any other class.
I've found the making the functions "static" does the work, but those cannot be apply to the "this." (intances). like:
[Code]...
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].....
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.
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 RepliesI'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?
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 RepliesI 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();
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 RepliesI 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.
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?
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 RepliesAfter 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].....
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?
how do I make a global variable that can be recognized in all frames?
View 1 RepliesIs it possible to make global functions, much in the same way you make a global variable, reachable from anywhere in the project?
View 1 RepliesI'm making this thread because I have searched in google for how to make a "global library". I'm sure this is not what it's called but i couldnt think of another way to search. If I start a new project and I want to bring in objects from other projects should I be going to "open external library"? I imagine that an external library is global. While i'm waiting for replies i'll look up how to make an external library.
View 1 Repliesi 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"
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]........
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]...............
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]......
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].....
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].....
1- how to make a var global to use it in other scripts on the time line?
like this one
var clip_mc = newMovieClip();
how to change that to global to be used in another scripts?
Problem 2:
2- how to kill or destroy or stop or close a movie clip from showing in the project until calling it's script again to show?
as u probably know TextFormat has no global style like FStyleFormat so i thought i could make one?
1. idea) i could wrap createTextField() in some fns which then assigns automaticly some TextField-propertys and sets setTextFormat.
THE PROBLEM with that is that not all of my TextFields are generated via script, some r created by authoring-time.
2. idea) is to change the prototype."someproperty" of the TextField,THE PROBLEM TextField is not created via standard "new" constructor
so something like TextField.prototype.embedFonts=true; DOES NOT WORK as well.
3. idea) i could simply traverse all instances on stage and ask if the instanz is TextFeld and then assgin some fns which makes the formating.THE PROBLEM i dont know how to do that?
couse if i ask
trace(typeof t_txt.__proto__);
it just givs "object" not TextField or so
---------------------------------------------
does anybody knows how to make kind of global TextFormat for createTextField()-generated as well as for authoring-time generated TextFields?
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.
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");