??Actionscript3.0 flash9 Preview
±¾ÎÄ×÷Õß:egoldy
ÎÄÕ³ö´¦:http://www.adobe.com
ÎÄÕÂÐÔÖÊ:??
ÔĶÁ´ÎÊý:36311
·¢²¼Ê±¼ä:2006-06-29
??Flash Professional Actionscript 3.0 Preview


      ???????????Adobe??http://www.adobe.com/devnet/flash/articles/flash9_as3_preview.html????Jen deHaan?Peter deHaan,????????????????????????????????????
      Adobe Flash Professional 9 ActionScript 3.0 Preview(????AS3.0???)?????????flash ?????????????????”Blaze”,????Flash Professional 8 ???????????Flash9 ?????????2007????
    ??????????Actionscript 3.0,?????????flash player 9 ?????????(AVM)??????????????Actionscript ?????????10?????????????flash player 9???????Flash Player Product page
       Flash9??????????????Fla??Actionscript3.0 ???????????????????????????????????
    ?????????Flash??????????????????????????????????????????????actionscript???????????????????????Flash???????
    ?????????Flash Professional 9 Actionscript 3.0 ?????

?FLASH???Actionscript 3.0

      Flash9 ??????????????????Flash??(FLA)???Actionscript 3.0,????????Flex Builder 2???As3.0.
Flash9??????????????Actionscript3.0?????????????????????????flash.display.MorphShape??abobe.utils package,static text fields,scenes,???
Flash9 ????????????:
1.Document class:
Flash9???document class??????????swf???????????????????????document class???????????????????Actionscript 3.0?????????document class,??File>Publish Settings > Flash tab > Settings button
????


2.Symbol-class linkage: (??-???)
?ActionScript 3.0????????id???????????????????????????????????????????????


3.????????????????????Flash???????????????????????????


4.Errors and warnings: ???????
??ActionScript 3.0 errors?warnings???????.????Actionscript 3.0?????????????Edit>Preferences > ActionScript > Actionscript 3.0?????????
—??Strict Mode,????????????????????????????????????????Warnings Mode,??????????????????Actionscript 2.0???As3.0????????????????Warning?????????EnabledWarnings.xml????Enabled????????????EnabledWarnings.xml??????
o Windows: C:\Program Files\Adobe\Flash 9 Public Alpha\en\Configuration\ActionScript 3.0\EnabledWarnings.xml
o Mac OS: HD|Applications|Adobe Flash 9 Public Alpha|Configuration|ActionScript 3.0|EnabledWarnings.xml


      
Creating clickable and draggable shapes??????????????

      ???????????flash9 ??????????????????????????????????????,??????????????????????????????????????

Clickable shapes(??????)

???????????????????
1. ????>?????????????simpleBall.fla.
2. ?????????????????????????????shift?????
????????????Object Drawing mode????????????
3????????????????????
4.  ?????????????modify>Convert to Symbol?????(?F8)??????????
5??????circle????ok,??????????
6? ????????????????????????????ball_mc
7? ??????????action??(F9).
8??Action??????????
´úÂë:
ball_mc.addEventListener(MouseEvent.CLICK, clickHandler);
function clickHandler(event:MouseEvent):void {
   trace("You clicked the ball");
}

???????ball_mc???????????????????????????????????????????????ball_mc?????clickHandler()?????????????????????????????As2.0??onPress()??????????????????
9???Control>Test Movie ????????????????????”you clicked the ball.
10???Swf????Flash?????????Actionscript ????????????????????
ball_mc.buttonMode = true;
11?????????,????????????????????????????????????????????

Draggable shapes(??????)

      ?????????????????????????????????mouseDown(MouseEvent.MOUSE_DOWN)?mouseUp(MouseEvent.MOUSE_UP),???????
??????????mouseDown?mouseUp?????????
1.???????????????
´úÂë:

