dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [RESOLVED] Problem creating package in Flash CS3

  1. #1
    Junior Member
    Join Date
    Aug 2007
    Posts
    9

    resolved [RESOLVED] Problem creating package in Flash CS3

    hi good day to all,

    Im reading this book about flash CS3 actionscript and we are in the packages topic. How do I write packages? Do i just have to select frame1 and Press f9 and start coding on the actionscript panel?

    I tried doing it but it gives me the error

    "packages cannot be nested package{"

    here's the code for tracing mouse events. your advice deeply needed.
    Pls help.


    package{
    import flash.display.Sprite;
    import flash.events.MouseEvent;

    public class MouseEvents extends Sprite{
    public function MouseEvents(){
    init();
    }
    private function init():void{
    var sprite:Sprite =new Sprite();
    addChild(sprite);
    sprite.graphics.beginFill(0xff0000);
    sprite.graphics.drawCircle(0, 0, 50);
    sprite.graphics.endFill();
    sprite.x=stage.stageWidth /2;
    sprite.y=stage.stageHeight /2;
    sprite.addEventListener(MouseEvent.CLICK,onMouseEv ent); sprite.addEventListener(MouseEvent.DOUBLE_CLICK,on MouseEvent); sprite.addEventListener(MouseEvent.MOUSE_DOWN,onMo useEvent); sprite.addEventListener(MouseEvent.MOUSE_MOVE,onMo useEvent); sprite.addEventListener(MouseEvent.MOUSE_OUT,onMou seEvent); sprite.addEventListener(MouseEvent.MOUSE_OVER,onMo useEvent); sprite.addEventListener(MouseEvent.MOUSE_UP,onMous eEvent); sprite.addEventListener(MouseEvent.MOUSE_WHEEL,onM ouseEvent); sprite.addEventListener(MouseEvent.ROLL_OUT,onMous eEvent); sprite.addEventListener(MouseEvent.ROLL_OVER,onMou seEvent);
    }
    public function onMouseEvent(event:MouseEvent):void
    {
    trace(event.type);
    }
    }
    }

  2. #2
    trace("AKA: Biro Barna");
    Join Date
    Oct 2007
    Location
    RO.Timişoara
    Posts
    1,403
    You don't create packages on the timeline. To create a package, go to File > New ActionScript file. It will open a new actionscript document, you have to write the code you posted inside that new AS file and save the file ( it will be saved with an extension of fileName.as ). After that is done, you must connect the package ( you class ) to your .fla... that can be done in 2 ways ( maybe 3 ): you declare your file as a Document Class or you create an instance of the class and use that.



    | Windows MSN: birobarna [at] hotmail [dot] com | Skype: barna.biro |
    WebLog: http://blog.wisebisoft.com/ |
    | Software Developer / Flash & Flex Developer | Student ( Computer Science ) | Interested in: Sharing Knowledge |
    |
    Romanian Adobe Flash, Flex, AIR Forum: http://www.flashforum.ro/
    | By perseverance the snail reached the ark. |


  3. #3
    Junior Member
    Join Date
    Aug 2007
    Posts
    9
    Thanks thats excellent. It worked. Thank you very much. More power to you

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