Having trouble utilizing event functions in a class.

I am trying to write button code in a class, so my main actions panal of my .fla doesn't get too overcrowded. Here is my class coding:
package grid {
import flash.display.*;
import flash.events.*;
public class g1x1 extends MovieClip {
  public function activateGrid() {
   this.addEventListener(MouseEvent.CLICK, onMouseClickEvent);
  function onMouseClickEvent(event:Event):void {
   trace("mouse clicked on me");
Then on my main timeline I call to that class using:
instance:g1x1 = new g1x1();
instance.activateGrid();
I have also tryed linking the button, using export for actionscript, but I don't know what I'm doing wrong I keep getting errors when I try to compile.
I know something is wrong with my code, I'm used to assigning code right onto the buttons in AS2.
Can sombody tell me what I'm doing worng?
Thanks
Matt.

This is how it should look like:
Class:
package grid {
import flash.display.*;
import flash.events.*;
public class g1x1 extends MovieClip {
public function g1x1()
public function activateGrid()
   this.addEventListener(MouseEvent.CLICK, onMouseClickEvent);
private function onMouseClickEvent(event:Event):void
   trace("mouse clicked on me");
your document class or timeline or .as
import grid.*;
private var myGrid1x1:g1x1 = new g1x1();
myGrid1x1.activateGrid();

Similar Messages

  • Having problem with Event function in Photostream

    Since the upgrade I find that the event function is no longer separating my uploaded photos by date of taking them so they are now all in one bucket so to speak instead of each day of the holiday. Why has this happened and have others had a similar issues? 

    Hi Markus,
    If I understand it correctly then you have a dropdown box and on the basis of value selected in dropdown box you need to filter the records displayed in the table view below...
    If this is the requirement then you will have to write your custom code to filter data. For your dropdown field redefine get_p_xxxx to add a server event once the value is selected in dropdown box.
    Please refer to:
    Re: Tableview - get changed data event???
    Since server round trip would be triggered you can loop on data from your context and filter it in do_prepare_output or else you can create your event handler as well...
    e Regards,
    Bhushan

  • Grapher having trouble with trig functions

    Well I thought that I could make some cool visuals for my math class by using grapher instead of just making charts and graphs in Excel on my pc, but no dice with that idea. I created all the different variables (and how they related to x, ie x^2*(5-x6)/x=m) and it was pretty cool how it would all come together and I could use those variables in other equations instead of writing it all out (stuff like y=4x^m-m/5). (Those are examples, not anything I used)
    Everything seemed fine until I tried to use a cosine function in one of the equations. It seemed really intuitive and recognized cos as cosine and not the variables c, o, and s multiplied, so I thought "great!" Then when I entered it the graph didn't appear anything like it should have. It gave me a Richter scale instead of a slightly curved line. I spent about half an hour trying to find my own error but then realized maybe there was something wrong with the program. I tried just plain old cos(x) and found that it was completely off. Instead of traveling from 0,1 to 180,-1 like it should have, it went from 0,1 to 3.1475,-1. This was way off so I tried a sine function and that did the same exact thing (having a period of roughly 6.295 instead of 360!). These functions were way off, and I'm using an intel macbook from my school (with 10.5), so I thought maybe someone changed the settings, so I tried them them on my aunts g4 macmini (10.4.11 I think) and it gave me the same problem!
    Anyway what's wrong with the trig functions for Grapher and how can I fix them?

    Emzz, I'm running 10.5.5 (Intel) and Grapher v2.0. My version of Grapher supports changing Trigonometric Mode, so the absence of this option seems to have nothing to do with Leopard.
    But let's do some Math now. As you surely know the cosine has (besides others) a root at 90 Degrees in the unit circle. Now let f : (angle in Degrees) -> (length of the corresponding arc of the unit circle) be a mapping. For 90 Degrees f yields 0.5*Pi. That means cosine has a root at 0.5*Pi in Radian unit.
    Now, if you swith Grapher's Trigonometric Mode from Degrees to Radian, cosine will no longer have a root at 90 but at approximately 1.57. Hope that explains a bit...
    By the way, Radian is the standard unit of angular measurement when it comes to trigonometric functions. For more details about Radian see [this article at Wikipedia|http://en.wikipedia.org/wiki/Radian] (click the link to be redirected).
    I suggest you close this topic because, as you already noted yourself, your initial question is answered.
    Good computing.
    floba
    (MN576)
    Message was edited by: floba

  • I am having trouble implementing scripting functionality in an indesign template for a DPS project.

    Basically how should the interaction between inserted HTML and the CSS, JS applied for the HTML happen?
    I created plain HTML code which has text fields, buttons and the functions that perform some simple calculations. But when imported via Object>Insert HTML the HTML functionality was lost. I then tried creating and exporting an indesign template which contained all the buttons required for the calculation as a HTML file via File>Export option, added modified HTML code and then used Object>Insert HTML. But no luck.
    Is there a better way to import and/or how do we initiate a button to be used via scripting? (Eg: convert a image into a button in indesign, but.... how best to initiate a "onClick" function for the button created via Js or Jquery).

    I'm having the same issue. And Dreamweaver now crashes after just a few seconds.

  • I am having trouble with a function in vb can anyone give me a suggestion?

    I am trying to calculate a cable bill of a residential customer and a business customer, when the customer checks the list box of the channels and the connections I need it to add it up. I have edited the code. Does my logic make sense?
    for residential customers it is 4.50 processing,30 basic service and 5 per channel
    so is the logic processing+basicservice *premium
    Public Class Main
    Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
    If Data_Validated_ok() = False Then Exit Sub
    Dim premiumChannels As Integer = lstPremium.SelectedIndex
    Dim Connections As Integer = lstConnections.SelectedIndex
    Dim totalDue As Decimal
    If radResidential.Checked Then
    totalDue = CalcResidentialTotalDue(premiumChannels, Connections)
    lblTotal.Text = totalDue.ToString("C2")
    Else
    totalDue = CalcBusinesssTotalDue(premiumChannels, Connections)
    lblTotal.Text = totalDue.ToString("C2")
    End If
    End Sub
    ' make a function to calculate residential customers
    Private Function CalcResidentialTotalDue(ByVal premiumChannels As Decimal, ByVal connections As Decimal
    ) As Decimal
    Const ResidentialProcessing As Decimal = 4.5D
    Const ResidentialBasic As Integer = 30
    Const ResidentialPremium As Integer = 5
    Return ResidentialProcessing + ResidentialBasic + ResidentialPremium * premiumChannels
    End Function
    ' make a function to calculate business customers
    Private Function CalcBusinesssTotalDue(ByVal premiumChannels As Decimal, ByVal connections As Decimal
    ) As Decimal
    Const BusinessProcessing As Decimal = CDec(16.5)
    Const BusinessBasic As Integer = 80
    Const BusinessPremiumchannels As Integer = 50
    Return BusinessProcessing + BusinessBasic + BusinessPremiumchannels * premiumChannels
    End Function
    here is  a pic of my listboxes
    [IMG]http://i57.tinypic.com/muepug.png[/IMG]
    http://i57.tinypic.com/muepug.png

    The statement below is wrong in both functions.  You are passing the variable "connections" in the function parameter list and not using the variable.  I thing in the statement below you need to change connections to something else.
    connections = Convert.ToDecimal(lstConnections.SelectedItem)
    Here are the two parameter lists
    1)    Private
    Function calcResidentialTotal(ByVal connections
    As Decimal,
    ByVal premium As
    Decimal)
    As Decimal
    2)   Private
    Function calcBusinessTotal(ByVal connections
    As Decimal,
    ByVal premium As
    Decimal)
    As Decimal
    jdweng

  • Having trouble using a vector from another class

    have a vector in an addresbook class but when I try to acess the vector to write its object to a file from a write class, it doesn't resolve the symbol for the variable. How to I use the same same vector across different classes.
    thanks

    try this,
    class AddressBook {
      private Vector v;
      void yourmethod() {
        Vector someVector = (Vector) someoperation();
        setVector(someVector);
      public void setVector(Vector pVector) {
        this.v = pVector;
      public Vector getVector() {
        return v;
    class Different {
      void meth() {
        AddressBook ab = new AddressBook();
        //now you have access
        Vector recdVector = ab.getVector();
    }good luck !

  • Having trouble with put_line function in block statement..

    Am a student, and the request does not appear to be in my book anywhere... Nothing on put_line, or block statements that I can see..
    Need to write a block which will bring back via put_line for department 110: the department_id (departments table), the department_name (departments table), and the city in which the department is located (which must be pulled from locations table... can be joined by department_id). I can write the select statement with join, just not sure how to turn it into a block with put_line function..
    any advice appreciated.. Thanks.

    Hi,
    You need to format your code, so that it's easy to see what statements are in each section (DECLARE, BEGIN, etc.).
    The compiler doesn't care about this, but it will help anyone who tries to read your code, including yourself.
    Type {code} before and after formatted sections when posting messages on this site.
    All statements, including each individual variable declaration) end with a semicolon.
    If a query will return no more than one row, you can capture the results using an INTO-clause, right after the SELECT-clause. For every column in the SELECT-clause, there will be one variable in the INTO-clause.
    Lists, including lists of table names in a query's FROM-clause, are delimited by commas.
    In a query's FROM-clause, the real name of the table comes first, optionally followed by the alias you're using in the query.
    I think this is what you're trying to do:
    SET   SERVEROUTPUT  ON  SIZE 50000
    Declare
        dep_id    NUMBER;
        Dep_string VarChar (100);
    Begin
        select  d.department_id, d.department_name -- , l.city
          into  dep_id,          dep_string
          from  departments  d
             ,  locations    l
          where d.location_id = l.location_id
            and d.location_id = 110;
        DBMS_OUTPUT.PUT_LINE (Dep_string);
    END;
    /No one should ever have this many errors at one time. Write code in much smaller increments, and test after each one. For example, you know you'll be using dbms_output.put_line, so start with something like:
    SET   SERVEROUTPUT  ON  SIZE 50000
    BEGIN
        dbms_output.put_line ('Hello, world!');
    END;You may have problems if you forget semicolons, or SET SERVEROUTPUT. Solve those before you go any further.
    Once the program above is working, add a little (and I mean a little) to it.
    For example, you know you'll be printing a varibale, not a literal, so change it to a variable:
    SET   SERVEROUTPUT  ON  SIZE 50000
    DECLARE
        dep_string  VARCHAR2 (100) := 'Hello, world!';
    BEGIN
        dbms_output.put_line (dep_string);
    END;And so on.
    Edited by: Frank Kulash on Dec 15, 2008 12:36 PM

  • Having trouble deleting event from Calendar

    How do I delete an event from Calendar on iPhone 4s. Syncs with computer but does not delete event. When I follow instructions in user guide, can't do

    connect your ipod to itunes and go onto your ipod options on itunes. go to photos and reselect the album you want to transfer onto your ipod.

  • I'm having trouble deleting events from my calendar.

    Why is it that when I delete an event it comes right back? I don't any clue how to delete events from my calendar. Please get back to me with am answer.
    Thanks

    You are not doing it right see:
    http://support.apple.com/kb/ht1855

  • Anyone having trouble w/ iPod function?

    I was up and running in a breeze...very impressive. Unfortunately, I had some issues w/ iPod freezing right off the bat...then, for a few hours I had no problem other than the speaker sounding pretty lame...tonight, when I finished syncing, my entire music Library disappeared (from the iPhone). The iPhone memory shows it to be there and when I sync w/ iTunes, the memory bar shows I have music on the iPhone. However, when I tap the iPod widget, there is NO music, no playlists, nada, nothing. I just reset and erased the entire phone and am starting over. Hope it works. Downloading 1300+ songs takes forever.
    iMac, Powerbook   Mac OS X (10.4.10)  
    iMac, Powerbook   Mac OS X (10.4.10)  
    iMac, Powerbook   Mac OS X (10.4.10)  

    I've had a similar problem as those discussed here. I've sync'ed my iPhone, when it's complete it says there's more than 3G of audio. When I eject/unplug the iPhone, there's no music under the iPod tab. I had this happen yesterday, too.
    At that point, I restored (but lost all my previous text messages).
    It happened again tonight, the sync showed that the iPhone was full of music but there wasn't any on the device. I unchecked sync music and let it erase all the music data (it took a couple of tries). Now I am reloading all the music. How can this be avoided? It makes me scared to sync!
    BTW, I love it otherwise:)

  • HT201250 I am having trouble setting up my time capsule.  the amber light is flashing.  i have a Verizon FIOS network that i use for the internet (WiFi) and do not want to configure the Time Capsule to do that function.  I just want the Time Capsule to ba

    I am having trouble setting up my time capsule.  the amber light is flashing.  i have a Verizon FIOS network that i use for the internet (WiFi) and do not want to configure the Time Capsule to do that function.  I just want the Time Capsule to back up.

    Simple.. bridge the TC.. in the apple utility in the NAT and DHCP area.
    Plug it into the FIOS router.. you can turn off wireless in the TC if you want.. or use it.. it can work faster if you are nearby and can select 5ghz.. but up to you.

  • I have a new MacBook and I'm having trouble with the help section. I would like to rearrange the order of my photos with in an Event, how do I do this? I follow the directions but it will not work. Thanks for some tips.

    I have a new MacBook Pro and I'm having trouble with some of the Help sections. I want to rearrange the order of my photo's within an Event. I have followed the directions but it will not let me do it, what am I missing?  Thanks for any tips.

    Are you talking about iPhoto? If you are please post this in the iPhoto forum, thanks!

  • TS2776 having trouble syncing google calendar.  If I add event to my calendar using my ipad mini, it won't appear on my google calendar when Im viewing it using my computer or phone.  However, if I post an event using my phone or computer, it appears on i

    Im having trouble syncing google calendar.  If I add event to my calendar using my ipad mini, it won't appear on my google calendar when Im viewing it using my computer or phone.  However, if I post an event using my phone or computer, it appears on ipad mini, why is this and how do I fix it to where everything syncs both ways?

    let me ellaborate on this part:
    "b) perhaps I've got some kind of virus on mine?"
    I mean, " perhaps I've got some kind of virus on mine, and I've passed it on to hers?"

  • Is anyone having trouble connecting to the adobe send functionality currently?

    Is anyone having trouble connecting to the adobe send functionality currently?

    What problem are you having? Signing in? Uploading files to send? Actually sending the files? Are you using the Anonymous Link or Personalized Invitations option?
    The more details you can provide, the better we can assist.

  • Having trouble with Tiscali/TalkTalk site when accessed with 'FireFox', can't 'reply' to emails or report 'spam', other functions seem ok

    Having trouble with Tiscali/TalkTalk site when accessed with 'FireFox',
    can't 'reply' to emails or report 'spam', other functions seem ok
    == This happened ==
    Every time Firefox opened
    == On/Off few months now all time

    Try deleting cookies and cache:
    1. Tools| Clear recent history
    2. Time range to clear: Everything
    3. If it isn't already selected, select '''Cookies''' and '''Cache'''
    4. '''Clear now'''
    <u>Check cookie exceptions</u>
    1. Tools | Options | Privacy Panel
    2. Set '''Firefox will: Use custom settings for history''' Insure Accept cookies for sites and accept third-party cookies is selected
    3. Click '''Exceptions'''. If the misbehaving site is in that list, select it and click '''Remove site'''
    Also see [[Updating Firefox]]

Maybe you are looking for