Compiler errors with Actionscript Timer - actionscript

I have a couple timers in a Flash application I'm building. They worked fine initially, but after building the application and adding more code to it, I'm suddenly getting these weird compiler errors. When I try to compile, I get 'error 1136: Incorrect number of arguments. Expected 0.' on the line of the Timer declaration, which looks like this:
var newTimer:Timer = new Timer(5000, 1);
I've tried declaring without arguments and adding them to the according properties like this:
var newTimer:Timer = new Timer();
newTimer.delay = 5000;
newTimer.repeatCount = 1;
When I do this I get 'error 1120: Access of undefined property newTimer.' on both of the delay and repeatCount lines. Any ideas as to what the problem could be?

Timer accepts two arguments so that "expecting 0" error is suspicious. Are you by chance exporting another MovieClip or object with a class name of "Timer"?

var newTimer:Timer = new Timer(5000, 1);

Related

Can't get media image URL from Umbraco after upgrade

I have recently upgraded to 7.6.3 and I am having an issue retrieving media image URLs in my views. For testing purpposes, I added a new MediaPicker2 property for one of the nodes, set up a value for it and tried to get its value in my razor view:
var icon2 = Model.Content.GetProperty("icon2");
The object then looks like this:
Executing Model.Content.GetPropertyValue("icon2") throws the following error:
An exception of type 'System.Exception' occurred in Umbraco.Core.dll but was not handled in user code
Additional information: Exception while creating a value.
InnerException: "Object reference not set to an instance of an object."
Model.Content.GetPropertyValue<IPublishedContent>("icon2") throws the same error.
What am I doing wrong?
According to this answer, what you're doing is correct. However, I'm not sure why it's not working.
However, I have answered a similar question to this before, and I found a roundabout way of getting the node for a Udi:
You can get an IPublishedContent from your image string using this code:
// Your string.
var imageString = Model.Content.GetPropertyValue<string>("icon2");
// Get the guid from this string.
var imageGuidUdi = GuidUdi.Parse(imageString);
// Get the ID of the node!
var imageNodeId = ApplicationContext.Current.Services.EntityService.GetIdForKey(guidUdi.Guid, (UmbracoObjectTypes)Enum.Parse(typeof(UmbracoObjectTypes), guidUdi.EntityType, true));
// Finally, get the node.
var imageNode = Umbraco.TypedMedia(imageNodeId.Result);

Is Map attribute in DefaultLinkGenerator link() method thread safe?

We built an Grails (2.3.7) application where we are overriding the link(Map attr, String encoding = 'UTF-8') in DefaultLinkGenerator class. The reason we are doing this is to have the same URL throughout our application as it was business requirement from the customer. Basically in the overriding link() method, we are modifying the Map with new request parameters.
Now in Production we are seeing the following exception which occurs sporadically and we haven't been able to reproduce it locally.
2014-09-29 01:04:06,257 StackTrace ERROR Full Stack Trace:
java.lang.ArrayIndexOutOfBoundsException: 3
at org.codehaus.groovy.grails.web.mapping.UrlCreatorCache$ReverseMappingKey.<init>(UrlCreatorCache.java:196)
at org.codehaus.groovy.grails.web.mapping.UrlCreatorCache.createKey(UrlCreatorCache.java:62)
at org.codehaus.groovy.grails.web.mapping.DefaultUrlMappingsHolder.getReverseMappingNoDefault(DefaultUrlMappingsHolder.java:265)
at org.codehaus.groovy.grails.web.mapping.DefaultUrlMappingsHolder.getReverseMappingNoDefault(DefaultUrlMappingsHolder.java:257)
at org.codehaus.groovy.grails.web.mapping.DefaultLinkGenerator.link(DefaultLinkGenerator.groovy:213)
at gov.texas.multitenant.core.mapping.MultitenantLinkGenerator.super$2$link(MultitenantLinkGenerator.groovy)
The code in 'UrlCreatorCache$ReverseMappingKey' that throws the above ArrayIndexOutOfException can happen only when Map attribute (params) gets mutated during the loop. The excerpt of that code is below.
paramKeys = new String[params.size()];
paramValues = new String[params.size()];
int i = 0;
for (Map.Entry entry : params.entrySet()) {
**paramKeys[i] = String.valueOf(entry.getKey());** //throws exception here
String value = null;
if (entry.getValue() instanceof CharSequence) {
value = String.valueOf(entry.getValue());
}
...
paramValues[i] = value;
i++;
}
Now my question is, does this Map attribute THREAD SAFE? Can it get mutated between threads since we are modifying it?
Any feedback will be great appreciated. Thanks in advance.
You wouldn't know inside that method - anything implementing the Map interface is allowable. But that's not important - you're causing the problem (by being one of two concurrent editors of an apparently non-threadsafe instance) and can easily fix it.
Instead of modifying the map, create a new one (any Map implementation will do since only your code and the code in that method can access it) and modify that, and pass that in for link generation. Then throw it away and use the real map for further calculations. Something like
def attrs = ... // the 'real' map
def copy = [:] + attrs
copy.foo = 42
copy.bar = 'a very high one indeed'
String link = linkGenerator.link(copy)
//
...
def foo = attrs.foo // not available, set in copy, but no longer using that
...

