Buttons in AS3.0... is there an easier way?

I am wondering if there is an easier way to create buttons in
3.0... I want to make an e-publication in 3.0 but am finding most
of the actions easier to do in 2.0. Should I generally use a
combination of these AS versions or am I missing something with
this endless array of 3.0 options? I am having troubles adapting to
the whole applying an action to a frame rather than button thing...
I have downloaded all the terminology from Adobe so that I can get
better adjusted, but it's always nice to read feedback from a real
person explaining a few simple things to me... links or comments
much much much appreciated!!!

cdbsoccer63,
vvirgill's answer is good, because it shows how easy AS3
buttons can be.
In fact, the nice thing about ActionScript 3.0 is that nearly
all event
handling is this easy, becuase nearly all of it is performed
the same way.
That is ...
someObject.addEventListener(
<an event to listen for>,
<what to do when the event occurs>
You can put that all on one like, like vvirgill showed, or
broken over
several lines, like I just showed with my own example. My
example isn't
literal code, so it wouldn't work if you typed that into the
Actions panel.
Like vvirgill did, you'd have to replace the <an event to
listen for> part
with the name of some event. For buttons, one of them is
"click", which
appears in quotes because it's a string (text). Then you'd
replace the
<what do do ...> part with the name of some function,
such as myListener(),
onClick(), or honestly, whatever name you like. I often use
clickHandler(),
but it doesn't matter, so long as the function name makes
sense to you (a
descriptive name is usually a good choice, such as
submitForm() or
orderPizza()). When you refer to your function as a parameter
inside the
addEventListener() method, you leave the parentheses off the
function,
because it's the parentheses that actually make the function
do its thing.
You don't want to trigger the function inside that
addEventListener()
method, but rather, in response to whatever event you'r
listening for.
So ... how do you know what events are valid for buttons --
or anything
else, for that matter? Look up the class entry for the object
you're
dealing with. If you're dealing with button symbols, look up
the
SimpleButton class. For movie clip symbols, look up the
MovieClip class.
For text fields, the TextField class, and so on. Each class
entry -- in
this case, in the ActionScript 3.0 Language and Components
Reference (F1
key) -- generally has three categories: Properties
(characteristics of the
object), Methods (things the object can do), and Events
(things the object
can react to). You'll find relevant events under the Events
heading, as you
can imagine. Many classes inherit frunctionality from other
classes, so
always make sure to click the hyperlink that says "Show
Inherited
Properties/Methods/Events" near each heading.
The documentation will show you things a bit differently
than vvirgill
showed. Instead of "click", for example, you'll find sample
code that shows
you MouseEvent.CLICK. Don't be thrown by that. All that means
is that the
"click" string is stored as a constant (an unchanging
variable) of the
MouseEvent class. You can reference that string by referring
to the
contstant, like this:
myButton.addEventListener(
MouseEvent.CLICK,
clickHandler
According to best practices, you should do it like that
(it's the more
"proper" way to go about it), but in the end, all that
contsant does is
point to the string "click", so they ultimately mean the same
thing.
Nearly every time, if an object has an event, you'll be able
to wire up
an event listener the same way youv'e seen now in this
thread. The only
exceptions I can think of are related to video (cue points
and status
messages, I think) -- but for everything else ...
myObject.addEventListener(someEvent, someHandler);
... and then, of course, you have to write out that what
"someHandler" is.
As vvirgill demonstrated, that's easy to. You need a function
declaration,
and then the code you want performed, and that's really all
there is to it.
You do have to write the function to accept one parameter:
function myFunction(param:Event):void {
... which I called param in that snippet (vvirgill called it
e). That
parameter gives you optional access to the event itself, and
the *type* of
parameter it is depends on the type of event that triggers
the function.
Strictly speaking, the MouseEvent.CLICK event is an instance
of the
MouseEvent class (just like button symbols are instances of
the SimpleCutton
class, movie clips are instances of the MovieClip class, and
so on). So
ideally, that parameter should be typed as MouseEvent rather
than Event:
function myFunction(param:MouseEvent):void {
... but only when the function is triggered in reponse to a
mouse click
(that is, a MouseEvent). Makes sense, right? The reason
vvirgill's example
isn't wrong is because the MouseEvent class inherits some of
its
functionality from the Event class, so mouse event objects
actually *are*
event objects -- the identification as such is true -- but if
you're
adhering to Adobe recommendations, you'll type your
parameters (and all
variables) specifically.
David Stiller
Co-author, Foundation Flash CS4 for Designers
http://tinyurl.com/5j55cv
"Luck is the residue of good design."

Similar Messages

  • HT1660 is there an easy way to delete the whole itunes library and and start again. I notice there is only an add file/folder button but no remove facility

    I recently upgraded to the iphone 5 and managed to sort the transition out with little trouble but noticed when I tried to put my music on that Itunes has messed with album info and either it or me has generated several copies of the same albums over the years and it makes it quite dificult to sort it all out before reloading on the phone. To stop the chaos I had hoped to clear the library and start again but cant find a way to do it. I was hoping to sort all my music out in original files and consolidate them into a proper folder. HOw do I do this. I notice there is an add fole and folder button but no take away??? is there an easy way?

    Use Shift > View > Show Exact Duplicate Items as this is normally a more useful selection. You need to manually select all but one of each group to remove. If you have multiple references to the same files then don't send to the recycle bin. Use my DeDuper script if you don't want to do it by hand. See this thread for background and please take note of the warning to backup your library before deduping.
    (If you don't see the menu bar press ALT to show it temporarily or CTRL+B to keep it displayed)
    tt2

  • HT204406 after this new itunes and ios7 update all my music is off my ipod touch unless i download them one artist at a time, i have over 3500 songs in there.  really?  is there no easier way to get my music back into my ipod?  like a download all button?

         after this new itunes and ios7 update all my music is off my ipod touch unless i download them one artist at a time, i have over 3500 songs in there.  really?  is there no easier way to get my music back into my ipod?  like a download all button?  thanks.

    thanks for the reply.  guess i'll have to do that.  apple, not really happy with what you've done with this latest update.  have not been able to enjoy my music in my car since the update.  most of us dont mind changes that progress timely, but this was much more than just a progression.  this was a complete change.  and not a good one, at all.  thanks to the two people that replied.  appreciate it.

  • Hello, Is there an easy way of understanding what menu language means before you press the button, for instance, DUPLICATE, does it mean delete duplicates or form them? Cyfrommayo

    Is there an easy way of understanding what to expect when I press something like DUPLICATE?
    Cyfrommayo

    Thanks Guys,
    Yes, SAVE AS makes sense now you have illustrated it. Would an opportunity to rename the copy file have been a good idea? Additionally, a place to save the copy, something like the old PC way?
    I got to this question, because of another incident which ended up with many duplicates, the help files did not know what the question DELETE DUPLICATE was? I have therefore ended up deleting individual duplicate files as a 'work around'. The learning curve hey.
    Regards,
    Cyfrommayo

  • Is there an easier way to do this?  Save As in Acrobat to a Specified Folde

    CAN APPLESCRIPT RUN IN THE BACKGROUND?
    Or is there an easier way to do this script? The script does what I need done - no problem, but every action happens on screen. Is there a more direct way to some of the steps? (Ideally so most of the action happens in the background. I will ALL-CAP what my thought process is).
    *BASICALLY I GET JOB REQUESTS FROM DEPARTMENTS IN MY COMPANY ON AN PDF THAT I CREATED. WHEN I OPEN THE REQUEST, I RUN THIS REQUEST SO I CAN IMPORT IT INTO FILEMAKER PRO. IT IS OPEN IN ADOBE ACROBAT PRO 9.*
    tell application "Adobe Acrobat Pro"
    activate
    end tell
    *I SIMPLY SAVE EVERY REQUEST AS "REPORT". IT JUST RESAVES EVERY TIME A NEW REQUEST COMES IN. SO I WANT TO STREAMLINE THIS STEP BETTER AND HAVE IT JUST SAVE IN THE BACKGROUND TO THE SPECIFIED FOLDER.*
    tell application "System Events"
    tell process "Acrobat"
    save
    click menu item "save as..." of menu "File" of menu bar 1
    keystroke "report"
    keystroke tab
    delay 1
    keystroke "g" using {command down, shift down}
    keystroke "/users/kellyf/documents/projects/pdf2fmp/ExportPDF"
    keystroke return
    keystroke "s" using command down
    delay 1
    keystroke "r" using command down
    *I BELIEVE THIS STEP HAS TO HAPPEN LIKE THIS, UNLESS SOMEONE IS FAMILIAR WITH A BETTER WAY TO EXPORT FROM ADOBE ACROBAT TO A CSV/SPREADSHEET FILE.*
    tell application "System Events"
    tell process "Acrobat"
    click menu item "Merge Data Files into Spreadsheet..." of menu 1 of menu item "Manage Form Data" of menu "Forms" of menu bar 1
    keystroke return
    delay 1
    keystroke "g" using {command down, shift down}
    keystroke "/users/kellyf/documents/projects/pdf2fmp/exportpdf"
    keystroke return
    delay 1
    keystroke (ASCII character 31) -- Down
    delay 1
    keystroke return
    delay 1
    keystroke tab
    delay 1
    keystroke return
    delay 1
    keystroke "g" using {command down, shift down}
    keystroke "/users/kellyf/documents/projects/pdf2fmp/ImportCSV"
    keystroke return
    delay 1
    keystroke (ASCII character 31) -- Down
    delay 1
    keystroke return
    delay 1
    keystroke tab
    delay 1
    keystroke return
    keystroke "s" using command down
    delay 1
    keystroke "r" using command down
    delay 1
    click button "Close Dialog" of window "Export Progress"
    end tell
    end tell
    end tell
    end tell
    tell application "Adobe Acrobat Pro"
    close document "report.pdf"
    end tell
    delay 1
    tell application "Finder"
    activate
    open file "Creative Job List.fp7" of folder "Filemaker Pro Databases" of folder "Documents" of folder "Kellyf" of folder "users" of folder "macintosh hd"
    end tell
    tell application "FileMaker Pro"
    activate
    do script "PDF2FMP Import"
    end tell

    Kelly Fisher wrote:
    CAN APPLESCRIPT RUN IN THE BACKGROUND?
    Yes. Applescript can run in the backgound. The applications you run also need to be able to run in the background. You need to run scriptable applications & avoid simulating the keyboard & mouse. You need to run commands that are in the application dictionary.
    *BASICALLY I GET JOB REQUESTS FROM DEPARTMENTS IN MY COMPANY ON AN PDF THAT I CREATED. WHEN I OPEN THE REQUEST, I RUN THIS REQUEST SO I CAN IMPORT IT INTO FILEMAKER PRO. IT IS OPEN IN ADOBE ACROBAT PRO 9.*
    tell application "Adobe Acrobat Pro"
    activate
    end tell
    *I SIMPLY SAVE EVERY REQUEST AS "REPORT". IT JUST RESAVES EVERY TIME A NEW REQUEST COMES IN. SO I WANT TO STREAMLINE THIS STEP BETTER AND HAVE IT JUST SAVE IN THE BACKGROUND TO THE SPECIFIED FOLDER.*
    tell application "System Events"
    tell process "Acrobat"
    save
    click menu item "save as..." of menu "File" of menu bar 1
    keystroke "report"
    keystroke tab
    You are simulating the keyboard. They need to run as you have done.
    delay 1
    keystroke "g" using {command down, shift down}
    keystroke "/users/kellyf/documents/projects/pdf2fmp/ExportPDF"
    keystroke return
    keystroke "s" using command down
    delay 1
    keystroke "r" using command down

  • Is there an easy way to replace/swap assets?

    I output my short from Avid, ran it through Compressor, and made a DVD in DVD Studio Pro.
    Now I've done some re-cuts and want to create a DVD of the new version, using the DVD Studio Pro file I used for the last DVD. Is there an easy way in DVD Studio Pro to "relink" the new video assets to replace the old ones in the new version? This would save me from rebuilding the main menu button, redesigning navigation, and recreating chapter marks.
    I have found a workaround - Quit DVD Studio Pro, "hide" the old assets in a folder, and then direct DVD Studio Pro to the new assets when it asks where the old assets are located. But I wonder if there is an easier way to do this from inside the program.
    Thanks very much for any advice!
    I am using DVD Studio Pro version 4.2.1

    Eric, thanks for chiming in.
    I assume you mean replace the old ones with the new ones on the Finder level?
    Well, part of my goal is to avoid destroying, re-naming, or moving the old assets.

  • HT1766 On an iPhone 5, Is there an easy way to move app icons as a group? instead of one by one?

    On an iPhone 5, Is there an easy way to move app icons as a group? instead of one by one?

    If you have a bunch of apps on one screen yunwantnto move to another as a group, create a folder by holding your finger on ne app until all the icons start shaking and show and "x" in the top left corner of the icon. Press again and don't lift your finger; move that icon with your finger over one of the other icons you want to add to the folder, which will create a folder. Then you can move the other apps you want to move into that folder. When you have all the apps you want to move into that folder, close the folder by tapping on the screen outside the folder. The icons should still be shaking. Then press on the folder you want to move and slide it to the edge of the screen, left or right, until the folder moves to the next screen. Once you get it to the screen of choice, you can leave the apps in that folder or move them out by the same process. When you are done moving things around, press the Home button and the icons will stop shaking. Now they will stay put.
    Alternatively,my can sync your device with iTunes and move the icons around in the Apps windows in iTunes, then re-sync your device after you're finished. That will rearrange your icons on the device.
    Good luck!

  • Is there an easy way to switch back and forth between apps on an iPhone 4?

    Is there an easier way to flip back and forth between apps without going through the Home button?

    By "going through the Home button" do you mean double tapping the Home button to bring up the recently used apps tray?

  • Is there an easy way to remove entries from my site?

    I am running out of iDick space. I don't want/need to purchase more. I would like to remove some older entries from my site. Is there an easier way than cut and pasting? I want to save then on my computer, for posterity?

    Hi Sharon!
    Wow, you must have a very extensive site to be running out of iDisk space! First of all, are you sure you haven't got some unutilized iDisk space sitting around....maybe reserved for email or something? You can change the allocation between iDisk space and Email storage in your .Mac account settings page. Let me know if you need help on doing this...
    If you really are running out of space, I can't think of a good way for you to back up a portion of your site locally and only publish the recent entries to your iDisk. As you already know, iWeb loves to publish it all...all the time! Maybe it's time to bit the bullet and just start a new site for your new entries going forward. Before you start the new site, you can backup a read only version of your website to a CD or something by using "Publish to Folder". Then once you are sure you have the working website locally, you can delete the site from iWeb once and for all and then start your new site.
    I know it's probably not ideal, but it's a suggestion. You can always "Publish to Folder" and save the resulting folder as a fully functional website to a CD. Keep in mind that if you use any .Mac-only features (like counters, comments, search, slideshows, etc) these features will not be functional on a "Publish to Folder" site.
    If you have found any of this information to be useful to you, please take the time to provide me with feedback by marking my reply as "solved" or "helpful" using those little buttons that you see in the title bar of this reply. I'd really appreciate it!

  • Is there an easy way to make JSpinner wrap around at max/min values?

    I have several pages with a couple dozen JSpinners to set various values - mostly numeric, but some are not.
    I would like to make them wrap around when either the max or min values are reached.
    Is there an easy way to do this?
    I was hoping for something like an "enableWraparound" property, but I haven't found such an animal.
    I suspect I could add value change listeners to all the components and do it by brute force,
    but there are too many spinners scattered around to make that an option I would like to take.
    Any suggestions?
    Thanks.

    Ok, it looks like custom spinner models are the way to go.
    Hopefully, I can create a couple that are generic enough to meet my requirements without too much pain.
    It looks like the ones I have already created will be easy enough to modify.
    Thanks for the feedback.

  • Is there an easy way to clear the contents of Download Folder?

    Is there an easier way to clear out files (send to trash) from the downloads folder, other than dragging one by one? The downloads folder closes immediately upon dragging one file out.

    You do not need to invoke Finder to do this. Create a new empty Automator workflow and use the "Run Shell Script" option. Paste in the following....
    mv ~/Downloads/* ~/.Trash
    You can then save the workflow as an application, attach it as a Finder action or add it to the scripts menu, whichever you like better.
    If you would like to bypass the Trash and just completely delete the Downloads folder contents immediately, then paste in this command:
    rm -rf ~/Downloads/*

  • Is there an easy way to reimport all songs in my itunes folder?

    This may sound like a weird question but here goes... When I bring up my iTunes I have 8731 files (mostly music) that come to about 41.33G's but when I right click on my iTunes Music folder and select properties there are 8809 files and a total of 48.5G's. I am trying to free up some disk space and can't figure out why there is such a difference. I had issues with Norton 360 and removed it but I had to restore my music files from an external drive and when I did so I lost the links for music that I added after my last back-up. I noticed that TV shows I bought from Apple were not in my iTunes but I was able to locate them in the folder, and import them back into iTunes. I have a feeling there are music files in my folders that are not linked to iTunes but can't figure out how to import them without going through all 8800+ files. Is there an easy way to import all the files without losing the current playcounts or a way to figure out which files may be duplicated in my iTunes Music folder. Seems like I am wasting 7G somewhere that I would like to recover. I already went through the duplicate songs and that didn't help. Any suggestions would be great...
    hp pc m260n   Windows XP   media center

    I have a feeling there are music files in my folders that are not linked to iTunes but can't figure out how to import them without going through all 8800+ files. Is there an easy way to import all the files without losing the current playcounts
    AFIK there isn't an easy way of linking up to a lot of dead tracks and retaining play counts etc, except by finding the dead tracks and repairing each link individually. The only exception to this is if there is a simple error in the path that can be fixed by a search and replace on the xml library file, then rebuilding the library. However it doesn't sound as though that would be a solution for you.
    This MacMuse tip has a way of finding dead tracks if that helps.
    http://discussions.apple.com/thread.jspa?threadID=121967
    It is much simpler to sacrifice the playcount information and just reimport your iTunes Music folder. Then you can eliminate the dead tracks with a script. One of the forum members has written one that you can find here:
    http://home.comcast.net/~teridon73/itunesscripts/

  • I am looking to "move out" of my computer and into my wife's, is there an easy way to accomplish this task, keeping all my files and setting up a second user?

    I just bought a new external 3TB hard drive for this task and want to keep my items seperate from hers for both our sanity.
    I figured that I would do a time machine back up and use that to do the move part of things.
    But as to setting up the new user on her computer I am just not sure if I can "tell" the computer to only use the new drive for my stuff and only acces the new drive for all things related to that new profile.
    More then anything else I want to be able to say that all things that are hers have not been touched/acccesed/deleted by any of my actions. And that I am "confined" to the new drive.
    I hope this makes sence.
    Mr Geef

    I have a feeling there are music files in my folders that are not linked to iTunes but can't figure out how to import them without going through all 8800+ files. Is there an easy way to import all the files without losing the current playcounts
    AFIK there isn't an easy way of linking up to a lot of dead tracks and retaining play counts etc, except by finding the dead tracks and repairing each link individually. The only exception to this is if there is a simple error in the path that can be fixed by a search and replace on the xml library file, then rebuilding the library. However it doesn't sound as though that would be a solution for you.
    This MacMuse tip has a way of finding dead tracks if that helps.
    http://discussions.apple.com/thread.jspa?threadID=121967
    It is much simpler to sacrifice the playcount information and just reimport your iTunes Music folder. Then you can eliminate the dead tracks with a script. One of the forum members has written one that you can find here:
    http://home.comcast.net/~teridon73/itunesscripts/

  • Is there an easy way to filter a 2-d array based on the values of two of the fields?

    Is there an easy way to filter a 2-d array based on the values of one of the fields. In my attached VI the output array has the following format:
    TimeStamp        Ident                Frame Type          Bytes    Data
    10:57:07.621   3AD00016   CAN Data Frame   8          0000000000000000
    10:57:07.622   3AD00017   CAN Data Frame   8          000005E000000000
    10:57:07.624   3AD00018   CAN Data Frame   8          0000000003300000
    10:57:07.625   2DC00000   CAN Data Frame   8          0000000000000000
    10:57:07.626   3AD00019   CAN Data Frame    4         0000030000000000
    I would like to delete any rows that do not have an "Ident" between the values of 3AD00000 and 3AD0001E. So for the above data the fourth row would be deleted. The only way I can see to do it is to form a 1-d array. Is there a better approach?
    Thank you.
    Solved!
    Go to Solution.
    Attachments:
    CMM_SN_MULTI.vi ‏20 KB

    Hi chuck72352,
    after you have sorted your data, you can use the InRange Function. Combined with a "search 1D Array" you'll get the range you really want.
    Mike
    Attachments:
    ArraySubset.PNG ‏25 KB

  • Is there an EASY way to submit podcasts to the itunes store? i've tried creating podcasts in garageband, then somewhere after wordpress  itunes  doesn't recognize the feed. my process has been (i am open to suggestions for other free and EASY services/me

    is there an EASY way to submit podcasts to the itunes store? i've tried creating podcasts in garageband, then somewhere after wordpress  itunes  doesn't recognize the feed.
    my process has been (i am open to suggestions for other free and EASY services/methods):
    garageband : create & edit audio. add 1400x1400 image.
    share to itunes.
    drag file to desktop.
    upload .m4a file to google drive.
    create a link post in wordpress using "podcast" tag & create "podcast" category.
    click on "entries rss" in wordpress, which takes me to the rss subscribe page (which is basically just my wordpress address with "/feed" at the end.
    i copy this url.
    go to itunes store > then "submit a podcast"
    itunes gives me the error message "we had difficulty downloading episodes from your feed."
    when i try to subscribe to my podcast in itunes, it does, but gives me no episodes available.
    i went back into wordpress and changed settings/ reading settings to : "full text" from "summary"
    still the same error message.
    i added a feedburner step after wordpress but got the same errors. i don't think i should have to add feedburner.
    wordpress seems to be encapsulating the rss, what am i doing wrong?
    this so much easier when you could go directly from garage band to iweb to mobileme; i miss those apple days (also idisk).

    if anyone has a super EASY process, i would LOVE to know what it is. EASY, meaning no html and also free. there are many free online storage systems available, many of which i currently use. the above process was just me trying to figure it out, if you have an easier method, please share. thank you so much!

  • Is there an easy way to generate a site map of an APEX application ?

    Hi.
    Is there an easy way to generate a site map of an APEX application ?
    Thanks.

    Depends on your definition of "easy"...
    Patrick Wolf provided one way to do this a few years ago.

Maybe you are looking for

  • Line Items

    Hi All, I would like to know why the Doc. number ( or order number) is considered as a Line item dimension whereas others are not? I know this is being a high cardinality but, what exactly it does to increase the size of the dimension table? If someo

  • Java.lang.class not found exception to .ez.EZmed.class

    error every time I try to access chat. have reloaded both the plug in and virtual machine. Nada. Can anybody help me? Thanks in advance

  • Integrating India localization taxes and iStore module

    Hi Gurus, We are implementing iStore module in R12. We already have Oracle financials for india setups implemented. We would like to select the tax category in iStore UI and apply the taxes before booking the order. Is this kind of feature available

  • Export iCal calendars with AppleScript

    How might I do this? Since the iCal ics files aren't in a neat and tidy place anymore, now I have to export. Can anybody help? Thanks so much! -Ben

  • Continuous 'Compiler File Error'

    I've tried to burn various projects recently and each time I am getting a 'Compiler File Error' message. Can anybody advise what I should do to get rid of this. It's a real pain! Basically I have various projects which I'm unable to build it at all.