Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 10-23-2006, 03:24 PM   #1
mmm..pi..3.14..
/(bb|[^b]{2})/
 
mmm..pi..3.14..'s Avatar
 
Join Date: May 2004
Location: Denver, CO
Posts: 2,740
Question Global functions??

Just curious more than anything else...

Is it possible to compile components with _global functions? I notice that you can put them into a mc and then give the mc some component definitions which gives it the appearance of a component except it can be edited just like any other mc. However, that of course is not a true component because it is not an swc file. If you export it as a component file, _global functions no longer seem to work. Is it possible, or am I wasting my brain power thinking about it??
__________________
Eric Hainer
Unleaded Software
970.581.3387
Email: Eric followed by the AT symbol, unleaded software (one word) DOT com
Denver Web Design
mmm..pi..3.14.. is offline   Reply With Quote
Old 10-24-2006, 03:54 PM   #2
tg
done
 
Join Date: Jun 2001
Location: portland, or
Posts: 8,106
Default

why would you do that? it would defeat the purpose of a component. the whole reason to have a component is so the all the code necessary to make it work is all in one place, and it is portable. if it depends on global functions then when you move your component to a new project, you would need to move all of the global funcitons also....
__________________
tg
---
what the hell was i thinking?
tg is offline   Reply With Quote
Old 10-25-2006, 04:53 PM   #3
mmm..pi..3.14..
/(bb|[^b]{2})/
 
mmm..pi..3.14..'s Avatar
 
Join Date: May 2004
Location: Denver, CO
Posts: 2,740
Default

eh... just trying something.

Quote:
Originally Posted by tg
so the all the code necessary to make it work is all in one place, and it is portable
I was under the impression that's what _global variables and functions are for. You define it once and it is accessible everywhere

Quote:
Originally Posted by tg
you would need to move all of the global funcitons also....
If your talking about the fact that declaring the same function more than once would cause problems, easily can be solved by putting the following into the component script:

ActionScript Code:
if(myGlobalFunction == undefined){     _global.myGlobalFunction = function(){         //bla bla bla....    } }

Basically just think of it like this... you have a component but you don't want to have to refer to it relatively or absolutely throughout your code, (i.e. - _root.mc1.mc1_s1.myComponent.doSomething(); ), you just want to call the function from anywhere like a _global function
__________________
Eric Hainer
Unleaded Software
970.581.3387
Email: Eric followed by the AT symbol, unleaded software (one word) DOT com
Denver Web Design
mmm..pi..3.14.. is offline   Reply With Quote
Old 10-25-2006, 06:24 PM   #4
tg
done
 
Join Date: Jun 2001
Location: portland, or
Posts: 8,106
Default

if you make a component, then transfer it to a different project, if the new project does not have your function in it, it will return undefined. which is precisely why a component should have all code it uses defined within the scope of the component.
__________________
tg
---
what the hell was i thinking?
tg is offline   Reply With Quote
Old 10-25-2006, 07:20 PM   #5
mmm..pi..3.14..
/(bb|[^b]{2})/
 
mmm..pi..3.14..'s Avatar
 
Join Date: May 2004
Location: Denver, CO
Posts: 2,740
Default

Not sure we're on the same page. From what I gather, you think I'm talking about a component accessing _global functions from outside itself, right?

I'm actually talking about putting a _global function within a component, so wherever the component goes, the function goes with it. Does that make sense?

Let me know if I'm wrong, it is a rather confusing question.
__________________
Eric Hainer
Unleaded Software
970.581.3387
Email: Eric followed by the AT symbol, unleaded software (one word) DOT com
Denver Web Design
mmm..pi..3.14.. is offline   Reply With Quote
Old 10-28-2006, 09:40 PM   #6
mmm..pi..3.14..
/(bb|[^b]{2})/
 
mmm..pi..3.14..'s Avatar
 
Join Date: May 2004
Location: Denver, CO
Posts: 2,740
Default

nevermind, figured it out.

Turns out it had nothing to do with the _global property or the function or the fact that it was in a component. Just forgot to add in the classpath to the component definition, so the _global functions didn't know what they were supposed to call
__________________
Eric Hainer
Unleaded Software
970.581.3387
Email: Eric followed by the AT symbol, unleaded software (one word) DOT com
Denver Web Design
mmm..pi..3.14.. is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Loading Global Functions from External Clip honers Projectors and CDs 4 11-15-2006 04:21 PM
global functions StraySlakk ActionScript 2.0 1 02-07-2006 04:50 PM
functions don't display global vars compuboy1010 ActionScript 2.0 6 07-20-2005 10:35 AM
grids to global functions yorkeylady ActionScript 1.0 (and below) 0 01-29-2003 06:59 PM
Just a Hint: Global Functions Madokan ActionScript 1.0 (and below) 0 09-13-2002 09:53 AM


All times are GMT. The time now is 05:41 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.