A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Question about import flash.events.MouseEvent;

  1. #1
    Senior Member
    Join Date
    Dec 2004
    Posts
    459

    Question about import flash.events.MouseEvent;

    What is the purpose of a import flash.events.MouseEvent;?
    I am learning Actionscript 3.0 the tutorial tells me to use import flash.events.MouseEvent;. However, when I take it out it still works.
    Thanks for any help.

    Code:
    stop();
    import flash.events.MouseEvent;
    
    //--- G  Button Timeline change--\\
    //--- R Button Property change--\\
    
    R_btn.addEventListener(MouseEvent.CLICK,rClick);
    R_btn.addEventListener(MouseEvent.MOUSE_OUT,rOut);
    function rClick(event:MouseEvent):void{
    	R_btn.alpha-=0.1;
    }
    
    function rOut(event:MouseEvent):void{
    	R_btn.alpha =1
    }

  2. #2
    Bearded (M|G)od MyFriendIsATaco's Avatar
    Join Date
    Dec 2002
    Location
    Awesomeville.
    Posts
    3,045
    If you're putting that code directly onto the timeline, it's not required.

    What it's saying is to import the MouseEvents class before you can use it. But when you put code right on the timeline, it automatically imports most of the common classes. It's a hit or miss with which ones it includes. Meaning, I don't know.

    If you were writing code in external .as files and using your own classes, you'd HAVE you import every single class you use.

  3. #3
    Senior Member
    Join Date
    Dec 2004
    Posts
    459
    Quote Originally Posted by MyFriendIsATaco View Post
    If you're putting that code directly onto the timeline, it's not required.

    What it's saying is to import the MouseEvents class before you can use it. But when you put code right on the timeline, it automatically imports most of the common classes. It's a hit or miss with which ones it includes. Meaning, I don't know.

    If you were writing code in external .as files and using your own classes, you'd HAVE you import every single class you use.
    So what you're saying, is, if I do the code directly in my Flash project on it's timeline I wouldn't need that. However, if I were doing the Actionscript 3.0 on a external AS file I would need it. That's why it say Import Mouse Events?

    That make sense.

  4. #4
    Bearded (M|G)od MyFriendIsATaco's Avatar
    Join Date
    Dec 2002
    Location
    Awesomeville.
    Posts
    3,045
    You are correct. It's not hard to determine what's needed to be imported and what isn't. If you're using a class, and it tells you that it doesn't understand the class (I'm not sure what the exact error is, but you'll know), then you gotta import it. You'll eventually begin to figure out which ones you can use without importing.

    I never know because it's RARE when I use the timeline for code. Only when I'm writing up a quick test for something. So I'm just in a habit of importing everything.

  5. #5
    Senior Member
    Join Date
    Dec 2004
    Posts
    459
    Quote Originally Posted by MyFriendIsATaco View Post
    You are correct. It's not hard to determine what's needed to be imported and what isn't. If you're using a class, and it tells you that it doesn't understand the class (I'm not sure what the exact error is, but you'll know), then you gotta import it. You'll eventually begin to figure out which ones you can use without importing.

    I never know because it's RARE when I use the timeline for code. Only when I'm writing up a quick test for something. So I'm just in a habit of importing everything.

    So you usually just write the actionscript and an external file? Is that the way things are done these days with Actionscript 3.0?

    Is it a mistake for me to work on the timeline? Or, to each his own?

  6. #6
    Bearded (M|G)od MyFriendIsATaco's Avatar
    Join Date
    Dec 2002
    Location
    Awesomeville.
    Posts
    3,045
    It's not a mistake, it just matters with organization and complexity.

    You can't write your own classes from the timeline. I choose to write everything in my own classes because I tend to work on really complex objects that I wouldn't be able to do with timeline code. BUT, some people would argue that.

    Ahem, whispers.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center