View Full Version : Basics of ActionScript and Flex
theGuru
07-27-2009, 05:27 PM
I have a ActionScript class... which has a method...
public function checkSession():void {
}
Now i need to call
<mx:Panel id="as" x="225" y="87" width="784" height="510">
</mx:Panel>
I need to call the id of the panel in my method checkSession which is inside a class named Main.
rdrobinson3
07-29-2009, 06:52 PM
I am assuming the panel is inside part of your application. What you need to do is create an instance of your application and refference the id of the panel.
IE: myApp.myPanel
You could always pass a reference to the applicaiton or a reference to the panel when calling the function.
Frameworks like PureMVC really make this automatic. It can become really difficult in a complex program to keep up with the various mdules and components that make up your application otherwise.
Sekhar
07-30-2009, 04:03 PM
You could always pass a reference to the applicaiton or a reference to the panel when calling the function.
Yeah, I'd go this route, except: pass id rather than reference to full application. By passing the id, you make it easy to unit-test the function. This (dependency injection) is pretty much the norm these days.
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.