EzDevInfo.com

actionscript interview questions

Top actionscript frequently asked interview questions

Get size of ActionScript 3 Dictionary

var d:Dictionary = new Dictionary();
d["a"] = "b";
d["b"] = "z";

How to get the length/size of the dictionary (which is 2) ?


Source: (StackOverflow)

Flex: Text Input that accepts number only

Need a code that only accepts numbers. Upon inputting, the code must check if it is number, if not, it must remove the entered key or not enter it at all


Source: (StackOverflow)

Advertisements

How to deal with Number precision in Actionscript?

I have BigDecimal objects serialized with BlazeDS to Actionscript. Once they hit Actionscript as Number objects, they have values like:

140475.32 turns into 140475.31999999999998

How do I deal with this? The problem is that if I use a NumberFormatter with precision of 2, then the value is truncated to 140475.31. Any ideas?


Source: (StackOverflow)

How to check if two objects are of the same type in Actionscript?

I want to do this in Actionscript:

typeof(control1) != typeof(control2)

to test if two objects are of the same type. This would work just fine in C#, but in Actionscript it doesnt. In fact it returns 'object' for both typeof() expressions because thats the way Actionscript works.

I couldn't seem to find an alternative by looking in the debugger, or on pages that describe typeof() in Actionscript.

Is there a way to get the actual runtime type?


Source: (StackOverflow)

Test if an object is defined in ActionScript

In ActionScript, how can you test if an object is defined, that is, not null?


Source: (StackOverflow)

How do I get from an instance of a class to a Class object in ActionScript 3?

How do you get an instance of the actionscript class Class from an instance of that class?

In Python, this would be x.__class__; in Java, x.getClass();.

I'm aware that certain terrible hacks exist to do this, but I'm looking for a built-in language facility, or at least a library routine built on something reliable.


Source: (StackOverflow)

Static Actionscript code analysis?

I want to see class, function and variable/property, dependencies visually, like NDepend, but for ActionScript 2 or AS3 code.

Any programs or ideas?

Use Doxygen in some way?

FlexUnit?


Source: (StackOverflow)

