actionscript-3

AS3, loading in a SWF as a custom type

假如想象 提交于 2019-12-23 12:57:25
问题 Fundamental question here. Typically in AS3 you load in a SWF via the Loader, and what you get is some sort of pseudo MovieClip that is of type "Loader". Is there any holy way under the sun to cast this loaded SWF to a custom type that extends MovieClip and not Loader, assuming the SWF was published with a base class of the custom type? Without data loss? Alternatively, let's say you can't, can you even cast it from a custom type that extends Loader itself? 回答1: You can do something like this

How can I detect StaticText in AS3?

守給你的承諾、 提交于 2019-12-23 12:28:02
问题 I have StaticText fields in my flash project and I need to run some code when the mouse is hovering over them. So I tried this code stage.addEventListener(MouseEvent.MOUSE_OVER, mouseRollOver); function mouseRollOver(event:MouseEvent):void { var tf:StaticText = event.target as StaticText; if (tf){ //my code } } but it doesn't work. When I use dynamic text fields and replace StaticText with TextField in the var tf, it works fine. I also thought that I could get this thing working with static

AAC/MP4 not working in ActionScript 3's NetStream

拥有回忆 提交于 2019-12-23 12:09:48
问题 I'm trying to play a remote AAC file in ActionScript 3 in Flash CS3 and am currently using this code: var url:String = " http://a1.phobos.apple.com/us/r1000/020/Music/d4/50/94/mzm.kjjofihr.aac.p.m4a "; var connect_nc:NetConnection = new NetConnection(); connect_nc.connect(null); var stream_ns:NetStream = new NetStream(connect_nc); stream_ns.play(url); (This is based on: http://www.adobe.com/devnet/flashplayer/articles/hd_video_flash_player_03.html) No errors are thrown, but no sound is played

Flex 4 spark Panel has an ugly gray top part

[亡魂溺海] 提交于 2019-12-23 12:08:08
问题 I have a Flex 4 spark Panel I'm popping up through the PopUpManager, but it has a gray portion at the top I can't get rid of. What is that and how can I remove it? UPDATE : An example Panel is below. I simply call PopUpManager.addPopUp(new TestPanel(), background, true); on it and receive that solid gray bar above the button. <s:Panel xmlns:s="library://ns.adobe.com/flex/spark" xmlns:fx="http://ns.adobe.com/mxml/2009" dropShadowVisible="false" backgroundAlpha="0" controlBarVisible="false"

Check if users flash player has audio capabilities. (Capabilities.hasAudio)

一曲冷凌霜 提交于 2019-12-23 10:55:11
问题 Is it possible to check if the user has a sound card? I found Capabilities.hasAudio but dont know if that is the value I should look at. trace(Capabilities.hasAudio) "Specifies whether the system has audio capabilities. This property is always true . 回答1: The docs are unclear on this, but I think that the properties in the Capabilities class tells you what the capabilities of the player is, not necessarily the system. For instance, the desktop players will always return true for hasAudio,

Why doesn't removing event listeners work?

巧了我就是萌 提交于 2019-12-23 09:57:58
问题 I have this in my constructor: addEventListener(Event.REMOVED_FROM_STAGE, actualDestroy); And this in actualDestroy: public function actualDestroy(e:* = null){ removeEventListener(Event.REMOVED_FROM_STAGE,actualDestroy); if(this.parent){ this.parent.removeChild(this); } } The problem is I get Error: Error #2094: Event dispatch recursion overflow. Why does removechild keep getting called if this.parent does not exist? Why doesn't removing event listeners work? 回答1: The name of the event is

AS3 - Scale BitmapData

半城伤御伤魂 提交于 2019-12-23 09:49:47
问题 I'd like to scale a BitmapData to different sizes such as 200, 400, 600 and 800. What is a good way to do that? 回答1: You can't directly scale a BitmapData but you can make a scaled clone of it. Here is a quick example for scaling a BitmapData : package { import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.Sprite; import flash.geom.Matrix; import mx.core.BitmapAsset; public class Test extends Sprite { [Embed(source="test.jpg")] private var Image:Class; public

Why can't typed optional arguments have a default of Null?

吃可爱长大的小学妹 提交于 2019-12-23 09:39:46
问题 In ActionScript 3, when you declare an optional argument by giving it a default value, the value null cannot be used on typed arguments. function Action(Param:int=null){ // 1184: Incompatible default value of type Null where int is expected. } function Action(Param:int=0){ // No compiler errors } Any workarounds for this, or general purpose values that can apply to all data types? 回答1: You can change your int to Number and then can set it to NaN which is a special number that means 'not a

Chrome Notification/Permission Bar - Detect if visible

心不动则不痛 提交于 2019-12-23 09:34:39
问题 Chrome displays the following notification bar when flash requests access to the camera or microphone... Is there any JavaScript or AS3 way to be detect if this is/isn't visible? 回答1: I know it's been a long time since you asked, but we finally found a workaround that I would like to share, the ActionScript Camera has a public property called currentFPS which while the permission is pending will be constant and set to 0 (zero). We use that property to decide either or not we should display a

URL encode variable in AS3?

落爺英雄遲暮 提交于 2019-12-23 09:07:06
问题 I get the following error when trying to pass variables via URLRequestMethod.POST; Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs. Is there a method for string URL Encoding? 回答1: Solution to this problem is: You have to set URLLoaderDataFormat to URLLoaderDataFormat.TEXT not URLLoaderDataFormat.VARIABLES. Because VARIABLES means different types of data, not multiple items in URLVariables . 回答2: There are escape()