ActionScript 3.0 :: Flash - Calculating Order Of Boxes As Per There Position
May 28, 2010I am working on sequence quiz engine. I have a function to sort boxes (dynamically generated Movieclips) which calls on every release of boxes.
[Code]...
I am working on sequence quiz engine. I have a function to sort boxes (dynamically generated Movieclips) which calls on every release of boxes.
[Code]...
I'm trying to jump to a position in the mc by clicking on a progressbar that is 388 pixels in width the total frames of the mc I am trying to jump to with the progressbar is 3348 my function is:
Actionscript Code:
progressBarMC.progressBar.onRelease = function(){ mc.gotoAndPlay(mc._totalframes / this._xmouse * 24); trace((Math.round(mc._totalframes / this._xmouse * 24)));};
i'm in the middle of attempting to write my own collision detection algorithm because the built in 'hitTestObject' function seems to be incredibly inaccurate (it's registering 'hits' when the objects are still a considerable distance from each other).I need to be able to calculate the position of each of the 4 corners of a rectangle, based on its rotation. Obviously one of the corners will simply be the rectangle's x and y coordinates. I have made a little test program to make sure I am calculating the positions of the corners accurately - it works when the rectangle is rotated to 0, 90, 180 and 270 degrees, but produces strange results for any other angles.[code]
View 7 RepliesI have a couple of images, representing tents, that look like this: The red and blue parts on each side of the tents are doorways, and several tents can be connected together via these doorways. For example, I want to connect the two blue doorways so that they match up like in this picture: If the first tent is stationary, around which point do I rotate the second tent and how do I calculate where to place it?
Currently, I have the upper left corner of each doorway as an x and a y value, together with the width and direction (in degrees) of the door. I'm treating the doorways as one dimensional, so they don't have heights. Would another representation suit this better? Perhaps a start point and an end point plus direction?
How do you change the TAB order of text input boxes. I want to tell it what box to go to next depending on which one it is on now making a login form ..
View 2 Replieshow do you change the TAB order of text input boxes i want to tell it what box to go to next depending on which one it is on now making a login form ..
View 2 RepliesI am inputting text from an xml file into dynamic text boxes; I have static text boxes as titles of each.
making the dynamic text boxes expand if the xml text is of a larger size & moving the static text boxes so they don't start getting over written.
The code Ive used to put the text into the dynamic boxes is very simple:
var xmlData:XML = new XML ();var theURL_ur:URLRequest = new URLRequest("xml.xml");var loader_ul:URLLoader = new URLLoader(theURL_ur);loader_ul.addEventListener("complete", fileLoaded);
[Code]....
If I have several items that move across the screen but the user can click any of them at any time, how do I record the current position of any of the items item in order to use that data to change the position of the item after the user clicks?
This is what I am doing: I have 11 images that slide accross the screen. The user can click any of them at any time. When he clicks one I am scaling the image so it looks like it is comming forward (z axis) and then the rest of the images are scaled down so it looks like they are going back on z axis. So what I am trying to do is get the current position of the image when the user clicks the image so that I can use that to correctly estimate the scaling and moving of the image to make it look like it scales from the center and not from the top left corner. So if have a variable that gets the current position of the image being clicked I'm thinking I can change its position using something like: x = currentposition + -45;
I am developing a game for mobile in AIR (as3). I have created some bots for this game that initially just wander around. But when a bonus enters the stage, they have to move to the bonus.The detection of a new bonus and moving of the bots works fine, but there is something wrong with the manipulation when a new bonus enters the stage.Basically, this is how it works (or I try to make it work):My bot moves along with his rotation as a parameter. (works fine)
private function moveToNextLocation():void
{
var angle:Number = _rotation * 0.0174532925; // 1 degree = 0.0174532925 radians
var speedX:Number = Math.sin(angle) * _speed;
[code]....
I have flash create an empty movieclip, screen_1, then attach 4 different colored movieclips to the empty one: box_1, box_2, box_3, box_4.Now I am trying to change the position of one of the boxes with the number of the box as a stored variable. So say:
boxNum = 1
this["screen_1.box_" + boxNum]._x = this["screen_1.box_" + boxNum]._x +1600
I can get this to work on the main movie clip.. but not on the movieclips inside of it.
take the children of an object, the children are groups nested within a parent group, and sort them based on their x coordinate. so the one furthest left (lowest x) is in position 0 and so on.
View 3 Repliesthis concerns flash cs5 and the timeline.Everybody knows the effect you get when you use appendText() to add text to a multiline dynamic textfield, right ? Well, I have a movieClip as a container, and I would like dynamic textfields to populate this movieclip in the same manner as textStrings would populate the dynamic Textfield.
How would this work?I have buttons that trigger addChild() function so as to populate the movieclip with textfields, but how do I make sure that the textfields make up an arbitrary list as a menu user chooses which buttons to click?
Let's say this is the visible text when the swf runs.(I cut away some of the code to make this more to the point):
var buttonTrace:TextField=new TextField;
addChild(TextClip.buttonTrace); buttonTrace.x=0;
buttonTrace.y=0;
buttonTrace.text="Breadcrumbs";
Now for each time I click a button in the menu I've made, a new textfield appears with the name of the button. This is how I want it. BUT......... How do I control the display properties and positioning of dynamic textfields within a movieclip ? How do I control persistent visibility, and how do I make these textfields appear one after the other in the order they were clicked.
I am creating an order form for my flash site. I have never done this before in flash but I have in visual basic. I have a few questions:
1. Is assigning variable names to checkboxes and radio buttons the same as in visual basic? I mean i know that you probably assign them in the properties. ex..say i name a radio button 'radio1', to run a check in my actionscript whether radio1 was checked or not would it be something like if(radio1){}
2. After the person fills out the form I would like to have the results of the order sent to a pre-specified email adress in a certain format. What would be a good way to do this?
i need to combine these two scripte (first one creates array to play movie clips in a order fro left to right of the screen depending on position ) each script works corectly if used on there own. but i want to combine them
var videos:Array = new Array("mc1", "mc2", "mc3", "mc4");
var busy:Boolean = false;
for(var i = 0; i<videos.length; i++)[code]....
I'm making a program that draws a grid of boxes and the color of the box must be different to those adjacent to the box. My code compares the current box's color to those to the left and top. If any of them matches, it picks another random number (as the color). For the tiles on the first row/column, I make my grid's array indexes with negative numbers -1 so that it will not match.
What I have:
private function fillArray():void {
grid = new Array();
grid[-1] = new Array(-1,-1,-1,-1,-1); //paddles the grid[-1][0 to 4] with -1
for (var i = 0; i < HEIGHT; i++) {
[code]...
I'm creating a drag based control in Flex / Flash, similar to a film strip, where an individual can swipe horizontally to scroll through the items. To make the control feel a bit more natural I've added some inertia to slow the scrolling once a swipe has taken place. When first loaded up there will be five items in view with 'x' numbers of items to scroll through with the 3rd item centred and selected.
My problem though is that I want, when animating, a swipe gesture to determine whether an item will end up the middle (3rd position) and adjust its movement calculation accordingly so it docks with the 3rd / centre position. Imagine you perform a long swipe, it flys pasts 'x' amount of items, but as it slows to a stop it elegantly stops with an item centred / in the 3rd position. To do this I believe I need to determine the distance to travel just from the speed value (as time is irrelevent to the user experience, i.e. a longer / stronger swipe would justify a longer animation skimming through the items).
At the moment I'm invoking the animation routine (with inertia) in the ENTER_FRAME event when the user generates a MOUSE_UP event. When they do this, I obtain the speed of drag (by monitoring this beforehand) and then decrement this speed value on each call of the ENTER_FRAME event until it reaches an appropriate value to stop the animation.
Unfortunately all the speed calculations I've seen deal with Speed and Time to determine distance, I just need Speed. Admittedly, my knowledge isn't strong in this area so I might be missing the obvious.
Here is the thing I have a movie with X scenes and I want the progress bar to fill up according to the porcentage of my timeline that has passed.here is the code I'm using
Code:
var parcialSeek
var completeSeek
[code].....
I'm trying to calculate how WIDE to make my button, based on the text that it will contain, and when I try to google for how to calcuate something as simplistic as the WIDTH OF SOME TEXT, I go cross-eyed just trying to wade through apparently nonsensical esoteric counter-intuitive voodoo. how I would write a function like this:
public function HowWideWouldThisTextBeIfItWereInThisButton(Text:String,Container:Button):int {
...
}
I have a 2D side scrolling game (made with ActionScript 3) that runs at 60 frames per second. I'm trying to make it frame rate independent so it will run on slower devices.
To do this I create a var called timeElapsed by calculating how many milliseconds have passed between each frame and dividing that by 16 (60 fps is about 16ms, I think.) So that at 60 fps the result would be about 1. Then I times any time related vars by this number (e.g player.x = speed * timeElapsed;) This is the code:
private var oldTime :Number;
private var defaultFrameRate :uint = 16; // the default frame rate in milliseconds
private var timeElapsed :Number;
[Code]....
As you can see, at 30 frames per second the player is moved further in the same amount of real time. What seems to be the issue is that, at 30fps in frame one, my current code doesn't account for the slight difference in speed between frame one and two at 60fps. I thought of getting the average value of speed between any two frames at 60fps and using that to calculate a more accurate value when the frame rate changes but I got the feeling wouldn't work correctly in some other situations since at 60fps for example, it would move the player by 115 and not 110 pixels.
Is their any way to accurately simulate an object accelerating in a way that is frame rate independent?
sorting number Ascending Order and Descending Order tutorial with out useing sort property[Array sorting like 91,3,5,4,6,8,3,6,1,0]
View 6 Replies[code]how to do Ascending Order and Descending Order this array merge(don't use sort property)
View 1 RepliesI have an array, and I add info dynamically into it. I need some way to re-order the array into ascending order.
Another thing. How can I add a value in the first position of the array pulling keeping all the other values jumping to the next position.
I have simple image gallery, where images are placed one next to another and the mask is revealing only one of them. Now I want to tween position of the images, but when I do that the mask is "traveling" alongside with the images..
View 4 RepliesSo I'm trying my hands on some full browser flash and after reading a couple of tuts I wrote this
Code:
#include "mc_tween2.as"
Stage.scaleMode = "noScale";
stageListener = new Object();[code]...
The trace's are because it didn't work like I thought it would.Etc the middle movieclip didn't center itself but rather positioned itself seemingly how it pleased so I traced its x position and the var stageXcenter position and like suspected it shows different values.
I am trying to use boxes for hit collision. I want to be precise with the collision so I was thinking about making multiple small boxes and checking for collision that way. This maybe a stupid idea or a smart one. If I do this way will that affect the performance of the game even though the boxes are invisible and wont be drawn on the stage.
map out the object starting from its center outward. Like right, left, top and bottom. I am creating a flying shooter so the plane has a long wing span. I could also map out the wing span and tail and so on.
I'm trying to animate a simple stick figure just now. I used an inverted triangle shape for the body,which gives a nice width to the shoulders. Unfortunately, flash doesn't seem to realise that it's a triangle. Due to it's stubborn way of drawing a rectangular bounding box around every shape.
This is getting in the way a lot, as there are parts of figure which are clearly not blocked by the torso, but are blocked by it's big square bounding box, which makes it a nightmare to drag the arms and legs around to where I want them
Is there any way to fix this silly behaviour, and have it only select an object when I click on a visible part of it, and not just anywhere in it's bounding box ?
Is it possible to set up comment boxes on a flash movie? For instance, if I am viewing a page on my flash movie and I wish to make a comment on it, is there a way to set up a comment box and also show all of the previous comments as well? I figure it is but I am just unsure as to how to start it.
View 1 RepliesI am a PHP Developer, I know nothing about Flash and with all respect I do not want to know anything about. I develop a CMS which provides the backend for a Flash front end. Data is passed to the template via XML. Everything is grand. The problem is with text formatting. Currently we use the dodgiest flash text formatter. It doesn't work half the time, its horrible but it - just about - does the job. I have been tasked with replacing it. I would like to bring in CKEditor or TinyMCE but when I do I have 2 major problems.
1) Pre-existing HTML messes up the display in TinyMCE due to its invalidity (I can solve this.)
2) The TinyMCE HTML breaks the flash template because of the valid HTML.
I have an interactive assignment in which the students have to enter text entries into an input box. I have it working to where when the enter the correct answer it will tell them, or if it's wrong. I need to be able to tell them when they get to the last question, after they have gotten all of them correct, that they got all the questions correct. I know how to do this with a drag and drag interaction but not text entry. can someone point me in the right direction?
View 4 RepliesIm working on a project which includes a text editor in Flash which works perfectly but im trying to alter the code so the editor works over several input boxes rather than just one. Using Flash CS4 btw. Here is the actionscript im working with. If someone could give me some pointers as to how to allow the code to edit text in multiple boxes i would be eternally grateful.
[Code]....