actionscript

AS3 Timers vs. ENTER_FRAME performance

主宰稳场 提交于 2019-12-03 05:13:55
问题 I'm building a game that got some moving things all the time, so I'm using a lot of Timer instances to control repetition and trigger motion. Now the thing is that I started to notice some performance "lags". Is this due to the timers? and do you suggest using ENTER_FRAME event instead? Related: Do you suggest any other library/method for such games that could enhance performance? Simple Tween libraries are not enough per se. 回答1: maybe it would make more sense, to have only one timer running

How can I modify my code to line through the bezier control points?

风格不统一 提交于 2019-12-03 05:12:00
HI all - I am using anchor points and control points to create a shape using curveTo. It's all working fine, but I cannot figure out how to get my lines to go through the center of the control points (blue dots) when the line is not straight. Here is my code for drawing the shape: // clear old line and draw new / begin fill var g:Graphics = graphics; g.clear(); g.lineStyle(2, 0, 1); g.beginFill(0x0099FF,.1); //move to starting anchor point var startX:Number = anchorPoints[0].x; var startY:Number = anchorPoints[0].y; g.moveTo(startX, startY); // Connect the dots var numAnchors:Number =

Test if an object is defined in ActionScript

旧时模样 提交于 2019-12-03 04:24:29
In ActionScript, how can you test if an object is defined, that is, not null? Matthew Crumley test if an object is defined This works in AS2 and AS3, and is the most reliable way to test if an object has a value. if (obj != null) { doSomethingWith(obj); } Its also the most reliable way to test an object's property and read it in the same expression: if (arr[0] != null && arr[0]>5) { doSomethingWith(arr[0]); } test if an object is null There's a difference between null and undefined, but if you don't care you can just do a normal comparison between either one because they compare equal: if (obj

Javascript to flash communication

若如初见. 提交于 2019-12-03 03:58:22
I am trying to call a Actionscript function from javascript but I am having problems in Internet Explorer. I am using Swiff.remote in mootools 1.2.1 to call the actionscript function ie: Swiff.remote(playSwf.toElement(), 'sendResult', result, plays, name); This all works fine in FireFox, Safari and Opera but I'm getting an "unspecified" error in Internet Explorer 6 and 7. I have tried using the bog standard: window['flash'].sendResult(result, plays, name); To no avail. Thanks for any help. Mark I'm not familiar with the Swiff plugin, but you don't need a plugin to call flash functions from

How do I learn Flash Game Development?

假装没事ソ 提交于 2019-12-03 02:06:47
问题 I'm currently a PHP programmer and one of my childhood dreams is to create a game. The problem is I don't know Flash. I'm not great at drawing stuff or even artistic. I could program a little with JavaScript and I could consider myself intermediate with JQuery. Question How do I get started with Flash Game development? What books do I read first? The type of game is a side scroller about an Indiana Jones type of character and the setting is on the jungle with trees and snakes and a lot of

How do I get from an instance of a class to a Class object in ActionScript 3?

好久不见. 提交于 2019-12-03 01:28:47
问题 How do you get an instance of the actionscript class Class from an instance of that class? In Python, this would be x.__class__ ; in Java, x.getClass(); . I'm aware that certain terrible hacks exist to do this, but I'm looking for a built-in language facility, or at least a library routine built on something reliable. 回答1: You can get it through the 'constructor' property of the base Object class. i.e.: var myClass:Class = Object(myObj).constructor; 回答2: Any reason you couldn't do this? var s

Best Practices for Internationalizing a Flex Application?

时间秒杀一切 提交于 2019-12-03 00:41:46
I am looking into internationalizing a Flex application I am working on and I am curious if there are any best practices or recommendations for doing so. Googling for such information results in a handful of small articles and blog posts, each about doing it differently, and the advantages and disadvantages are not exactly clear. Edited to narrow scope: Need to support only two languages (en_CA and fr_CA) Need to be able to switch at runtime Of course, after googling a bit more I come across an article on runtime localization . And followed these steps: Add the following to the compiler

Asynchronous function call in Flex

99封情书 提交于 2019-12-02 23:05:14
Is it possible to call a function asynchronously in Flex? I want to parse a file at regular intervals without blocking the rest of the application, what is the recommended approach for this? Actionscript doesn't support multithreading, which I think is what you are really asking about here. While the functionality isn't inherent in actionscript (or Flex) you could set up a mock system using events and timers. I'm a little unclear on your exact question, so I'll give two answers: 1) You want to process a file every few seconds to act on any changes. In this case all you need to do is set up a

UDP real-time games in Flash/Flex available Open source RTMFP implementation

一曲冷凌霜 提交于 2019-12-02 23:02:14
Are there any examples of using the Flash 10 beta RTMFP UDP based protocol to build real-time Flash games. The RTMFP examples so far seem to focus on P2P networking between flash clients does anyone know of any examples of traditional client/server UDP based communication over RTMFP. Does anyone know the ability of RTMFP to do NAT firewall punch-through to allow clients to "host" real-time games. Imagine being able to over the web through flash client perform XBox live-like matchmaking and allow a client to host a Flash based realtime "Call of duty"-like game server through a web browser. It

Is it possible to do a traceroute in the browser?

独自空忆成欢 提交于 2019-12-02 21:42:57
I'm looking for a way to do a traceroute client-side, i.e. in a browser. As far as I know, it's not possible to send ICMP, UDP or TCP packets with arbitrary TTL values via Javascript or Flash. I know Flash allows TCP connections via the Socket class in Actionscript but it doesn't seem useful for a traceroute implementation. Is the only solution to develop a browser plug-in ? EDIT : I just found out that it has been done with a Java applet: http://www.codefromthe70s.org/traceroute.aspx The bad news is that this applet requires to be signed code because it actually parses the output from the