How to verify Alert contents using UIAutomation with tuneup.js

I just started trying UIAutomation with tuneup.js. But I am unable to verify the Alert contents using following script.
test("Login Screen: Test Alert", function(target, app)
{
UIATarget.onAlert = function onAlert(alert)
{
var alert_title=alert.name();
assertEquals("Test", alert_title);
alert.cancelButton().tap();
}
}
);
The above code returns result as PASS even though expected result “Test” does not match the actual result (“Check Password”). The alert.cancelButton().tap(); will work.
Can anyone help me on this issue? Thanks in advance.
Your syntax is wrong is all!
UIATarget.onAlert = function onAlert(alert){}
Should be:
UIATarget.onAlert = function (alert){}
UIATarget.onAlert is a callback that is executed asynchronously with the rest of the test code. Any exception that gets raised from assertEquals will not be caught by the test code.
You should probably work around this by setting a global variable from within the alert handler, and checking that variable from your test code.

Using dart:web_audio

I have some confusion debugging some simple app that uses the Web Audio API.
In the developer console I can do something like this:
var ctx = new webkitAudioContext(),
osc = ctx.createOscillator();
osc.connect(ctx.destination);
osc.start(0);
Trying to get this to work with Dart yields the following errors when I try it like this:
AudioContext ctx = new AudioContext();
OscillatorNode osc = ctx.createOscillator();
osc.connect(ctx.destination);
osc.start(0);
//Dart2JS: Uncaught TypeError: Object #<OscillatorNode> has no method 'connect$1'
//DartVM: Class 'OscillatorNode' has no instance method 'connect' with matching
arguments. NoSuchMethodError: incorrect number of arguments passed to method
named connect' Receiver: Instance of 'OscillatorNode'
Stepping through I found that there are two kinds of implementations to the connect method. So I tried to add an extra second param and since I can not really wrap my head around why it needs an int named "output", thinking maybe it is for volume I decided on the value 1 but that yields:
//Dart2JS: Uncaught Error: IndexSizeError: DOM Exception 1 flexsynth.html_bootstrap.dart.js:8698 $.main flexsynth.html_bootstrap.dart.js:8698 $$._IsolateContext.eval$1flexsynth.html_bootstrap.dart.js:565 $.startRootIsolate flexsynth.html_bootstrap.dart.js:7181 (anonymous function)
//DartVM: "Dart_IntegerToInt64 expects argument 'integer' to be non-null."
Here is where I can't figure out what to do, I think the argument is not null, it is 1.
Googling the errors only leads me to the actual Dart source code.
Is there any place that explains how to work with the dart:web_audio? What am I doing wrong?
This is because the underlying implementation seems to require the parameter input, despite it being an optional parameter. This code will work:
AudioContext ctx = new AudioContext();
OscillatorNode osc = ctx.createOscillator();
osc.connect(ctx.destination, 0, 0);
osc.start(0);
This is a known bug, you can star it here: https://code.google.com/p/dart/issues/detail?id=6728

Syntax Error in ActionScript function

it seems there is an error in the code below, but where?
function cloneLoader(source:Loader):Loader
{
var clone:Loader = new Loader();
clone.loadBytes(source.contentLoaderInfo.bytes);
return clone;
};
clone.loadBytes is an asynchronous call. So you probably can't use the returned object right away.
Maybe try return Loader(ObjectUtil.clone(source));
There is no error in the code as such, nothing wrong with the syntax, it will work fine if source is a Loader.
What error message do you get?

Resources