Calling event functions from movieclips in actionscript 2

In a flash movie I usually have a frame of actionscript that controls all elements in the file to keep everything in one place.

Sometimes I have an onPress(etc) function that refers to something happening in the scene when something is pressed, but what happens if we want another element to refer to that event for some reason?

Here’s an example of that code without anything “flashy”:

_root.myMC.onPress = function() {
        //code goes here
}

..and here’s our slightly more intersting flashy version:

_root.myMC.onPress = _root.funcOnPress = function() {
        //code goes here
}

So now we can call the following from another place in the code to call the same event’s function:

//somewhere else in our flash file
_root.funcOnPress()

That’s about it folks!
Now you can call things from other places.
Just remember to not use “_root” if you are including your final swf inside another swf.


Share This Article

Related Posts

Comments

  1. Raghib suleman April 20, 2010

    thanks for nice tips

Trackbacks

There are no trackbacks on this entry.

Add a Comment

Required

Required

Optional

Latest Domains

1. weebly.com
(1 day ago)
2. whpromotions.co.uk
(1 day ago)
3. adsl24.co.uk
(1 day ago)
4. youryoungmodels.net
(1 day ago)
5. enom.com
(1 day ago)
6. dynect.net
(1 day ago)
7. websitewelcome.com
(1 day ago)
8. hostgator.com
(1 day ago)
9. uploading.com
(2 days ago)
10. soccernetghana.com
(2 days ago)

Services

PHP MySQL Apache Flash Air Java C++ Python