A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: How do I access an as3 file class from the document class

  1. #1
    Junior Member
    Join Date
    Sep 2011
    Posts
    5

    How do I access an as3 file class from the document class

    Hi, please help, it seems simple, but it doesn't seem to be working I have 2 as3 files as classes "mainclass.as3 (this is the document class)" and GamePlay.as3

    the GamePlay class works flawlessly on it's own, but when i try to create the var to access it ... var gp:GamePlay=new GamePlay(); ... i get the following error. can someone post an example on how this should work?

    I have looked at tutorial etc, but i cant get it to work i am currently getting the following error.

    Error: Error #2136: The SWF file file:///C|/LAPTOP/Games/mygame/mygame.swf contains invalid data.
    at mainclass/begin()
    at MethodInfo-139()


    Please help


    Actionscript Code:
    package{
        import flash.display.*;
        import flash.events.*;
        import flash.text.*;
        import flash.events.MouseEvent;
        import GamePlay;
       
        public class mainclass extends MovieClip{
           
            public function mainclass():void{
                gotoAndStop(1, "Main Menu");
               
               
            ply_btn.addEventListener(MouseEvent.MOUSE_UP, myBtnHandler1);
                function myBtnHandler1(event:MouseEvent):void {
                    gotoAndStop(1, "Game");
                    begin();
                };
               
               
            }
           
            public function begin(){
                    var gp:GamePlay=new GamePlay();
                    gp.startGame();
                }

        }
    }
    Last edited by flashruns; 10-03-2011 at 01:47 PM.

  2. #2
    Senior Member
    Join Date
    May 2010
    Posts
    178
    Avoid using Scene in AS3 coding habit.

    Post your GamePlay Class.

    poltuda
    Last edited by poltuda; 10-03-2011 at 04:38 PM.

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