In my Application, I have four mxml files and one ActionScript file. I want to know how I can access that one action script from 4 mxml files without Specifying <mx:Script source="one.as" any Idea?
3 Answers
Just remember the simple fact: file is a set of bits to store your data. The data stored in *.mxml and *.as files is programming code in OOP manner (in case of you're doing things right). So it has no sense to talk about files in this case. Lets talk about classes which are represented by MXML and AS files.
The directive <mx:Script source="one.as" is about files. I never use it because it is a kind of hack. Even Adobe itself uses includes only in case of embedding version number and some class metadata. I recommend you to forget about this hack at the beginning of learning Flex. You can use it wisely in the future (maybe or maybe not: I never use it only using old good OOP design principles and haven't any problems).
So now we realized about OOP and classes. So use MXML and AS classes using OO principles. This book can help you to learn OOP and design patterns.
As I said in my comment on the original question, and as @www.Flextras said in his last point, wrapping the AS functionality into a class is a great idea.
I would recommend one step further, as I did in my original comment, and create that class as an implementation of a singleton pattern. In this way, you're using a single instance of the class throughout an application, which will ensure the object is identical between MXML components.
Alternatively, if it works properly (hard to tell with no detail) you could also implement the functionality in static methods of some form of utility class, this would also be a good implementation.