Personal tools

Views

Talk:ActionScript 3

From Adobe Labs

If you intend to edit the 'Discussion' tab of this document, you must sign your comment. To do so, simply add four tilde characters as so:

~~~~

...on a new line at the end of your post to add your username and timestamp to the comment. Anonymous or off-topic comments will be removed by the Labs wiki administrators at their discretion.


Table of contents

In-Player content

What classes contained in the API are intrinsic? How big is the compression rate of compiled AS3 classes or different asked: What classes used of the API will increase the .swf filesize?

[James] At some point the source class files will be released along with a published complete API, but not at the current time.

Currently the AS3 compiler does not optimize for file size, but you can be sure that by RC1, file size will be comparable to the AS1/AS2 compiler's output.

Your last question can really be answered only by careful testing. Although we know that using more basic classes than classes further down an inheritance tree will ultimately lead to smaller swf file size, it might also require more custom actionscript. But again, when the source class files are released, we can better gauge which of the classes we should use in specific cases.

I'm sorry for being ambiguous, but be on the lookout for updates in the future.

jameslyon 07:57, 28 Oct 2005 (PDT)

For ... in loops for all classes?

For ... in can be good handlers for different classes.

If you choose to use a Iterator interface with

 next(Void):Object
 hasNext(Void):Boolean

it is possible to implement for ... in loops for all classes. It would be nice to have something like this to enjoy for ... in loops in custom classes too.

Overloading?

Page 47 of [1] displays in its example:

var numRectangles = rectangle.length(); // returns 1 – number of <rectangle> elements var rectangleLength = rectangle.length; // returns 20 – content of <length> element

This means AS3 has to support overloading if it wants to support E4X. Is this the case?

[James] I'm afraid, I can't find that example. Are you sure about the page number?

But the example you quoted uses two different ways of accessing different values.

-- a normal method -- rectangle.length();

-- a getter method or a public property -- rectangle.length;

jameslyon 07:57, 28 Oct 2005 (PDT)

Well but exactly this is overloading ... the same name with different usage. Of course different arguments is the main usage. But in any case it actually requires to save multiple items with one child name.

[James] Overloading implies the exact same method but with different arguments. A getter method is not the same as a normal method with the same name. But I'd like to see the example that was posted up above, to see the context.

jameslyon 15:07, 2 Nov 2005 (PST)

[Jason] Actually, there are two different things at play here. One is the call to the length() method of the Xml object. The other is asking for the 'length' element (which is made to look like a property). It's not overloading - it's more like syntactic sugar on the Xml object allowing you to query it's nodes by name. Where the nodenames and method names overlap it appears to be overloading, but really it's not - just a different resolution based on the context.

This can be (imho) problematic, though, in that there can be ambiguous references...however, this would explain why [xmlObject].length() is a method and not a property. However, it might be better named 'getLength()' to avoid the ambiguity....

--good-question 09:19, 3 Jan 2006 (PST)

computeSpectrum and FFT

The computeSpectrum seems to work fine using readFloat to access the byteArray. To do that I use the following code:

while(i>1024){

   spectrum.position=i;	
   sprites_array[Math.round(i/4)].scaleY=(spectrum.readFloat()*100);
   i=i+4;

}

Now if you actually want a spectrum graph instead of a raw wave you need the FFTMode set to true. But that just seems to return a random mess and nothing like a spectrum graph. Am I missing something or is the FFT not working as it should?


I've had the same results with FFT not working.

You can also use the following:

while(spectrum.bytesAvailable) {

   spectrum.position=i;	
   sprites_array[Math.round(i/4)].scaleY=(spectrum.readFloat()*100);
   i=i+4;

}

Bryan Ledford 23:25, 10 Nov 2005 (PST)


I've had the same results as well:

it looks like FFT is returning frequencies over 2-3k --- all sound sample frequencies below that threshold are being combined together. It looks like the frequency range is going all the way up to 20k -- i think in most mp3's, the frequency range doesn't exceed 15k.

