Let's say I have an Array of numbers: [2,3,3,4,2,2,5,6,7,2]
What is the best way to find the minimum or maximum value in that Array?
Right now, to get the maximum, I am looping through the Array, and resetting a variable to the value if it is greater than the existing value:
var myArray:Array /* of Number */ = [2,3,3,4,2,2,5,6,7,2];
...
I have a sprite that I do some custom drawing in, but I would like the container to know where to position the sprite properly. To do this, the container needs to know how big the sprite is. UIComponents go through a measure stage, but sprites don't . How do I calculate the size that a sprite will be?
Edit: I'm doing the drawing in Even...
I have a swf (child.swf) that I wish to load into another (parent.swf). I wish to pass a parameter to child.swf through the loader I am using. Note that I am not trying to pass FlashVars that parent.swf already has, but rather I am trying to simply load a swf through another swf with custom arguments.
Any ideas?
...
Hello,
This question doesn't relate only to MouseEvent.CLICK event type but to all event types that already exist in AS3. I read a lot about custom events but until now I couldn't figure it out how to do what I want to do. I'm going to try to explain, I hope you understand:
Here is a illustration of my situation:
for(var i:Number; i <...
I work on a Flex app that loads external Flash resources created in CS3. I've just been reading about how I can use the Flex mx.managers.CursorManager class to change the mouse cursor explicitly. But what I'd ideally like to do is to set a mouse cursor property on some elements in the loaded Flash SWF, so as the cursor passes over this e...
Some methods in the Flex API such as CursorManager.setCursor(cursorClass:Class, priority:int = 2, xOffset:Number = 0, yOffset:Number = 0) take a parameter of type Class for a graphic. This example lets you specify a JPG/BMP/SWF as the cursor, but the only way I know to get a Class from an image file is using [Embed] in MXML, and this nee...
My Flex UI is communicating with a local HTTP server through a REST-inspired API. I want to be able to use HTTP's put, delete and head methods as part of the API. Currently, whenever I use mx.rpc.http.HTTPService and set the method to something other than get or post, the server only sees a get. The Adobe docs for HTTPService say:
Yo...
I would like to make a display object fullscreen in my Flex application. I understand it is easy to make the complete Stage fullscreen in flex (example). But I have two charts on my Stage and I would like to make one of the charts full screen on clicking a button (or on double clicking on the chart area) and as per my understanding a Col...
I understand how to declaratively assign a method to be called when an Image receives a MouseMove event.
<mx:Image
id="oneCent"
mouseMove="dragIt(event, 1);"
/>
How do I do this programmatically in Flex/AS3?
EDIT: Thanks for the comments. Here's what I have so far:
myImage = new Image();
myImag...
I have an interface that needs to react to "long key presses". That means 2 different actions for the same key based on how long the key has been down:
PRESS LEFT CURSOR: action A
PRESS & HOLD LEFT CURSOR: action B
Well, it's proving harder that I thought. The main problem is that both Keyboard.KEY-DOWN and Keyboard.KEY-UP fire contin...
Have you tried using straight javascript (rather straight ECMAscript 3 standard) in Flex applications, with none of the ECMAScript 4 enhancements?
If one were to do so, would it be better to let the AS3 compiler build from the javascript, or use the javascript bridge liberally?
...
hei,
I am not able to restrict this code to scroll only the front_mc and back_mc, in the front_mc are nested buttons that work and showing content on click - but the mouse-movement gets captured all the time so also content of the menu gets scrolled, when mouse is moved. please help me guys, I am not fit enough to deal with it.
root.ad...
How can I control the audio & pan levels of an external FLV or MP4 video that I am playing through a Video object?
In AS 2, the way to do this was to create an empty movieclip and then use the attachAudio function, which has been deprecated. Should I go about doing this the same way or is there a better way to control the audio without ...
In AS3 you have a function on a string with this signature:
function replace(pattern:*, repl:Object):String
The repl:Object can also specify a function. If you specify a function, the string returned by the function is inserted in place of the matching content.
Also, is it possible to get the the original string in which I want to re...
I want to set the enabled property on a button based on the return value of a function that has one or more parameters. How can I do this?
private function isUserAllowed (userName:Boolean):Boolean {
if (userName == 'Tom')
return true;
if (userName == 'Bill')
return false;
}
<mx:Button label="Create PO" id="createPOBut...
Let's say I have a resource file which exports mc1 with 4 frames in it. I would like to create a new MovieClip and insert frames like this:
mc2:flash.display.MovieClip = new flash.display.MovieClip()
mc1.gotoAndStop(2);
mc2.gotoAndStop(1);
mc2.currentFrame = mc1.currenctFrame
mc1.gotoAndStop(1);
mc2.gotoAndStop(2);
mc2.currentFrame = m...
I just finished writing my own collecion class, and i'd really like to make it iterable with the for each or the simple for construct, or just to access elements with the collection[key] notation.
I've written a getElementAt(index):MyOwnElement function, but using it, is not as sexy as using the square brachets, don't even let me start ...
I have a function that loads a user object from a web service asynchronously.
I wrap this function call in another function and make it synchronous.
For example:
private function getUser():User{
var newUser:User;
var f:UserFactory = new UserFactory();
f.GetCurrent(function(u:User):void{
...
ActionScript 3 / Flex 3 - Adding custom events to a class
Say I have the following Event:
import flash.events.Event;
public class SomeEvent extends Event
{
public static const EVENT_ACTION:String = "eventAction";
public function SomeEvent(type:String) {
super(type);
}
override public function clone():Event {
...
I'm developing a Flex 2 application, and I noticed that part of the library which is responsible for moving GUI windows (TitleWindows) around when you drag them with the mouse gets confused if there is a clickable (buttonMode = true) sprite beneath them. When I say confused, I mean that the window is moved around normally for a while, bu...