ActionScript 3.0 :: Flash Length Property Not Adding Up?
May 17, 2010
I have two values which are both ints: val1 and val2.
I set a movie clip's width equal to the difference of the two values:
mc.width = val1 - val2
After doing this calculation, the width of the object is 149.9 when it should be 150. This happens for other values as well. When I trace(val1 - val2), it returns 150.
What seems to be happening is the width value of my movie clip is not adjusting correctly. My movie clip is composed of a bunch of bitmaps and filters. I didn't think this would be a problem, but when I switched it out for a plain shape, the problem went away.
Is there something funny about bitmaps or filters that would make the width value screw up by .1?
I have 3 input textfield. Each textfield has a string pre-loaded into it. When user pressed Tab, the focus should be cycled around textfield 1-3. Now, I'm trying to set the caret index to the last letter of the textfield. What is wrong with the code?
Code: public function myTabKeyDown(event:KeyboardEvent):void {
I have a Flash based media player loading mp3s at 22.050 khz, and for some reason the length is being reported as a little over twice what it should be. Is there anything I can do, short of dividing the results by 2?
I would like to put an eventListener on an ArrayCollection's length proprety, but I don't know how to go about this.
I want to do this because I only want code to execute when a certain number of things are in a certain ArrayCollection. I want Flex to wait to execute this code over the next object until that length property drops back to an acceptable level. I think I should do this with events instead of a while loop that sits there spouting NOOPs forever (which I don't know how to do either).
I am looking at "length" property in the Adobe AS3.0 language ref as I do not understand it. It says: An integer specifying the number of characters in the specified String object. (I understand this). Because all string indexes are zero-based, the index of the last character for any string x is x. length - 1. (I do not understand the "- 1". I understand that all string indexes are zero-based but I cant put this together with the last character for any string being -1 or whatever it is saying.
generally, how i work involves designing all of my graphics in Flash Authoring, converting them to Sprite symbols by changing the base class to flash.display.Sprite, give my instances names and finally export them to ActionScript.the approach actually permits me to dynamically create properties in code on my Sprite instances that i've exported to ActionScript, just as if they were instances of MovieClips. i'm not entirely sure why i'm able to do this, but i can. in polling the objects to make sure of their superclass, they are indeed Sprites and not MovieClips.however, as expected, if i program a new sprite from scratch in code and try to dynamically add a property to the new programmed sprite a compile time error will result.
I am using an array to return data to an application and as the array is filled with data using a loader and the order is important it happens that data in slot n is inserted later than data in slot n+1. How do I know that the array is full as I know the number of elements to be loaded? The length property doesn't work for this. I could go through the array each time I put something in and look if every slot is full but that seems ineffective.
Let's say I have array foo and a positive integer y, where foo.length > y.I want to remove elements from foo so that foo.length becomes y (or very close to it).Also, I need to preserve the first and last element of foo. The indices of the removed elements must be spaced apart as equally as possible. Foo can be sliced, or it can be used to create a new array.
Example: if foo = [a,b,c,d,e,f,g,1,2,3,4,5] and y = 6, then trimmedfoo could be [a,c,e,g,2,4,5] or maybe [a,c,e,2,4,5], but not [a,c,e,g,2,4] because the last element of foo is missing.
Is there any way to determine if a (anonymous) function has defined the ...(rest) parameter in ActionScript 3? I know there's the function.length property, but it only counts the explicitly defined arguments.
I want to add a function as a property something similar to this is what i'm looking for (only that this generates an error).
ActionScript Code: function getPosition():Point { return new Point(this.x, this.y); }
[code].....
And i know i can create a class in an external file. But this is supposing i want to keep it in the same file. And i know that is not a good idea either, but just assume that i have a valid reason.
I have the 4 countries of the UK that get scaled up on click. I because each country is a different sizes geographically they do not scale up by the same amount. I would like to set a pixel scale size like this (scotland is the name of the movieclip)
I am not sure if this is possible, but can I add a custom property to the MovieClip class. I'd like to add a tooltip-functionality to some things so I'd just need a "tip"-property in which I can store a String. Would this work, or do I have to create a new Class extending MovieClip?
I am generating the following text box and the data in it dynamically: _root.createTextField("recipe"+i+"_txt", _root.getNextHighestDepth(), 5, 100, 600, 400); The problem I am having is the text that is generated only stays on one line and therefore doesn't fit into the text field. I know there is a way to add the multiline property to other types of components but can this be done dynamically?
What I deduce from this example is that the swfLoader.contentLoaderInfo and _ldrInfo = this.contentLoaderInfo refer to the same object in the same memory location. So you may think: "well the last added event will overwrite the first one (the internally one added). But it doesn't. The two event listeners will respond sequentially. First the internal listener and then the external listener.
I can't get the letterspacing property to function in a dynamic text box, I have tested it with color and it works just fine. just letterspacing. And I have embedded the font, so I know it isn't that. The code affecting the text box is this.
Code: var txt_box0:TextField var format1:TextFormat = new TextFormat(); format1.letterSpacing = 4 //trace(format1.letterSpacing) txt_box0.setTextFormat(format1)
Those working with AS2 have had similar problems but managed to fix it by typing "setNewTextFormat", which has been phased out in AS3.
I'm wondering if there is a way I can bind a flex property to flash property?, the flash property is inside a swc file created in flash with the Flex Component Kit for Flash Professional, I can manipulate the flash component as a regular flex component, but I want to bind their properties, is there a way?
I have situation I want the player to play the video from the beginning to only 15 sec, even the video length is more than 15 sec for example it will be about 10 min. but I only want it to play beginning 10 sec. Is there a way for the flash player to only play 15 sec of the video? how is this work, and what function should I look for? is it also possible with HTML5 player?
I am making a side scrolling flash game. The level is pre-made so there arent objects wich spawn on runtime. Now I made this level quite long, but in the editor window it suddenly stops. But in game it still scrolls on.This is in the editor.You can see that the scroll bar cant go left any more.The level is longer than then shown in editor. At first it was just putting an object at the border of the scene to increase it.
This is my first time posting to a forum as I have been unable to find the solution to this problem. I am receiving an array from a php script in this manner[code]...
I load a song and when I get the length the song never reach this value.Here is issue document by another guy AS3 - SoundChannel.position never reaches Sound.length.And here is my code