flash 方向箭头
前几天一个3D项目上要运用到 方向箭头(鼠标往哪移,箭头就转动一定的角度指向哪)!!
demo: http://6921.ggii.net/swf/ok.swf
操作是: 按下鼠标,并且移动鼠标观察效果!
下面将其代码贴出来:
MC是箭头影片剪辑 实例为arro
Circle 是一个转动的园 按下鼠标,固定在按下点处 实例 circle
代码是在时间轴上写的:
var arro:Sprite= Sprite(new MC());
var circle:MovieClip= MovieClip(new Circle());
arro.name="arro";
circle.name="circle";
stage.addEventListener(MouseEvent.MOUSE_DOWN,onDown,false,1,true);
stage.addEventListener(MouseEvent.MOUSE_UP,onUp,false,1,true);
stage.addEventListener(MouseEvent.MOUSE_MOVE,onMove,false,1,true);
addEventListener(Event.ENTER_FRAME,onFrame,false,1,true);
var tx,ty,gx,gy:int;
var isDown:Boolean;
function onDown(e:MouseEvent) {
isDown=true;
tx=e.stageX;
ty=e.stageY;
Mouse.hide();
addChild(circle);
positionCircle(tx,ty);
}
function onUp(e:MouseEvent) {
graphics.clear();
isDown=false;
Mouse.show();
if (getChildByName(circle.name)!=null) {
removeChild(circle);
}
if (getChildByName(arro.name)!=null) {
removeChild(arro);
}
}
function onMove(e:MouseEvent) {
gx=e.stageX;
gy=e.stageY;
if (isDown) {
addChild(arro);
arro.x=gx;
arro.y=gy;
}
}
function positionCircle(tx:int,ty:int) {
circle.x=tx;
circle.y=ty;
}
function onFrame(e:Event) {
// 处理鼠标旋转
var disX:int=gx-tx;
var disY:int=gy-ty;
var angle:Number=Number(Math.atan(disY/disX)*180/Math.PI);// atan返回的是弧度值,要转换为角度值
//if (disX == 0) { 这里不需要处理 这点是特殊点 可以忽略不计
//if(disY>=0){
//
//angle=90}else{
//
//angle=270
//
//
//
//}
//}
//
if (disX>0) {
//do nothing
}
if (disX<0) {
 
相关文档:
All metal heart shaped necklace containing an 8 GB USB flash drive.
These days a
USB flash drive
is as necessary as your house keys. Whether you are
taking large work files back and forth from the office or are sharing pictures
and music with friends, nothing beats the convenience of a USB ......
function getFlashVer() {//获得flashplayer的版本 google
var f="",n=navigator;
if (n.plugins && n.plugins.length) {
for (var ii=0;ii<n.plugins.length;ii++) {
if (n.plugins[ii].name.indexOf('Shockwave Flash')!=-1) {
f=n.plu ......
随着Flash型单片机的普及,单片机加密的技术已经有了较大的变化。下面本文将以Motorola的HCS12系列单片机为例,介绍一种典型的加、解密机制,并着重讨论使用密码加解密的方法以及相应的用户接口程序设计思路。
厂商利用单片机进行产品开发时,都会关心其代码和数据的保密性。考虑到用户在编写和调试代码时所付出的时 ......
ExternalInterfaceExample.as
以下示例演示了在 Flash Player 与 HTML 容器之间发送数据的过程。
package {
import flash.display.Sprite;
import flash.events.*;
import flash.external.ExternalInterface;
import flash.text.TextField;
import flash.utils.Timer;
import flash.text. ......