Search Results

Search found 908 results on 37 pages for 'as3'.

Page 9/37 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Help needed throwing a ball in AS3

    - by Opoe
    I'm working on a flash game, coding on the time line. What I'm trying to accomplish is the following: With the mouse you swing and throw/release a ball which bounces against the walls and eventualy comes to point where it lays still (like a real ball). I allmost had it working, but now the ball sticks to the mouse, in stead of being released, my question to you is: Can you help me make this work and explain to me what I did wrong? You can simply preview my code by making a movieclip named 'circle' on a 550x400 stage. stage.addEventListener(Event.ENTER_FRAME, circle_update); var previousPostionX:Number; var previousPostionY:Number; var throwSpeedX:Number; var throwSpeedY:Number; var isItDown:Boolean; var xSpeed:Number = 0; var ySpeed:Number = 0; var friction:Number = 0.96; var offsetX:Number = 0; var offsetY:Number = 0; var newY:Number = 0; var oldY:Number = 0; var newX:Number = 0; var oldX:Number = 0; var dragging:Boolean; circle.buttonMode = true; circle.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); circle.addEventListener(Event.ENTER_FRAME, throwcircle); circle.addEventListener(MouseEvent.MOUSE_DOWN, clicked); circle.addEventListener(MouseEvent.MOUSE_UP, released); function mouseDownHandler(e:MouseEvent):void { dragging = true; stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler); offsetX = mouseX - circle.x; offsetY = mouseY - circle.y; } function mouseUpHandler(e:MouseEvent):void { dragging = false; } function throwcircle(e:Event) { circle.x += xSpeed; circle.y += ySpeed; xSpeed *= friction; ySpeed *= friction; } function changeFriction(e:Event):void { friction = e.target.value; trace(e.target.value); } function circle_update(e:Event){ if ( dragging == true ) { circle.x = mouseX - offsetX; circle.y = mouseY - offsetY; } if(circle.x + (circle.width * 0.50) >= 550){ circle.x = 550 - circle.width * 0.50; } if(circle.x - (circle.width * 0.50) <= 0){ circle.x = circle.width * 0.50; } if(circle.y + (circle.width * 0.50) >= 400){ circle.y = 400 - circle.height * 0.50; } if(circle.y - (circle.width * 0.50) <= 0){ circle.y = circle.height * 0.50; } } function clicked(theEvent:Event) { isItDown =true; addEventListener(Event.ENTER_FRAME, updateView); } function released(theEvent:Event) { isItDown =false; } function updateView(theEvent:Event) { if (isItDown==true){ throwSpeedX = mouseX - previousPostionX; throwSpeedY = mouseY - previousPostionY; circle.x = mouseX; circle.y = mouseY; } else{ circle.x += throwSpeedX; circle.y += throwSpeedY; throwSpeedX *=0.9; throwSpeedY *=0.9; } previousPostionX= circle.x; previousPostionY= circle.y; }

    Read the article

  • Commenting Code AS3 - Not being an API

    - by Marcelo Noronha
    How should I comment a method? What are the best practices on commenting code? Example: /* Checks if a color is allowed in a given point * of the bitmapdata of the current floor * @param value - color to be checked * @return boolean - if color is allowed returns true, else, return false */ private function isAllowed(value:uint):Boolean { //code... } Is that the best way to comment a method? I´ve heard there´s the use of the tag @see. What should be on this tag? I wonder if it could be something that has a relation to the method, is that right? Thanks.

    Read the article

  • tic tac toe game ai as3

    - by David Jones
    I'm looking into creating a simple tic tac toe/noughts and crosses game in actionscript3 and am trying to understand the ideas behind the ai used in a game like this. I've seen some simplistic examples online but from what I've read a game tree or something like minimax is the best way to go about this. Can anyone help explain or reference any good examples of this? I've seen that there is a library called as3ds - data structures for game developers which has a number of classes that might help tie this together? Any info/examples or help is much appreciated

    Read the article

  • Fixed timestep with interpolation in AS3

    - by Jim Sreven
    I'm trying to implement Glenn Fiedler's popular fixed timestep system as documented here: http://gafferongames.com/game-physics/fix-your-timestep/ In Flash. I'm fairly sure that I've got it set up correctly, along with state interpolation. The result is that if my character is supposed to move at 6 pixels per frame, 35 frames per second = 210 pixels a second, it does exactly that, even if the framerate climbs or falls. The problem is it looks awful. The movement is very stuttery and just doesn't look good. I find that the amount of time in between ENTER_FRAME events, which I'm adding on to my accumulator, averages out to 28.5ms (1000/35) just as it should, but individual frame times vary wildly, sometimes an ENTER_FRAME event will come 16ms after the last, sometimes 42ms. This means that at each graphical redraw the character graphic moves by a different amount, because a different amount of time has passed since the last draw. In theory it should look smooth, but it doesn't at all. In contrast, if I just use the ultra simple system of moving the character 6px every frame, it looks completely smooth, even with these large variances in frame times. How can this be possible? I'm using getTimer() to measure these time differences, are they even reliable?

    Read the article

  • Make a turn based system like final fantasy in AS3

    - by Kaoru
    i wanted to make a turn based system like final fantasy tactics. I already created the map, which is 5x5 tiles grid and the characters which is each character places in the end of the tiles. I have 2 teams, which are named Red and Yellow. ------Red-------: First character is at 0,0. Second character is at 0,1. Third character is at0.2, fourth character is at0.3, and the last one is at0.4`. -----Yellow------: First character is at 5.0. Second character is at 5.1. Third character is at 5.2, fourth character is at 5.3, and the last one is at 5.4. I wanted Red team are moving first and make a decision (whether it is attack or wait), and after 5 characters of the Red team is already made a decision, the Yellow team is the one that make a decision (Yellow team is an AI) But, i don't know how to move my characters into the next grid (e.g: from 0,0 to 0,1) by clicking the left mouse button and also how do i display a grid (when select a move selection) that shows how many tiles that the character able to move. Anyone know about this? or how should i know more about this? is there any recommendations books or webs? And also, i don't know how to move the characters using mouse click.

    Read the article

  • AS3 Calculating Delta Time In Seconds

    - by user1133079
    Here is how I've been trying to implement delta time based on different internet resources. var startTime:Number = getTimer(); game.Update(deltaTime); deltaTime = Number(getTimer() - startTime) * 0.001; My issue with this is it doesn't seem to be giving me accurate timing. The main update shows the frame time at 0.001 and when reinitializing the level it goes to 0.002. I'm using dt else where for a timer and later on time based physics so I would like it to work as expected. I must be missing something silly.

    Read the article

  • AS3 - At exactly 23 empty alpha channels, images below stop drawing

    - by user46851
    I noticed, while trying to draw large numbers of circles, that occasionally, there would be some kind of visual bug where some circles wouldn't draw properly. Well, I narrowed it down, and have noticed that if there is 23 or more objects with 00 for an alpha value on the same spot, then the objects below don't draw. It appears to be on a pixel-by-pixel basis, since parts of the image still draw. Originally, this problem was noticed with a class that inherited Sprite. It was confirmed to also be a problem with Sprites, and now Bitmaps, too. If anyone can find a lower-level class than Bitmap which doesn't have this problem, please speak up so we can try to find the origin of the problem. I prepared a small test class that demonstrates what I mean. You can change the integer value at line 20 in order to see the three tests I came up with to clearly show the problem. Is there any kind of workaround, or is this just a limit that I have to work with? Has anyone experienced this before? Is it possible I'm doing something wrong, despite the bare-bones implementation? package { import flash.display.Sprite; import flash.events.Event; import flash.display.Bitmap; import flash.display.BitmapData; public class Main extends Sprite { public function Main():void { if (stage) init(); else addEventListener(Event.ADDED_TO_STAGE, init); } private function init(e:Event = null):void { removeEventListener(Event.ADDED_TO_STAGE, init); // entry point Test(3); } private function Test(testInt:int):void { if(testInt==1){ addChild(new Bitmap(new BitmapData(200, 200, true, 0xFFFF0000))); for (var i:int = 0; i < 22; i++) { addChild(new Bitmap(new BitmapData(100, 100, true, 0x00000000))); } } if(testInt==2){ addChild(new Bitmap(new BitmapData(200, 200, true, 0xFFFF0000))); for (var j:int = 0; j < 23; j++) { addChild(new Bitmap(new BitmapData(100, 100, true, 0x00000000))); } } if(testInt==3){ addChild(new Bitmap(new BitmapData(200, 200, true, 0xFFFF0000))); for (var k:int = 0; k < 22; k++) { addChild(new Bitmap(new BitmapData(100, 100, true, 0x00000000))); } var M:Bitmap = new Bitmap(new BitmapData(100, 100, true, 0x00000000)); M.x += 50; M.y += 50; addChild(M); } } } }

    Read the article

  • Keyboard is not detecting as3

    - by Kaoru
    i got this problem, when i press 1 in keyboard, the function does not run, even i already declared it. How do i solve this? Here is the code: public function Character() { Constant.loaderMario.load(new URLRequest("mario.swf")); addEventListener(KeyboardEvent.KEY_DOWN, selectingPlayer); } private function selectingPlayer(event:KeyboardEvent):void { isoTextMario = new Word(); isoTextChocobo = new Word(); if (event.keyCode == Keyboard.NUMBER_1|| event.keyCode == 49) { Constant.marioSelected = true; if (Constant.marioSelected == true) { isoTextMario.marioCharacter(); addChild(isoTextMario); } } else if (event.keyCode == Keyboard.NUMBER_2 || event.keyCode == 50) { Constant.chocoboSelected = true; if (Constant.chocoboSelected == true) { isoTextChocobo.chocoboCharacter(); addChild(isoTextChocobo); } } }

    Read the article

  • Cross-domain policy issues after redirect in Flash

    - by ggambett
    I'm having trouble with a cross-domain policy. I'm using the AS3 Loader to fetch an image; I'm making it load the policy file, like this : var pLoader : Loader = new Loader(); var pContext : LoaderContext = new LoaderContext(); pContext.checkPolicyFile = true; pLoader.load(new URLRequest(sURL), pContext); This works fine as long as the image is directly accessible; however, when the server sends a redirect, the loader follows it but loses the checkPolicyFile flag, resulting in a SecurityException - that is, it doesn't check the cross-domain policy of the redirected URL. I've found a solution here ( http://www.stevensacks.net/2008/12/23/solution-as3-security-error-2122-with-300-redirects ) but looks fragile (that is, looks like it will fail if there's more than one redirect). What would be the correct way of doing this?

    Read the article

  • Mixin or Trait implementation in AS3?

    - by Brian Heylin
    I'm looking for ideas on how to implement a Mixin/Trait style system in AS3. I want to be able to compose a number of classes together into a single object. Of course this is not a language level feature of AS3, but I'm hoping that there is maybe some way to do this using prototype based techniques or maybe some bytecode hacking that I believe AsMock uses to implement it's functionality. An existing Java example is Qi4J where the user define interfaces that the Qi4j framework implements based on metadata tags and coding by convention. Has anyone any ideas on how to get the Mixin/Trait concept working within AS3?

    Read the article

  • Eclipse and Actionscript 3

    - by teapot7
    Does anyone know of any good solutions (Eclipse plugins presumably) for using Eclipse to develop in ActionScript 3? There are a number of solutions for developing with ActionScript 2, leveraging MTASC, Swfmill and other open source tools, but I'm specifically looking for AS3 support. It's simple enough to use Eclipse as an editor, and a place from which to invoke Ant scripts to compile with the Adobe command line tools, but I'm looking for syntax colouring, autocompletion, refactoring, debugging - all the modern IDE luxuries. Other tool I've used: FlashDevelop: free and good, but Windows only and doesn't have refactoring. Nevertheless a nice piece of work. IntelliJ Idea: very nice ActionScript 3 support, though not quite as slick as their Java support. Unfortunately AS3 is not supported in the free/community edition of Idea and I'm not ready to purchase the full version as yet.

    Read the article

  • Retrieving/simulating run-time "layer" functionality in Flash under ActionScript 3.

    - by Triynko
    Are there any AS3 classes to help arrange objects into layers, like in the designer, such that the objects all have the same parent? Obviously, I can use container clips to simulate layers, but I specifically want this kind of functionality for objects that have the same parent. My understanding is that the design-time notion of layers does not exist at run-time, and objects just have a depth index. I'm creating a class to simulate layering functionality with a single parent, but if one already exists, I'd like to check it out. On a side note... how do design-time layer masks manifest themselves at runtime in AS3? I thought maybe all objects on the masked layer share the same mask object, but the "mask" property appears to be null for all objects on the masked layer, even though they share the same parent timeline as the unmasked objects (i.e. unmasked layer object parent == masked layer object parent; therefore, no masked subcontainers appear to be in use).

    Read the article

  • guide on how to kick start template based flash website?

    - by rizxta
    I'm very new to flash and as3 design patterns. But I can read and write as3 quite ok, i've created small widgets with that. I've developed several web sites using php and also python. Now for a educational cd-rom project i'm working on, i've basically designed all templates (A home page, a generic page with navigation and a sidebar - kind of like a wordpress blog). I have all the data for the cdrom on word files, which i intend to place on xml files. My question is what is the best way to start a project like this? Can anyone guide me to a template or something that can be used for kickstarting this? kind of like a wordpress (without the admin)? Or am i on this all wrong? Can someone please help

    Read the article

  • Is html/javascript equivalent to as3/flex?

    - by DJ.
    Hello my fellow coders, As i notice for a while now (like everybody else in the industry), the RIA market is shifting from AS3/Flex to HTML/Javascript. What i would like to know is? Is html/javascript as powerfull as as3/Flex or are they entirely different. With other words can i build the exact same applictions with HTML(4/5) and Javascript as i can do with AS3/Flex? I'm not looking for the speed comparison? or bashing one technology over the other? I just want to know if is good for me to dive into javascript, JQuery...... PS. If there is a nother post on stackoverflow with the exacte question. please share the link. Thanks. Thank you.

    Read the article

  • MYSQL accentuated characters é display as %E9

    - by Jk_
    Hi guys, I'm pushing data from as3 to MSQL through a little php script! My problem is that all my accentuated characters are displayed as weird iso characters. Example : é is displayed %E9 Obvisously the collation of my field is set to utf8_general_ci Even when I try to INSERT the data from a simple php script without as3, I get the same mistake. <?php mysql_connect("***", "***", "***") or die("Error :" .mysql_error()); mysql_select_db("***"); $query ="INSERT INTO test (message) values ('éèàïû')"; mysql_query($query) or die("Error updating DB"); ?> Any idea on what am I doing wrong and how I could fix that? Thanks in advance. Jk_

    Read the article

  • Port AS3/Flex app to iPhone

    - by John
    I believe Adobe tools like CS5 have ways to output as an iPhone app, but what about a regular AS3 or Flex project? Are there any tools to auto-port, or AS3/Flex iPhone implementations out there? Out of interest, how does the CS5 thing work? Is it a totally different code-path or something less drastic? For instance Flash supports Shapes and Timelines, etc... do they in fact provide an iPhone Flash runtime of some sort?

    Read the article

  • FLV performance and garbage collection

    - by justinbach
    I'm building a large flash site (AS3) that uses huge FLVs as transition videos from section to section. The FLVs are 1280x800 and are being scaled to 1680x1050 (much of which is not displayed to users with smaller screens), and are around 5-8 seconds apiece. I'm encoding the videos using On2's hi-def codec, VP6-S, and playback is pretty good with native FLV players, Perian-equipped Quicktime, and simple proof-of-concept FLV playback apps built in AS3. The problem I'm having is that in the context of the actual site, playback isn't as smooth; the framerate isn't quite as good as it should be, and more problematically, there's occasional jerkiness and dropped frames (sometimes pausing the video for as long as a quarter of a second or so). My guess is that this is being caused by garbage collection in the Flash player, which happens nondeterministically and is therefore hard to test and control for. I'm using a single instance of FLVPlayback to play the videos; I originally was using NetStream objects and so forth directly but switched to FLVPlayback for this reason. Has anyone experienced this sort of jerkiness with FLVPlayback (or more generally, with hi-def Flash video)? Am I right about GC being the culprit here, and if so, is there any way to prevent it during playback of these system-intensive transitions?

    Read the article

  • Fastest Strategy for Drawing Flash Particles

    - by user146543
    I am wondering what the fastest approach might be for using Flash/AS3 to render a 2D point plot (sonar lofargram) ; basically screens full of tiny 2D dots using Flash as fast as possible. Any suggestions on where to start? Is Flash capable of displaying 10's of thousands of 2D points (or more) with an acceptable fps?

    Read the article

  • Debugging in Flash CS4

    - by danyal
    Is a watch list hidden away somewhere in the AS3 debugger in Flash CS4? Sorry for asking a simple question like this here - I did spend a while looking around the net first. It's much easier to find the watch list in the AS2 debugger. Thanks, Dan

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >