用Flash Builder4.5.1发布了一个加载本地文件夹中的SWF文件,运行发现报错“Local-with-filesystem and local-with-networking SWF files cannot load each other.”,查后,知,可在当前工程属性的编译条件中加入-use-network=false
Archive for Flex
无法加载本地SWF
关于ActionScript Project中Preloader的解决
在使用Flex建立as的Project后,总是会希望显示出加载的进度,用loaderInfo的ProgressEvent来监听是不成功的,那么可参照以下方法,来实现AS应用的两桢法。
首先,建立了一个ImageGrallery的Project,其中包括ImageGrallery.as与AdPlayer.as。
然后,修改当前应用的Compiler,在其中添入“-frames.frame ImageGallery ImageGallery -generate-frame-loader=true”,(About the application compiler options)。
接着,目标是希望AdPlay能加载ImageGrallery,AdPlayer的代码如下:
package { import flash.display.DisplayObject; import flash.display.MovieClip; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.events.Event; import flash.text.TextField; import flash.utils.getDefinitionByName; public class AdPlayer extends MovieClip { private var preText: TextField; public function AdPlayer() { stop(); stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; preText = new TextField(); addChild(preText); addEventListener(Event.ENTER_FRAME, onEnterFrame); } public function onEnterFrame(event:Event):void { graphics.clear(); if (framesLoaded == totalFrames) { removeEventListener(Event.ENTER_FRAME, onEnterFrame); removeChild(preText); preText = null; nextFrame(); onInit(); } else { var percent: Number = root.loaderInfo.bytesLoaded / root.loaderInfo.bytesTotal; preText.textColor = 0xFFFFFF; preText.text = (percent * 100).toFixed() + " %"; preText.x = (stage.stageWidth * percent - preText.textWidth) / 2; preText.y = (stage.stageHeight - preText.textHeight) / 2; graphics.beginFill(0); graphics.drawRect(0, stage.stageHeight / 2 - 10, stage.stageWidth * percent, 20); graphics.endFill(); } } private function onInit() : void { var playerClass: Class = Class(getDefinitionByName("ImageGallery")); if (playerClass) { var playerInstance: Object = new playerClass(); addChild(playerInstance as DisplayObject); } } } }
设置AdPlayer.as为Default Application,运行后,嘿嘿,OK了。(运行)
注:如果想用ImageGrallery为主应用程序,那么ImageGrallery的程序可以如下:
package { import com.biztv.player.PlayerContext; import flash.display.Sprite; import flash.events.Event; [Frame(factoryClass="AdPlayer")] // 此处为关键 public class ImageGallery extends Sprite { protected var context: PlayerContext; public function ImageGallery() { addEventListener(Event.ADDED_TO_STAGE, onAddedToStage); } private function onAddedToStage(event: Event):void { removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage); initialize(this); } public function initialize(own: Sprite=null):void { removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage); context = new PlayerContext(own); // 此处使用robotlegs框架 } } }
Flash Builder 4.5安装后
- 安装Flash Builder 4.5后,需要修改系统中的hosts文件,Windows是“C:\Windows\System32\drivers\etc\hosts”,Mac是“/etc/hosts”。
# 127.0.0.1 localhost # ::1 localhost 127.0.0.1 activate.adobe.com 127.0.0.1 practivate.adobe.com 127.0.0.1 ereg.adobe.com 127.0.0.1 activate.wip3.adobe.com 127.0.0.1 wip3.adobe.com 127.0.0.1 3dns-3.adobe.com 127.0.0.1 3dns-2.adobe.com 127.0.0.1 adobe-dns.adobe.com 127.0.0.1 adobe-dns-2.adobe.com 127.0.0.1 adobe-dns-3.adobe.com 127.0.0.1 ereg.wip3.adobe.com 127.0.0.1 activate-sea.adobe.com 127.0.0.1 wwis-dubc1-vip60.adobe.com 127.0.0.1 activate-sjc0.adobe.com
- 修改完后,打开Flash Builder,输入序列号:1424-4009-1836-4008-6385-6886
Robotlegs是什么?
上个月在M童的提议下,终于开始使用一个框架了,开始了解一下Robotlegs是什么?
Robotlegs 是一个用来开发Flash,Flex 和 AIR 应用的纯 AS3 微框架。它的核心是一组模块化的工具集以及界面集,用来信息沟通任务,减少重复的代码编写,以及管理应用程序中的依赖注入。除了这些核心工具集以外,Robotlegs还提供了一个比较规范的MVC+S(Model模型,View视图,Controller控件和Service服务)实现,来帮助开展工作。
一个典型的Robotlegs MVC+S应用程序包含以下几个部分:
- Context,实际上是一套自展机制,用来初始化Robotlegs所使用的依赖注入以及各种核心工具,一个应用程序是可以有多个 context 的,这对想要加载外部模块的应用程序很有用,因为在一个 context 里的 actor 只能在他们的 context 定义的范围之内相互通讯,所以在一个模块化的应用程序里,不同context 之间的通讯是完全可能的。
- Controller & Commands,Controller 层由 Command 类体现。Command 是用来执行应用程序单一单位工作的,无状态的,短生命周期的对象。Command 用于应用程序各层之间相互通讯, 也可能用来发送系统事件. 这些系统事件既可能发动其它的 Command, 也可能被一个 Mediator 接收,然后对一个 View Component 进行对应这个事件的工作。Command 是封装应用程序业务逻辑的绝佳场所。Command 应该只在处理框架事件时被执行, 而不应该被任何其他框架 actor 实例化或执行。
- View & Mediators,View 由 Mediator 类体现。继承 Mediator 的类管理应用程序中的 View Component 与应用程序中的其它对象之间的信息交流。一个Mediator 将会监听框架事件和 View Component 事件, 并在处理所负责的 View Component 发出的事件时发送框架事件。这样开发者可以将应用程序特有的逻辑放到 Mediator, 而避免把 View Component 耦合到特定的应用程序。
- Model ,用来在 model 层对数据进行封装并为其提供 API。Model 会在对数据模型进行某些工作之后发出事件通知。Model 通常具有极高的便携性。
- Service,一个 service 层的 Service 用来和“外面的世界”进行通讯。 Web service、文件存取或者其它任何应用程序范围之外的行为对 service 类都很适合。Service 类在处理外部事件时会广播系统事件。一个 service 应该封装和外部服务的交互且具有非常高的便携性。
Robotlegs 使用Flash的原生事件用于框架 actor 之间的通讯。 自定义事件类通常用于此用途,虽然使用现有的 Flash 事件同样可行。Robotlegs 不支持事件冒泡。使用自定义类允许开发者通过给事件添加属性来为框架 actor 之间通讯所用的系统事件提供强类型的负载。
所有的框架 actor 都可以发送事件:Mediator、Service、Model 和 Command。Mediator 是唯一接收框架事件的actor,Command 是在对框架事件的处理中被触发,一个事件既可以被一个 Mediator 接收, 也可以触发一个 command。model 和 service 不应该监听和处理事件,这样做会把它们紧耦合到应用程序特有逻辑而降低潜在的便携性和复用性。
ActionScript Project引用mx.effects
在Flash builder 4.1中,建立了一个SlideSample的ActionScript Project,想import mx.effects.Effect,但是当前工程中,SDK并没有加载framework.swc,手动在Library path中Add SWC,俺机器的路径为“D:\Program Files\Adobe\Adobe Flash Builder 4\sdks\4.1.0.16076\frameworks\libs\framework.swc”,如此这般,可以很成功的引入mx.effects中的效果。
应用编译后,发现报错:Resource Path Location Type Unable to resolve resource bundle “core” for locale “en_US”.等一堆的Error。
接着手动在这个工程的Library path中Add SWC,“D:\Program Files\Adobe\Adobe Flash Builder 4\sdks\4.1.0.16076\frameworks\locale\en_US\framework_rb.swc”。
嗯,到此,终于成功的使用了Flex中的效果。
TextFlow Error #1502
从昨天到今天,一直被困于Flex应用中报出的Error #1502的Bug,搞不明白简单的赋值,SDK报出这么个错误来,而且并不是每一个字符串进行此种赋值都会报错。
报错的语句是: textArea.textFlow = TextConverter.importToFlow(value, TextConverter.TEXT_LAYOUT_FORMAT);
暂时认为是因为导入的文本过长,超过TextArea对象的高,采用这种方法赋值,会引发生成滚动条,带出相关的Error吧。
改写为: // 先定义一个TextFlow变量,方便赋值时候传入 var importTextFlow: TextFlow = null; importTextFlow = TextConverter.importToFlow(value, TextConverter.TEXT_LAYOUT_FORMAT); // 将TextFlow变量的值,进行两次转变,先转为html格式的String类型,再转回为TextFlow类型后,赋值给textArea.textFlow textArea.textFlow = TextConverter.importToFlow(TextConverter.export(importTextFlow, TextConverter.TEXT_FIELD_HTML_FORMAT, ConversionType.STRING_TYPE), TextConverter.TEXT_FIELD_HTML_FORMAT);
采用如上写法后,奇怪般的好用了,呵呵,有时灵光一闪,还是有些作用的。
rawChildren
rawChildren用于mx中hao系列容器组件中,如Canvas。
在flash Builder 4中,出现了spark系列组件,如Group。
问题,如何在Group中加入Shape组件呢?下面代码显示出如何在两组不同组件中加入Shape:
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" width="600" height="340"> <fx:Script> <![CDATA[ import mx.core.UIComponent; protected function button1_clickHandler(event:MouseEvent):void { var shape: Shape = new Shape(); shape.graphics.beginFill(0xFFCC00); shape.graphics.drawRect(0,0,mxCanvas.width,mxCanvas.height); mxCanvas.rawChildren.addChildAt(shape, 0); } protected function button2_clickHandler(event:MouseEvent):void { var shape: Shape = new Shape(); shape.graphics.beginFill(0xFF0000); shape.graphics.drawRect(0,0,sGroup.width,sGroup.height); var uicomponent: UIComponent = new UIComponent(); uicomponent.addChild(shape); sGroup.addElementAt(uicomponent, 0); } ]]> </fx:Script> <fx:Declarations> <!-- Place non-visual elements (e.g., services, value objects) here --> </fx:Declarations> <mx:Canvas id="mxCanvas" width="227" height="172" x="38" y="80"> <mx:Label text="Canvas.." id="label1"/> <s:Button x="86" y="42" label="Add Shape" click="button1_clickHandler(event)"/> <s:CheckBox x="86" y="81" label="CheckBox"/> </mx:Canvas> <s:Group id="sGroup" x="314" y="80" width="250" height="172"> <s:Label text="Group..." id="label2"/> <s:Button x="86" y="42" label="Add Shape" click="button2_clickHandler(event)"/> <s:CheckBox x="86" y="81" label="CheckBox"/> </s:Group> </s:Application>
UIComponent是由DisplayObject扩展而来,所有UIComponent都是DisplayObject,也就是说UIComponent都是children。UIComponent同时也实现了IVisualElement接口,因而所有的UIComponent也可以被作为elements看待。
public function get rawChildren():IChildList
容器中通常包含子组件,可以使用 Container.getChildAt() 方法和 Container.numChildren 属性枚举这些子组件。此外,容器可以包含样式元素和外观,如边框和背景。Flash Player 和 AIR 创建的子组件和外观之间没有任何差异。二者均可以使用播放器的 getChildAt() 方法和 numChildren 属性进行访问。但是,Container 类通过覆盖 getChildAt() 方法和 numChildren 属性(以及其他多个方法)可造成容器的子项是唯一的子组件的错觉。
如果您需要访问容器的所有子项(内容子项和外观),则需使用 rawChildren 属性上的方法和属性,而不是常规 Container 方法。例如,可使用 Container.rawChildren.getChildAt()) 方法。但是,如果容器为其子项创建了 ContentPane Sprite 对象,则 rawChildren 属性值将只计算 ContentPane,而不计算容器的子项。并非总能够确定容器何时包含 ContentPane。
注意:如果您调用 rawChildren 对象的 addChild 或 addChildAt 方法,则需在添加的组件上设置 tabFocusEnabled = false。这可以防止用户跳位到所添加的仅可视组件。
PageFlip.as
这个as的文件与我一起有三年了,却对它,总是远远的躲着,因为没有搞明白过。它是一个翻书的效果,被好些程序使用中,完美的很,Foxy写于2007-01-18,版本保持着1.0。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 | package com.foxaweb.pageflip { import flash.geom.Point; import flash.display.BitmapData; import flash.geom.Matrix; import flash.display.Shape; /** * Computes, generates, and draws a pageflip. * * @notice PageFlip drawer * @author Foxy * @version 1.0 * @date 2007-01-18 * * Original author : * ----------------- * Didier Brun aka Foxy * webmaster@foxaweb.com * http://www.foxaweb.com * * AUTHOR * ***************************************************************************** * * authorName : Didier Brun - www.foxaweb.com * contribution : the original class * date : 2007-01-18 * * VISIT www.byteArray.org * * * LICENSE ****************************************************************************** * * This class is under RECIPROCAL PUBLIC LICENSE. * http://www.opensource.org/licenses/rpl.php * * Please, keep this header and the list of all authors * * * * Nomenclature * ------------ * * PT(0,0) PT(1,0) * --------------------------------------------------- * | <-------------------PW----------------------> | * | ^ Offset(0,0) x--> | * | | | * | | y | * | | | | * | | | | * | | V | * | | pPoints[] | * | | | * | | | * | | | * | | (T3) | * | PH ---| * | | --- / * | | --- / * | | --- / * | | --- / * | | --- / * | | --- / * | | PTD --- cPoints[] / * | | \ / * | | \ / * | | \ / * | | \ / * | | \ / * | V \ / * |-------------------------------- \/ * PT(0,1) PT(1,1) */ public class PageFlip { // ------------------------------------------------ // // ---o public static methods // // ------------------------------------------------ /** * Compute and generate a new flip. * * @param ptd Point indicating the position of the PTD point (the drag one) relative to the upper-left corner. * @param pt Point indicating the original position of the dragged point. The two possible values for its x and y properties are 0 or 1. pt(0,0) is the upper-left corner, for example, pt (1,1) is the bottom-right one. * @param pw int indicating the sheet width in pixels. * @param ph int indicating the sheet height in pixels. * @param ish If true, horizontal mode is provided, if false, vertical. * @param sens Number indicating the constraints sensibility. This parametter is a multiplicator for the constraints values. It's intended to prevent some awefull flickering effects. Its possible value is ranged between 0.9 and 1. 0.9 -> when ptd move is free (drag'n'drop), 1 -> when ptd move is progresive (tween when release). At best, you should never swap it from .9 to 1. A progressive incrementation is better. If flickering effects don't disturb you or if your ptd moves is coded, keep this parametter to 1. * * @return Object containing:<br /> * cPoints:Array - Array of points which describes the flipped part of the sheet. Note that in case of the ptd point is aligned with its original position or if the height of the shape is very small (<1) this array is set to null.<br /> * pPoints:Array - Array of points wich describes the fixed part of the sheet.<br /> * matrix:Matrix - Transformation matrix for the flipped part of the sheet.<br /> * width:Number - Sheet width.<br /> * height:Number - Sheet height. * */ public static function computeFlip(ptd:Point,pt:Point,pw:int,ph:int,ish:Boolean,sens:int):Object{ // useful vars var dfx:Number=ptd.x-pw*pt.x; var dfy:Number=ptd.y-ph*pt.y; var spt:Point=pt.clone(); var opw:int=pw; var oph:int=ph; // offset corections var temp:Number; // transform matrix var mat:Matrix=new Matrix(); if (!ish){ // size temp=pw; pw=ph; ph=temp; // ptd temp=ptd.x; ptd.x=ptd.y; ptd.y=temp; // pt temp=pt.x; spt.x=pt.y; spt.y=temp; } // pt1 & pt2 are the two fixed points of the sheet. opposed to ptd drag one. var pt1:Point=new Point(0,0); var pt2:Point=new Point(0,ph); // default points array // cPoints -> the fliped part var cPoints:Array=[null,null,null,null]; // pPoints -> the fixed part var pPoints:Array=[new Point(0,0),new Point(pw,0),null,null,new Point(0,ph)]; // compute some flip flipDrag(ptd,spt,pw,ph); // ditstance // it allows you to have a valid position for ptd. // the limit is the diagonal of the sheet here limitPoint(ptd,pt1,(pw*pw+ph*ph)*sens); // the limit is about the opposite fixed point limitPoint(ptd,pt2,(pw*pw)*sens); // first fliped point cPoints[0]=new Point(ptd.x,ptd.y); var dy:Number=pt2.y-ptd.y; var tot:Number=pw-ptd.x-pt1.x; var drx:Number=getDx(dy,tot); // fliped angle var theta:Number=Math.atan2(dy,drx); if (dy==0)theta=0; // another fliped angle var beta:Number=Math.PI/2-theta; var hyp:Number=(pw-cPoints[0].x)/Math.cos(beta); // vhyp is the hypotenuse of the fliped part var vhyp:Number=hyp; // if hyp is greater than the height of the sheet or hyp is // negative, the fliped part has 4 points // else, it's just a 3 points part (simple corner). if (hyp>ph || hyp<0)vhyp=ph; // second fliped point cPoints[1]=new Point( cPoints[0].x+Math.cos(-beta)*vhyp, cPoints[0].y+Math.sin(-beta)*vhyp); // last fliped point cPoints[3]=new Point(cPoints[0].x+drx,pt2.y); // if we have a 4 points shape if (hyp!=vhyp){ dy=pt1.y-cPoints[1].y; tot=pw-cPoints[1].x; drx=getDx(dy,tot); // push the before the last point cPoints[2]=new Point(cPoints[1].x+drx,pt1.y); // we can now find the fixed points of the sheet pPoints[1]=cPoints[2].clone(); pPoints[2]=cPoints[3].clone(); pPoints.splice(3,1); }else{ // else we delete the point cPoints.splice(2,1); // we can now find the fixed points of the sheet pPoints[2]=cPoints[1].clone(); pPoints[3]=cPoints[2].clone(); } // these two polygons are always convex ! // now we can flip the two arrays flipPoints(cPoints,spt,pw,ph); flipPoints(pPoints,spt,pw,ph); // if !ish (vertical mode) // we have to change the points orientation if (!ish){ oriPoints(cPoints,spt,pw,ph); oriPoints(pPoints,spt,pw,ph); } // flipped part transfrom matrix var gama:Number=theta; if (pt.y==0)gama=-gama; if (pt.x==0)gama=Math.PI+Math.PI-gama; if (!ish)gama=Math.PI-gama; mat.a=Math.cos(gama); mat.b=Math.sin(gama); mat.c=-Math.sin(gama); mat.d=Math.cos(gama); ordMatrix(mat,spt,opw,oph,ish,cPoints,pPoints,gama,beta); // here we fix some mathematical bugs or instabilities if (vhyp==0)cPoints=null; if (Math.abs(dfx)<1 && Math.abs(dfy)<1)cPoints=null; // now we just have to return all the stuff return {cPoints:cPoints,pPoints:pPoints,matrix:mat,width:opw,height:oph}; } /** * Draw a sheet using two Bitmap objects. * * @param ocf computeFlip() returned object * @param mc Target * @param bmp0 First page bitmap (left-top aligned) * @param bmp1 Second page bitmap (left-top aligned) * */ public static function drawBitmapSheet(ocf:Object,mc:Shape,bmp0:BitmapData,bmp1:BitmapData):void{ // affectations var wid:Number=ocf.width; var hei:Number=ocf.height; var nb:Number; var ppts:Array=ocf.pPoints; var cpts:Array=ocf.cPoints; // draw the fixed part mc.graphics.beginBitmapFill(bmp0,new Matrix(),false,true); nb=ppts.length; mc.graphics.moveTo(ppts[nb-1].x,ppts[nb-1].y); while (--nb>=0)mc.graphics.lineTo(ppts[nb].x,ppts[nb].y); mc.graphics.endFill(); // draw the flipped part if (cpts==null)return; mc.graphics.beginBitmapFill(bmp1,ocf.matrix,false,true); nb=cpts.length; mc.graphics.moveTo(cpts[nb-1].x,cpts[nb-1].y); while (--nb>=0)mc.graphics.lineTo(cpts[nb].x,cpts[nb].y); mc.graphics.endFill(); } // ------------------------------------------------ // // ---o private static methods // // ------------------------------------------------ /** * orientation correction * @private */ private static function oriPoints(pts:Array,po:Point,pw:Number,ph:Number):void{ var nb:Number=pts.length; var temp:Number; while (--nb>=0){ temp=pts[nb].x; pts[nb].x=pts[nb].y; pts[nb].y=temp; } } /** * ptdarg correction * @private */ private static function flipDrag(ptd:Point,po:Point,pw:Number,ph:Number):void{ // flip y if (po.y==0)ptd.y=ph-ptd.y; // flip x if (po.x==0)ptd.x=pw-ptd.x; } /** * flip correction * @private */ private static function flipPoints(pts:Array,po:Point,pw:Number,ph:Number):void{ var nb:Number=pts.length; // flip if (po.y==0 || po.x==0){ while (--nb>=0){ if (po.y==0)pts[nb].y=ph-pts[nb].y; if (po.x==0)pts[nb].x=pw-pts[nb].x; } } } /** * compute some trigonometry equation * * this one is more stable than Math.atan2 for our case * * @private */ private static function getDx(dy:Number,tot:Number):Number{ return (tot*tot-dy*dy)/(tot*2); } /** * limit the ptdrag position * @private */ private static function limitPoint(ptd:Point,pt:Point,dsquare:Number):void{ var theta:Number; var lim:Number; var dy:Number=ptd.y-pt.y; var dx:Number=ptd.x-pt.x; var dis:Number=dx*dx+dy*dy; // we save some times using square if (dis>dsquare){ theta=Math.atan2(dy,dx); lim=Math.sqrt(dsquare); ptd.x=pt.x+Math.cos(theta)*lim; ptd.y=pt.y+Math.sin(theta)*lim; } } /** * matric correction * @private */ private static function ordMatrix(mat:Matrix,spt:Point,opw:Number,oph:Number,ish:Boolean,cPoints:Array,pPoint:Array,gama:Number,beta:Number):void{ if (spt.x==1 && spt.y==0){ mat.tx=cPoints[0].x; mat.ty=cPoints[0].y; if (!ish){ mat.tx=cPoints[0].x-Math.cos(gama)*opw-Math.cos(-beta)*oph; mat.ty=cPoints[0].y-Math.sin(gama)*opw-Math.sin(-beta)*oph; } } if (spt.x==1 && spt.y==1){ mat.tx=cPoints[0].x+Math.cos(-beta)*oph; mat.ty=cPoints[0].y+Math.sin(-beta)*oph; if (!ish){ mat.tx=cPoints[0].x+Math.cos(-beta)*oph; mat.ty=cPoints[0].y-Math.sin(-beta)*oph; } } if (spt.x==0 && spt.y==0){ mat.tx=cPoints[0].x-Math.cos(gama)*opw; mat.ty=cPoints[0].y-Math.sin(gama)*opw; } if (spt.x==0 && spt.y==1){ mat.tx=cPoints[0].x-Math.cos(gama)*opw-Math.cos(-beta)*oph; mat.ty=cPoints[0].y-Math.sin(gama)*opw+Math.sin(-beta)*oph; if (!ish){ mat.tx=cPoints[0].x; mat.ty=cPoints[0].y; } } } } } |
加上备注,总共不过402行代码,准备研究。
describeType
public function describeType(value:*):XML
语言版本: ActionScript 3.0 生成描述 ActionScript 对象(命名为方法的参数)的 XML 对象。
如果 value 参数是类型的实例,则返回的 XML 对象包括该类型的所有实例属性,但不包括任何静态属性。可以在解析 XML 对象时检查此条件,方法是检查
要获取某个类型的静态属性,请为 value 参数传递该类型本身。返回的 XML 对象不仅仅包括类型的静态属性,而且还包括它的所有实例属性。实例属性嵌套在名为
详情请参见http://help.adobe.com/zh_CN/AS3LCR/Flex_4.0/flash/utils/package.html#describeType%28%29
初始 OSMF 中几个简单对象
嗯,写这个只为了加深下,自己的印象,方便提醒自己。
这是个简单的播放,无任何的控制,首先了解几个常见的元素:
* MediaElement:一个声音、一张图片,一个视频,或者其他媒体资源。
* MediaPlayer:对所有媒体类型提供必要的互动支持。
* MediaContainer:基于Sprite类的容器,用以承装媒体对象。
* MediaFactory:判断要播放的类型,来创建不同的MediaElement 。