dcsimg
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: [RESOLVED] event listener folder question

  1. #1
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588

    resolved [RESOLVED] event listener folder question

    I'm using the following .as file for events ....this works well but only if its in the same folder as the .swf I'd like to move it to a diffrent folder.How do i modify the code so i can aceess it in a diffrent folder.

    event file

    PHP Code:
    package {
        
    // Import class
        
    import flash.events.Event;
        
    // EventType
        
    public class EventType extends Event {
            
    // Properties
              
    public var arg:*;
              
    // Constructor
              
    public function EventType(type:Stringbubbles:Boolean falsecancelable:Boolean false, ... a:*) {
                   
    super(typebubblescancelable);
                   
    arg a;
               }
            
    // Override clone
            
    override public function clone():Event{
                return new 
    EventType(typebubblescancelablearg);
            };
        }

    dipatcher
    PHP Code:
    dispatchEvent(new EventType("TYPE_NAME",false,false,"arg1","arg2")); 
    ~calmchess~

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    The .as file is only necessary during compilation. After you have a swf, you don't need to deploy the .as file with it.

    To use a .as file in a directory other than the current directory, you'll have to add that directory to your classpath. You could also put it in a package, which will let you (force you) to have a directory structure which mirrors the package structure.

  3. #3
    Senior Member joshstrike's Avatar
    Join Date
    Jan 2001
    Location
    Alhama de Granada, España
    Posts
    1,131
    If the folder relative to your .fla file was lib/events/
    you'd just change the first line of your code to
    package lib.events {
    and then in whatever was calling it, make sure you
    include lib.events.*;

  4. #4
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    nevermind this event handeler doesn't work with my application....I don't understand how the event .as file ties to the dispatchevent and addlisteners that exsist in seperate .as files
    ~calmchess~

  5. #5
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    .as files are almost always used to define a single class. That class can then be imported and used in other code, including other classes as defined in .as files.

    The code you posted above is not an event handler, rather it was a subclass of Event. It lets you create a new Event with extra data. I'd have named it differently, but overall it looked like a good idea.

  6. #6
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    oh ok 5TonsOfFlax i'm getting AS 3.0 more now that you reminded me of the ways to connect my AS 3.0 there are so many that my brain gets bogged down.Slowly its coming into focus though.
    ~calmchess~

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