How do I correctly pass the string "Null" (an employee's proper surname) to a SOAP web service from ActionScript 3?

We have an employee whose last name is Null. Our employee lookup application is killed when that last name is used as the search term (which happens to be quite often now). The error received (thanks Fiddler!) is:

  <soapenv:Fault>
   <faultcode>soapenv:Server.userException</faultcode>
   <faultstring>coldfusion.xml.rpc.CFCInvocationException: [coldfusion.runtime.MissingArgumentException : The SEARCHSTRING parameter to the getFacultyNames function is required but was not passed in.]</faultstring>

Cute, huh?

The parameter type is string.

I am using:

  • WSDL (SOAP).
  • Flex 3.5
  • ActionScript 3
  • ColdFusion 8

Note that the error DOES NOT occur when calling the webservice as an object from a ColdFusion page.


Source: (StackOverflow)

What is the best way to stop people hacking the PHP-based highscore table of a Flash game

I'm talking about an action game with no upper score limit and no way to verify the score on the server by replaying moves etc.

What I really need is the strongest encryption possible in Flash/PHP, and a way to prevent people calling the PHP page other than through my Flash file. I have tried some simple methods in the past of making multiple calls for a single score and completing a checksum / fibonacci sequence etc, and also obfuscating the SWF with Amayeta SWF Encrypt, but they were all hacked eventually.

Thanks to StackOverflow responses I have now found some more info from Adobe - http://www.adobe.com/devnet/flashplayer/articles/secure_swf_apps_12.html and https://github.com/mikechambers/as3corelib - which I think I can use for the encryption. Not sure this will get me around CheatEngine though.

I need to know the best solutions for both AS2 and AS3, if they are different.

The main problems seem to be things like TamperData and LiveHTTP headers, but I understand there are more advanced hacking tools as well - like CheatEngine (thanks Mark Webster)


Source: (StackOverflow)

IDE for developping in ActionScript (Flash). Any suggestions?

I started to work with Adobe Flash a few days ago and I'd say that the code editor lacks a few features before even being considered as an IDE (it sucks actually).

Do you know any other solution for developing in Flash ? For AS3 coding only, I don't care about designer and timeline... I just want to work efficiently with the code.

Thank you !


Source: (StackOverflow)

Best Tools for Debugging Flash ActionScript 3 (AS3) [closed]

Does anyone want to share the best debugging tools they have found for Actionscript 3 (AS3) and Flash CS5?

I've just done a search and found a few, but would love to hear from people who've actually used any of them. (In order of 'most promising')


Screenshots...

Adobe Scout:

De MonsterDebugger:

Thunderbird AS3 Console:

Luminic Box:

Senocular:

Xray:


Source: (StackOverflow)

How to make use of play2() function in order to perform fast stream switching of videos?

I am currently working on a Flash webplayer with resolution switching functionality. I am trying to make use of the NetStream class's play2() function in Actionscript.

The problem I am running into is that the videos don't change quickly. For those familiar with the play2() function I believe that the player is performing a "standard switch" rather than a "fast switch."

The documentation says that when the offset parameter is -1, fast switching occurs. What actually happens, though is once the "NetStream.Play.Transition" event is received, the player waits until the time denoted by ns.time + ns.bufferLength has been reached, before performing the switch.

I thought fast switching cleared the buffer, but on a check to ns.backbufferlength, I found that everything is still cached. Also it mentions: "When offset is -1, the switch occurs at the first available keyframe after netstream.time + 3," which is why I am confused.

Any help/insight on this matter would be much appreciated.

Here is a snippet of code describing what is going on (newStream() is called when a user clicks to change to a new resolution, youtube style):

public function newStream(address:String):void
{
    var opts:NetStreamPlayOptions = new NetStreamPlayOptions();
    opts.streamName = address;
    opts.transition = NetStreamPlayTransitions.SWITCH;
    opts.offset = -1;
    ns.play2(opts);
}

private function nsCallback(event:NetStatusEvent)
{
    switch(event.info.code)
    {
        case "NetStream.Play.Transition":
        {
            trace("Current time (on Transition): " + 
                  ns.time, "Buffer: " + ns.bufferLength);
            var estTime:Number = ns.time + ns.bufferLength;
            trace("Estimated Completion Time: " + estTime);
            break;
        }
    }
}

Source: (StackOverflow)

See trace() of Flash when running in browser

Whats an easy way to see the trace() of Flash/Flex movies when running in any browser?


Source: (StackOverflow)

How can I get an instance's "memory location" in ActionScript?

FlexBuilder's debugger will show you the "memory location" (or, I can only assume, something roughly analagous) of any in-scope instance:

debugger memory location

But I'd like to get this information in code (sort of like Python's id function), so I could very easily trace how objects move through out the system. For example, I might have:

trace("Returning", id(foo));

Then somewhere else I could use:

trace("Using", id(foo));

To make sure both bits of code are dealing with the same instance.

Now, I know that many AS classes implement the IUID interface... But there are also a bunch of classes which don't (plain old arrays and objects, for example), so that wouldn't solve my problem.

I realize that I could also wrap objects in an ObjectProxy, but that would be less than ideal as well.


Source: (StackOverflow)

How to detect when a youtube video finishes playing?

I am working on a site that has a ton of embedded youtube videos, the client wants to show a popup whenever a video stops splaying.

I looked at the youtube api and there seems to be a way to detect when a video ends:

http://code.google.com/apis/youtube/js_api_reference.html

but I can't embed the videos like they mentioned on that page since the videos are all already on the site (thousands that have been added manually by pasting embed code).

Is there a way to detect the ending of these videos without changing any of the existing videos (using javascript)?


Source: (StackOverflow)