Event

--Sérgio Vasquez 03:34, 7 Nov 2005 (PST) Hi all!

I have a problem with dispatch events between classes. How I can dispatchEvent a class and listener another class.

Sample:

- Class Business:

public function ListBible():String {

       webservice = DataAcess.wsHelper(Common.getDomain("1"));

var call:Object = webservice.GetBookTitles(); call.resultHandler = function (event:ResultEvent):Void { I want return de value event.result

               I Try   return event.result, but the flex lost a data.

} }


Another class call the function.

Thank You!

Private/protected constructors?

I've run into (what I believe to be a) bug, in that a constructor cannot be defined as anything other than 'public' in AS 3.0 (Flex Builder Alpha).

Is this a design decision or a bug? If the former, what was the reasoning behind disallowing private/protected constructors? If the latter, any idea if/when it will be resolved?

[See a related blog post for examples where having private/protected constructors is wanting.

--good-question 13:48, 7 Nov 2005 (PST)


I asked the same question and was told it was a design decision. I can see the concern though, as current Singletons must be refactored.


jameslyon 10:54, 28 Nov 2005 (PST)

Flex 2 + AS 3 + SSL

Are there classes in Flex 2 to work with SSL ?


- Not really. AS3 includes some classes that allows to use SSL for specific purposes (NetConnection and Loader, at least), but there isn't anything like a SSLSocket class. Guilt Puppy 20:20, 20 Jan 2007 (PST)

Release data (app!) for AS3 / Flex 2

Hi,

I was just curious - I'm quite thrilled with the new ActionScript version as well as the same for the Flex Framework, but does anyone have any idea as to how long it will normally last from the release of the Beta-version to the official version - i.e. when you can start developing applications for a new version of the Flash player, available to the general public?

--Bobozz 08:10, 27 Feb 2006 (PST)

MODAL Dialog Box

Hello Macromedia/Adobe!Media:Example.mp3

It's been quite a while since I've been continuously thrilled and amazed by the new features of the MXML and AS3.0.

However, my happy days has gone when just recently , I've come into some tricky issue:

How can an execution thread wait for user input, same as one can do with JavaScript's Alert box? Does the new AS 3.0 have any kind of REAL modal dialog box behavior? I mean, if JavaScript does have something that holds the execution thread, why doesn't ActionScript too? Especially when you've announced your intention to adapt Flex for the RDAs (Rich Desktop Applications).

Must I say, that I didn't find anything related to this issue in the scarce Flex documentation.

Anyway , as bottom line, if the intention of this blog is also to play the role of a users wish list, I'd like to to express LOUD and CLEAR:

It would probably be really useful to have a real MODAL dialog box class that could hold code execution!

Thanks!

iuliks 07:12, 7 Apr 2006 (PDT)


AS3 runs on one thread. block that thread, and nothing will happen. Most browsers will also quickly block waiting for that thread to yield.

In short, you don't really want to hold code execution while a modal dialog is showing. You want to refactor your code to wait for the modal dialog to emit an event to know when to continue your code path.

For reference, the javascript alert() code on gecko-based browsers (firefox among others) does not fully hold code execution either. setTimeout() events will keep firing even while the modal alert dialog is showing.

Guilt Puppy 20:24, 20 Jan 2007 (PST)

how to use mx.controls.*?

hi

I'm trying to use the mx.controls. so I have this code here


package { import flash.display.Sprite; import mx.controls.Button; public class Test extends Sprite {


public function Test() { init(); }

private function init():void { var btn:Button = new Button(); addChild(btn); } } }


I use the FlexSDK2 to compile the code. It compiles but when I open the swf I get those 2 errors

VerifyError: Error #1053: Illegal override of releaseCapture in mx.core.UIComponent.

and

ReferenceError: Error #1065: Variable Test is not defined.

now my question. Whats wrong?

Retrieved from "http://labs.adobe.com/wiki/index.php/Talk:ActionScript_3"