ball_mc.buttonMode = true;
ball_mc.addEventListener(MouseEvent.CLICK, clickHandler);
ball_mc.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownListener);
ball_mc.addEventListener(MouseEvent.MOUSE_UP, mouseUpListener);
function clickHandler(event:MouseEvent):void {
  trace("You clicked the ball");
}
function mouseDownListener(event:MouseEvent):void {
   ball_mc.startDrag();
}
function mouseUpListener(event:MouseEvent):void {
   ball_mc.stopDrag();
}

2.?????????????????
??????????????????????????????????????????????????????????????????????,???????????????????????????????????????

Converting code into a class(?????????)

?????????Actionscript????????????????????????????????????????????????????????????????????
1.??????Fla????????fancyBall.fla.
2.??File>New??Actionscript File??????Actionscript???
3.????Actionscript???Ball.as?Fla?????????????????fancyBall.fla.
4. ??????????
´úÂë:
package {
  import flash.display.MovieClip;
   import flash.events.MouseEvent;
   public class Ball extends MovieClip {
      public function Ball() {
         trace("ball created: " + this.name);
         this.buttonMode = true;
         this.addEventListener(MouseEvent.CLICK, clickHandler);
         this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownListener);
         this.addEventListener(MouseEvent.MOUSE_UP, mouseUpListener);
      }
      private function clickHandler(event:MouseEvent):void {
         trace("You clicked the ball");
      }
      function mouseDownListener(event:MouseEvent):void {
        this.startDrag();
      }
      function mouseUpListener(event:MouseEvent):void {
         this.stopDrag();
      }
   }
}

       ??????????????Ball,????MovieClip?(???flash.display package?).?????As3.0????????????????????????Fla???????
5??????Ball.as???????fancyBall.fla???
6. ??????????????????????movieClip.
7???????????????
8???Export for ActionScript(?action??)??Class(?)?????????Ball
9???ok.??????
10??????????????????????????????????
????????????????????????????

Dynamically creating instances of a class?????????

      ????????????????????????????Actionscirpt????????????????

Using the new operator????????

     ???Actionscript?????MovieClip??TextField?????????MovieClip.attachMovie(),MovieClip.createEmptyMovieClip(),?MovieClip.createTextField().??????ActionScript 3.0??????????new Ball()???????MovieClip,TextField,Sprite,?Video ??—??????????????
1.??fancyBall.fla.???????????????????????????
´úÂë:
var b1:Ball = new Ball();

2.??ctrl +??????????????????????????????????????“ball created: instance1”,??Flash???ball???????????????????????addChild()???????????
3.??????b1??????????????
´úÂë:
addChild(b1);


     ????????document class,??????????????????????????????????????????????.

Using the Document Class text box(??Document class???)

???????????????????????As????
1.??fancyBall.fla????????
2.??????Actionscript?????BallDocumentClass.as??fancyBall.fla????????
3.???????BallDocumentClass.as??
´úÂë:
package {
   import flash.display.MovieClip;
   public class BallDocumentClass extends MovieClip {
      private var tempBall:Ball;
      private var MAX_BALLS:uint = 10;
      public function BallDocumentClass() {
         var i:uint;
         for (i = 0; i < MAX_BALLS; i++) {
            tempBall = new Ball ();
            tempBall.scaleX = Math.random();
            tempBall.scaleY = tempBall.scaleX;
            tempBall.x = Math.round(Math.random() * (this.stage.stageWidth - tempBall.width));
            tempBall.y = Math.round(Math.random() * (this.stage.stageHeight - tempBall.height));
            addChild(tempBall);
         }    
      }
   }
}

4.???????as?????fancyBall.fla.
5.??????document class?????????BallDocumentClass??????
6.????????10?????????????????
??Document Class?????????????????????????????fla????????????????????(CVS)?,????????

???

       ???????As3.0???????????????????????????????????????????document class.

Ps by egoldy:???????????????????fla????????????????????????????????????????????As3.0??????????????Cheers J.

?????

?????



   
 
Copyright (C) 2004 websudio Team All Rights Reserved.