actionscript-3

Multi-pages Flash application

走远了吗. 提交于 2019-12-24 07:37:32
问题 I am very new to Flash and I need help to get started with building multi-pages Flash application. I managed to open another swf file (called Page1) from within the main swf by calling this function private function LoadExternalSwf(): void { var loader:Loader = new Loader(); var urlReq:URLRequest = new URLRequest("page1.swf"); loader.load(urlReq); addChild(loader); } How do you add a sort of "Back" button to Page1 so that it will close itself (so that we are back to the main screen)? If Page1

Is there a fixed-point library for actionscript 3?

℡╲_俬逩灬. 提交于 2019-12-24 07:35:34
问题 I would like to code a calculator in Flex but can't find any fixed-point libraries on the web. For the calculator, I need more precision then IEEE 754 can guarantee. For example: trace(1.4 - .4); //should be 1 but it is 0.9999999999999999 Can someone suggest a good fixed-point library please ? Thank you in advance 回答1: It works but it is not perfect, all credits go to Josh from http://joshblog.net/2007/01/30/flash-floating-point-number-errors/ /** * Corrects errors caused by floating point

how to let textfield's width auto fit the text?

放肆的年华 提交于 2019-12-24 07:35:16
问题 recently i was thinking making a component which like html's table tag. html table can auto fit the cell's width with the text or content in it.and the certain column's width is decided by the widest cell on that column. <table> <tr> <td>this could be very long.</td> </tr> <tr> <td>short</td> </tr> </table> but in as3 this is a problem,i don't know the string's actual size unless i set it to a textfield. i don't think it would be a good strategy to use the actual textfield instance try and

flex mobile : textInput does not clear prompt on focus

浪尽此生 提交于 2019-12-24 07:35:12
问题 a simple <s:TextInput x="163" y="117" prompt="hello"/> Does not clear the prompt on focus, but clears the prompt when user first type in a letter. This is the behaviour on flex mobile (behaviour is OK on swf ) Is that a bug and how to correct that ? regards 回答1: There May be an-other way to get rid of that, but my approach is that you may add a focusIn event and do some thing like : <s:TextInput id="textInput" x="10" y="24" prompt="Enter SomeThing" focusIn="textinput1_focusInHandler(event)"/>

Displaying movieclips from an array in sequential order

不打扰是莪最后的温柔 提交于 2019-12-24 07:31:16
问题 Here is what I am trying to do: Establish an array of movie clips in the library Randomize the order within the array On enter frame, display the first movie clip in the randomized array When a "next" button is clicked, the existing clip with unload and the next move clip in the array order will load Once the last movie clip in the array has been displayed and the "next" button has been clicked, the first movie clip in the array will load. this will repeat over and over if the user keeps

Actionscript 3 ContextMenu closed event?

我怕爱的太早我们不能终老 提交于 2019-12-24 07:10:14
问题 There is an event which is dispatched when the context menu (right click menu) in actionscript for flash has been opened: ContextMenuEvent.MENU_SELECT Now, is there an event which is dispatched when the menu has been closed? 回答1: Good question. That would make a nice feature request, an ContextMenuEvent.MENU_CLOSED event :) I think I have half you're answer. Here's my idea: var myContextMenu:ContextMenu = new ContextMenu(); var menuLabel:String = "Custom Item"; var rightClicking:Boolean;

Link button in action script3 + fade out in jQuery integration

﹥>﹥吖頭↗ 提交于 2019-12-24 06:58:37
问题 I need help. I'm a graphic designer and i new to jQuery. In AS3 i find nice jQuery script - if you click to link the website its fade out and new site fade in. I use custom.js in html5 page $(document).ready(function() { $("body").css("display", "none"); $("body").fadeIn(2000); $("a").click(function(event){ event.preventDefault(); linkLocation = this.href; $("body").delay(2000).fadeOut(2000, redirectPage); }); function redirectPage() { if (location.href.indexOf('reload')==-1) location.replace

How can I trigger a function at Main from an instanced object — the right way?

时间秒杀一切 提交于 2019-12-24 06:47:09
问题 I want to keep total control over my game from the Main MovieClip and nowhere else. But I don't want to pass its instance through constructors neither do any .parent reference thingy from its children. Seems too workaroundish and unstable. A sample situation: public class Main extends MovieClip { public function Main() { addChild(new MainMenu()); } public function startGame():void { trace("Game started"); } } public class MainMenu extends Sprite { public function MainMenu() { var option

Error in Flash addition

谁说胖子不能爱 提交于 2019-12-24 06:45:04
问题 Make a new AS3 Document in Flash, paste in the following code and run it: var a:Number=0; trace(a) // 0 a+=0.3; trace(a) // 0.3 a+=0.3; trace(a) // 0.6 a+=0.3; trace(a) // 0.8999999999999999 a+=0.3; trace(a) // 1.2 a+=0.3; trace(a) // 1.5 a+=0.3; trace(a) // 1.8 a+=0.3; trace(a) // 2.1 a+=0.3; // ^ This is the output. Notice the inaccuracy starting from 0.9 / 0.89 Why the error? I'm just doing an ordinary hi resolution addition. Any workarounds? 回答1: This is a standard floating point problem.

AS3 RegEx returns null

≯℡__Kan透↙ 提交于 2019-12-24 06:43:46
问题 Can anyone explain why the code below traces null when on the timeline? var cleanRegExp:RegExp = /^[a-zA-Z0-9]+(\b|\/)/; var str:String = "/num83r5/and/letters/4/A/"; trace(str.match(cleanRegExp.toString())); I've read the documentation, so I'm pretty sure that I'm declaring the RegEx correctly and that String.match() should only return null when no pattern is passed in, otherwise it should be an array with 0+ elements. I suspected a badly written expression, but surely that should still