actionscript-3

Flex graphic assets: SWF or SWC?

橙三吉。 提交于 2019-12-29 23:27:50
问题 Which is a better format to store graphic assets for a Flex application, SWF or SWC? Are there any real differences, and if so what are they? 回答1: Assets in a seperate SWF are loaded and included at runtime. Assets in a SWC are loaded and included / compiled at compile time. You can also directly embed assets within the main app SWF at compile time (check out the Embed meta data). Of course, you can also load individual assets (such as a PNG) directly at runtime. As far as which is better, it

How can I send value to Actionscript using Javascript

只谈情不闲聊 提交于 2019-12-29 09:37:07
问题 I want to send a float variable to Actionscript. I use window.document.setVariable() , but it only supports type String , and ignores 0 and point ( . ) I try to use parseFloat() and value * 1 in javascript,but it doesn't work. 回答1: Your question is pretty vague. Still, here goes: There are 2 (edited to 3 ) methods to get a variable into Flash from the html. Both use the ExternalInterface class (1): Pull the variable into ActionScript //JavaScript: var myVariable=3.14159; //or whatever you

AS3 - hitTestObject Collision Not Registering Correctly

北战南征 提交于 2019-12-29 09:22:24
问题 I had a problem with my hitTestObject collision detection a couple of days ago which has since been fixed (How can I solve my hitTestObject Collision Null Object Ref Error) with the help of you folks (thanks). My problem now is as such: When my "enemy.hit" comes into contact with "player.hit" it registers as a hit - this is good. When my "building.collide" comes into contact with "player.hit" it registers as a hit - this is good. However, when my "building.collide" comes into contact with my

AS3 - How to do a synchronous load of an asynchronous call?

社会主义新天地 提交于 2019-12-29 09:21:46
问题 I have a function that loads a user object from a web service asynchronously. I wrap this function call in another function and make it synchronous. For example: private function getUser():User{ var newUser:User; var f:UserFactory = new UserFactory(); f.GetCurrent(function(u:User):void{ newUser = u; }); return newUser; } UserFactory.GetCurrent looks like this: public function GetCurrent(callback:Function):void{ } But my understanding is there is no guarantee that when this function gets

AS3: get browser window size?

倖福魔咒の 提交于 2019-12-29 09:12:32
问题 Can I get the obtain the size of the browser window in AS3? The best method I've found is to get the size with Javascript and send it to Flash as a FlashVar. One limitation of this method is that it doesn't give the current size if the window is resized. Is there a pure Flash way to do this? 回答1: It depends if you are trying to set your swf to fullscreen, or simply obtain window dimensions for some other purpose. If you are doing fullscreen, you need to set your stageScaleMode to NO_SCALE,

AS3: How accurate are the getTimer() method and the Timer class?

风格不统一 提交于 2019-12-29 08:58:44
问题 I'm in the process of making a game (a shmup) and I've started to question the accuracy of the timers in ActionScript. Sure, they're accurate enough when you want to time things on the order of a few seconds or deciseconds, but it seems to perform pretty poorly when you get to finer ranges. This makes it pretty tough to do things like have a spaceship firing a hundred lasers per second. In the following sample, I tested how long (on average) the intervals were between 1000 timer ticks

AS3 singleton implementations

ぐ巨炮叔叔 提交于 2019-12-29 07:54:12
问题 I have seen so many implementations of singletons around, and i just want a singleton that 1.- instances on the first call 2.- instances only once (duh) So in performance and lowest memory consumtion, whats the best implementation for this? Example 1 package Singletons { public class someClass { private static var _instance:someClass; public function AlertIcons(e:Blocker):void{} public static function get instance():someClass{ test!=null || (test=new someClass(new Blocker())); return

AS3 Instantiate Class From External SWF

故事扮演 提交于 2019-12-29 07:52:20
问题 I was chatting with my buddy about this, he is convinced you can do this and says he has done it, but I cannot get this to work. I am wondering if it is even possible at all. I tried typing a var as a Class that is within the externally downloaded SWF and then making an instance but no can do. some code private static function onCompleteHandler(e:Event) { dashboardObject = e.target.content; // registerClassAlias("Dashboard", ); doesnt work var dash:Class = getDefinitionByName("Dashboard") as

AS3 How to startdrag only on x-axis?

本秂侑毒 提交于 2019-12-29 07:43:11
问题 I have a red square that I want to drag only on the x-axis. I've worked out a simple script, which theoretically should work, but it's not behaving properly. It's a bit hard to explain..the square keeps starting at the wrong position and the stage position seems to be changing so sometimes you can't drag the square all the way to the right... red.buttonMode = true; red.addEventListener(MouseEvent.MOUSE_DOWN, dragHandler); function dragHandler(e:MouseEvent):void { var ypos:Number = e

Unexpected Flash Security Exception When Using URLLoader

本小妞迷上赌 提交于 2019-12-29 07:43:11
问题 What I am trying to accomplish is to upload some binary data, specifically a ByteArray representing a PNG image, to a server using the URLLoader class in conjunction with URLRequest. When I set the contentType property of the URLRequest to 'multipart/form-data' instead of the default, the call to urlLoader.load() results in a security exception. When I leave the contentType property as the default, it works fine, but takes a long time (proportional to the length of the PNG file) to upload the