Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 08-08-2008, 06:35 PM   #1
mousels
Registered User
 
Join Date: Apr 2007
Posts: 3
Default Buttons in Air

Hi all

I've recently started learning how to develop desktop things using Flash CS3 and Air. However, I'm having some problems with the basics of the Air scripting.

Not sure if I've done something wrong, but I cannot add actionscript to any of the buttons I create.

What I'm wanting to do is create a button that I'm going to place in one of the corners. When the button is pressed I'm wanting it to do is run the nativeWindow.close piece of actionscript.

Am I able to add the code the the button as I normally (directly onto the button itself)? Or do I need to create a function that will locate the button and run the code when the button is pressed?

Any help is appreciated

mousels
mousels is offline   Reply With Quote
Old 08-09-2008, 01:34 PM   #2
evride
2006 Man Of The Year
 
evride's Avatar
 
Join Date: Mar 2007
Posts: 919
Default

Actionscript 3 (which is what AIR uses) no longer allows putting code directly on a button. instead give the object you want to add actions to an instance name. its in the properties panel. then you can use that instance name to add event listeners to and change the properties.

ActionScript Code:
btn.addEventListener(MouseEvent.CLICK, buttonClick); function buttonClick(evt:MouseEvent){ stage.nativeWindow.close(); }

notice also that .onPress is no longer used in Actionscript3. instead you add an event listener of an event type. here i used the MouseEvent.CLICK event.
__________________
As long as people believe in absurdities they will continue to commit atrocities. --Voltaire
evride is offline   Reply With Quote
Old 08-09-2008, 02:14 PM   #3
mousels
Registered User
 
Join Date: Apr 2007
Posts: 3
Default

Thanks evdog! It all makes sense now.
mousels 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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
exe installer for AIR runtime and program evride AIR (Apollo) 1 09-14-2009 09:15 PM
Algorithm for repositioning buttons jfbaro ActionScript 2.0 2 12-21-2007 07:23 AM
Buttons that just won't leave... RQFlash ActionScript 2.0 5 07-25-2005 06:51 PM
LoadMovie and turn off buttons below billingsgate Other Flash General Questions 2 07-01-2005 03:58 PM
Buttons under buttons under buttons... Mortimer Jazz ActionScript 2.0 2 07-14-2004 12:27 PM


All times are GMT. The time now is 11:57 AM.

///
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.