Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

custom handlers

Status
Not open for further replies.

ckennerdale

Programmer
Dec 23, 2000
158
GB
I have spent the last six months using dirctor and php, and have found myself confused with Flash after such a long break

I want to be able to define my own handlers and then call them within other events such as enter frame

such as

on clipevent(enterframe){

myhandler1;
myhandler2;
}

and then to be able to define these handlers else where

can I do this

thanks Caspar Kennerdale
Senior Media Developer
 
you should be able to set them in first frame...that's what I always did...myhandler1 == 0 then later on, I called ._root.myhandler == whatever.

I dont know if its what you need, haven't been in this forum for a while as people were poking and prodding me with sticks. Regards,
Anth:cool:ny
----------------------------------------
"You say [red]insanity[/red] like it's a BAD THING!"
 
Thanks a lot

The trick is to refence the function via its location- ie _root.handler();

I am just used to refencing the handler directly.

Another thing then,I am having similar trouble with variables.

I declare then in frame one like

var1 = 12;
var2 = 33;

and so on.

I want that button to pass to my handler when activated by a button. The variable doesnt seem to get that far. In director for example you can decale a variable to be global and its current value is accessicble by evey live element.

Is there a way to make variable 'live' throughout different movie clips and buttons. All documentation suggests it can but it doesnt seem to work.

If you got the time, an answer would be appreciated.

Cheers once again Caspar Kennerdale
Senior Media Developer
 
You can declare global variables withinn Flash with either setVariables or simple assignment.

However, to avoid confusion between local and global names etc I find that the easiest thing to do is to declare your global variable at the _root level and then reference it using an absolute path from other clips...

e.g.

_root.myVariable=value;

will work from anywhere in the movie.
 
For those who don't know and are familiar with true Global Variables in other programming languages, there is no such thing as a Global Variable in Flash, only Globally Accessible Variables.

I agree about declaring your variables in the main timeline, it's the easiest way to keep scripting down, but I would recommend defining all variable within their own movie-clip. If you do put them in the timeline, I would use the syntax /:myvariable = .... to redefine or access them.

dave
dave@pinkzeppelin.com

^^^^^^^^^^^^^^^^^^^^^​
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top