4 Replies Latest reply on Aug 4, 2010 6:52 AM by celtrev

    How do I add flash cs4 game with AS3 to flash cs4 website??

    celtrev

      I have created a game in flash with ActionScript 3 and now want to add it to a website I have created with pages seperated into keyframes. Ideally, I am trying to have the game start when a link on the home page is selected. I would also like the users to be able to download the game themselves??? Any ideas for a flash novice??

        • 1. Re: How do I add flash cs4 game with AS3 to flash cs4 website??
          Ned Murphy Adobe Community Professional & MVP

          There are different approaches you can take.  You can copy the timeline of your game into a movieclip symbol in your main file and  incorporate it that way, or you can dynamically load the game file using  the Loader class (or alternatively, the UILoader component).

          • 2. Re: How do I add flash cs4 game with AS3 to flash cs4 website??
            celtrev Level 1

            Thank you so much!!! I just added it with a UI Loader Component! Worked really well... although it looks like doing that picked up an issue with some of my code? It's now looping over and over again and the counter within my game (for giving players their score - highlighted in red), is not working?If you are a AS3 guru any help would be greatly appreciated, otherwise thank you so much for your earlier tips

             

             

            package
            {
                import flash.display.MovieClip;
                import flash.events.*;
                import flash.utils.Timer;
                import flash.text.*;
               
                public dynamic class Gift extends MovieClip
                {
                   
                    private var dx:Number = Math.random() * 10; // make gift scurry
                    private var dy:Number = Math.random() * 10;
                   
                    public function Gift ()
                    {
                        this.gotoAndStop(Math.ceil(Math.random() * 4));
                        this.addEventListener(Event.ENTER_FRAME, scurry);   
                        stage.addEventListener(MouseEvent.MOUSE_DOWN, kill);
                    }
                   
                    public function scurry (e:Event)
                    {
                        if (this.x < 0 || this.x > 550)
                        {
                            this.dx *= -1;
                        }
                       
                        if (this.y < 0 || this.y > 576)
                        {
                            this.dy *= -1;
                        }
                       
                        this.x += this.dx; // make gift scurry
                        this.y += this.dy;
                    }
                   
                    public function die()
                    {
                        this.removeEventListener(Event.ENTER_FRAME, scurry);
                        parent.removeChild(this);
                    }
                   
                    private function kill (e:MouseEvent):void
                    {
                        if(e.target is Gift)
                        {
                            e.target.die();
                           
                            score += 10;
                            scoreText.text = score.toString();

                        }
                    }
                }
            }  

            • 3. Re: How do I add flash cs4 game with AS3 to flash cs4 website??
              Ned Murphy Adobe Community Professional & MVP

              You will be better off reposting this in the AS3 forum, explaining what got you where you are along with your code.  I do have a good handle on most aspects of AS3, but classes aren't one of my strong points.

              1 person found this helpful
              • 4. Re: How do I add flash cs4 game with AS3 to flash cs4 website??
                celtrev Level 1

                Thanks for your help anyway, I appreciate it.