|
| Linking actionscript to .mxml file |
 |
Tue, 16 May 2006 11:35:09 +000 |
I am using Flex Builder 2 beta 2
can anybody tell me how to link an .as file to .mxml file...
this is my .mxml file which contains code for GUI. I want an event to occur on
the click of the Clear Button(i.e to call a function clearAll() which is
defined in .as file name Snippet.as)
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="<a target=_blank
class=ftalternatingbarlinklarge
href="http://www.adobe.com/2006/mxml"">http://www.adobe.com/20
06/mxml"</a>
xmlns="*" layout="absolute">
<Snippet id="calcHandlers" calcView=""/>
<mx:Panel title="my Calculator" themeColor="Blue"
id="panel1">
<mx:Label id="calcDisplay" width="150"
textAlign="right" />
<mx:Grid>
<mx:GridRow>
<mx:GridItem colSpan="2">
<mx:Button label="Clear" width="85"
click="calcHandlers.clearAll()"/>
</mx:GridItem>
<mx:GridItem> <mx:Button label ="C/E"
width="35"/> </mx:GridItem>
<mx:GridItem> <mx:Button label ="+"
width="35"/></mx:GridItem>
</mx:GridRow>
<!-- end of first grid row containing 3 cols-->
<mx:GridRow>
<mx:GridItem> <mx:Button label="1"
width="35"/> </mx:GridItem>
<mx:GridItem> <mx:Button label="2"
width="35"/> </mx:GridItem>
<mx:GridItem> <mx:Button label="3"
width="35"/> </mx:GridItem>
<mx:GridItem> <mx:Button label="-"
width="35"/></mx:GridItem>
</mx:GridRow>
<mx:GridRow>
<mx:GridItem> <mx:Button label="4"
width="35"/> </mx:GridItem>
<mx:GridItem> <mx:Button label="5"
width="35"/> </mx:GridItem>
<mx:GridItem> <mx:Button label="6"
width="35"/> </mx:GridItem>
<mx:GridItem> <mx:Button label="*"
width="35"/> </mx:GridItem>
</mx:GridRow>
<mx:GridRow>
<mx:GridItem> <mx:Button label="7"
width="35"/> </mx:GridItem>
<mx:GridItem> <mx:Button label="8"
width="35"/> </mx:GridItem>
<mx:GridItem> <mx:Button label="9"
width="35"/> </mx:GridItem>
<mx:GridItem> <mx:Button label="/"
width="35"/> </mx:GridItem>
</mx:GridRow>
<mx:GridRow>
<mx:GridItem > <mx:Button label="0"
width="35"/> </mx:GridItem>
<mx:GridItem> <mx:Button label="."
width="35"/> </mx:GridItem>
<mx:GridItem colSpan="2"> <mx:Button label="="
width="85"/> </mx:GridItem>
</mx:GridRow>
</mx:Grid>
</mx:Panel>
</mx:Application>
-------------------------------------------
package
{
class Snippet
{
public function Snippet():void
{
} //empty constructor
public function clearAll(): void
{
} // want to clear the label named calcDisplay defined in .mxml file or
putting some text on the label when user
// clicks on that label
}
}
|
| Post Reply
|
| Re: Linking actionscript to .mxml file |
 |
Tue, 16 May 2006 16:34:01 -070 |
Try making Snippet.as a public class.
package
{
public class Snippet
{
}
--
Jason Szeto
Adobe Flex SDK Developer
"RajeshBhadra" <webforumsuser@macromedia.com> wrote in message
news:e4cddd$bat$1@forums.macromedia.com...
>I am using Flex Builder 2 beta 2
> can anybody tell me how to link an .as file to .mxml file...
>
> this is my .mxml file which contains code for GUI. I want an event to
> occur on
> the click of the Clear Button(i.e to call a function clearAll() which is
> defined in .as file name Snippet.as)
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="<a target=_blank
class=ftalternatingbarlinklarge
>
href="http://www.adobe.com/2006/mxml"">http://www.adobe.com/20
06/mxml"</a>
> xmlns="*" layout="absolute">
> <Snippet id="calcHandlers" calcView=""/>
>
> <mx:Panel title="my Calculator" themeColor="Blue"
id="panel1">
> <mx:Label id="calcDisplay" width="150"
textAlign="right" />
>
> <mx:Grid>
> <mx:GridRow>
> <mx:GridItem colSpan="2">
> <mx:Button label="Clear" width="85"
click="calcHandlers.clearAll()"/>
> </mx:GridItem>
> <mx:GridItem> <mx:Button label ="C/E"
width="35"/> </mx:GridItem>
> <mx:GridItem> <mx:Button label ="+"
width="35"/></mx:GridItem>
> </mx:GridRow>
> <!-- end of first grid row containing 3 cols-->
>
> <mx:GridRow>
> <mx:GridItem> <mx:Button label="1"
width="35"/> </mx:GridItem>
> <mx:GridItem> <mx:Button label="2"
width="35"/> </mx:GridItem>
> <mx:GridItem> <mx:Button label="3"
width="35"/> </mx:GridItem>
> <mx:GridItem> <mx:Button label="-"
width="35"/></mx:GridItem>
> </mx:GridRow>
>
> <mx:GridRow>
> <mx:GridItem> <mx:Button label="4"
width="35"/> </mx:GridItem>
> <mx:GridItem> <mx:Button label="5"
width="35"/> </mx:GridItem>
> <mx:GridItem> <mx:Button label="6"
width="35"/> </mx:GridItem>
> <mx:GridItem> <mx:Button label="*"
width="35"/> </mx:GridItem>
> </mx:GridRow>
>
> <mx:GridRow>
> <mx:GridItem> <mx:Button label="7"
width="35"/> </mx:GridItem>
> <mx:GridItem> <mx:Button label="8"
width="35"/> </mx:GridItem>
> <mx:GridItem> <mx:Button label="9"
width="35"/> </mx:GridItem>
> <mx:GridItem> <mx:Button label="/"
width="35"/> </mx:GridItem>
>
> </mx:GridRow>
>
> <mx:GridRow>
> <mx:GridItem > <mx:Button label="0"
width="35"/> </mx:GridItem>
> <mx:GridItem> <mx:Button label="."
width="35"/> </mx:GridItem>
> <mx:GridItem colSpan="2"> <mx:Button
label="=" width="85"/>
> </mx:GridItem>
> </mx:GridRow>
> </mx:Grid>
> </mx:Panel>
> </mx:Application>
>
> -------------------------------------------
>
> package
> {
>
> class Snippet
> {
>
> public function Snippet():void
> {
>
> } //empty constructor
>
>
> public function clearAll(): void
> {
>
>
> } // want to clear the label named calcDisplay defined in .mxml file or
> putting some text on the label when user
> // clicks on that label
>
>
> }
> }
>
>
|
| Post Reply
|
| Re: Linking actionscript to .mxml file |
 |
Wed, 17 May 2006 11:10:21 +000 |
|
| Post Reply
|
|
|
|
|
|
|
|
|
|