Could not resolve variable (may be a dynamic member) - actionscript-3

I created variable with datatype object and created property for this object and asignt value to it.
var tileModel : Object = new Object();
tileModel.property = 10;
But I got warning in FDT Ide. Could not resolve variable (may be a dynamic member)
I have found that possibly solution might be use /*FDT_IGNORE*/ but I would rather solve it some clasic way.
Thank you for every answer

Use array notation as follows:
tileModel["property"] = 10;

To not have FDT flag this as an error, you'll need to adjust the parser to ignore it.
See screenshot:

Related

angular dynamic (json chain) variables in ctrl variable definitions

Do you know how to use dynamic/chained variables inside a controller variable definition?
I have created this plnkr to further outline what I am trying to achieve: http://plnkr.co/edit/xOjhf8b7ZIxVhc1Id3xo
In the NodeCtrl, I am trying to dynamically access a node from a json object and I can't find the correct syntax to write out the chain.
I have tried a number of combinations but haven't found the correct way yet:
//var jsonChunk = "data." + $scope.transcendType;
$scope.tabinventory = data.$scope.transcendType;
//data;
//jsonChunk;
//function() { return "data." + $scope.transcendType; };
alert($tabinventory[0].title)
//alert($scope.tabinventory.project[0].title);
Any help you could provide would be greatly appreciated.
All the best,
Ben
Have you tried logging $scope.transcendType to make sure it's properly defined in that context?
Assuming it's properly defined, try data[$scope.transcendType].

how to solve variable has no type declaration warning in flex / as3

I came across this code snippet online that helps me solve a problem with a simple way to delay a piece of as3 code.
It runs fine and does the job, but I get a warning in flashbuilder / flex that says:
variable 'delayTextVisible' has no type declaration.
here is the code snippet:
var delayTextVisible = setInterval(showText,400);
function showText():void {
textgroup.visible = true; // insert delayed code here
clearInterval(delayTextVisible); // stop setInterval repeating
}
so my question is what type do I need to assign to the variable delayTextVisible for the warning to go away? I tried :String but that didnt work.
var delayTextVisible:uint = setInterval(showText,400);
setInterval return type is uint. see a documentation: setInterval
#bitmapdata.com's answer is correct.
However, in any case and for any variable, if you don't know its specific type, or if you need to declare the variable in a way that allows you to store many different types, you can always use the * placeholder:
var delayTextVisible:* = setInterval( showText, 400 );

SSIS Custom Component: Accessing Variables during Design Time

I am trying to read a package variable during design-time. I am able to do it during run-time fairly easily:
IDTSVariables variables = null;
pipelineComponent.VariableDispenser.LockForRead("MyVariable");
pipelineComponent.VariableDispenser.GetVariables(out variables);
But during design-time, I don't have a PipelineComponent and I can't find any object that will give me a VariableDispenser.
I've looked at the IDtsVariableService class, but it appears to only provide a helper UI to facilitate the creation of new variables -- I want to read an existing variable.
Turns out I was close, it was the IDtsPipelineEnvironmentService class:
Variables vars = null;
IDtsPipelineEnvironmentService pipelineService = (IDtsPipelineEnvironmentService)serviceProvider_.GetService(typeof(IDtsPipelineEnvironmentService));
pipelineService.PipelineTaskHost.VariableDispenser.LockForRead("VARIABLE_NAME");
pipelineService.PipelineTaskHost.VariableDispenser.GetVariables(ref vars);
VARIABLE = vars[0].Value.ToString();
vars.Unlock();
Probably, the following link might help you.
Accessing Variables in SSIS code

Dynamically instantiate a typed Vector from function argument?

For a game I'm attempting to develop, I am writing a resource pool class in order to recycle objects without calling the "new" operator. I would like to be able to specify the size of the pool, and I would like it to be strongly typed.
Because of these considerations, I think that a Vector would be my best choice. However, as Vector is a final class, I can't extend it. So, I figured I'd use composition instead of inheritance, in this case.
The problem I'm seeing is this - I want to instantiate the class with two arguments: size and class type, and I'm not sure how to pass a type as an argument.
Here's what I tried:
public final class ObjPool
{
private var objects:Vector.<*>;
public function ObjPool(poolsize:uint, type:Class)
{
objects = new Vector.<type>(poolsize); // line 15
}
}
And here's the error I receive from FlashDevelop when I try to build:
\src\ObjPool.as(15): col: 18 Error: Access of undefined property type.
Does anybody know of a way to do this? It looks like the Flash compiler doesn't like to accept variable names within the Vector bracket notation. (I tried changing constructor parameter "type" to String as a test, with no results; I also tried putting a getQualifiedClassName in there, and that didn't work either. Untyping the objects var was fruitless as well.) Additionally, I'm not even sure if type "Class" is the right way to do this - does anybody know?
Thanks!
Edit: For clarification, I am calling my class like this:
var i:ObjPool = new ObjPool(5000, int);
The intention is to specify a size and a type.
Double Edit: For anyone who stumbles upon this question looking for an answer, please research Generics in the Java programming language. As of the time of this writing, they are not implemented in Actionscript 3. Good luck.
I have been trying to do this for a while now and Dominic Tancredi's post made me think that even if you can't go :
objects = new Vector.<classType>(poolsize);
You could go something like :
public final class ObjPool
{
private var objects:Vector.<*>;
public function ObjPool(poolsize:uint, type:Class)
{
var className : String = getQualifiedClassName(type);
var vectorClass : Class = Class(getDefinitionByName("Vector.<" + className + ">"));
objects = new vectorClass(poolsize);
}
}
I tried it with both int and a custom class and it seems to be working fine. Of course you would have to check if you actually gain any speed from this since objects is a Vector.<*> and flash might be making some implicit type checks that would negate the speed up you get from using a vector.
Hope this helps
This is an interesting question (+1!), mostly because I've never tried it before. It seems like from your example it is not possible, which I do find odd, probably something to do with how the compiler works. I question why you would want to do this though. The performance benefit of a Vector over an Array is mostly the result of it being typed, however you are explicitly declaring its type as undefined, which means you've lost the performance gain. So why not just use an array instead? Just food for though.
EDIT
I can confirm this is not possible, its an open bug. See here: http://bugs.adobe.com/jira/browse/ASC-3748 Sorry for the news!
Tyler.
It is good you trying to stay away from new but:
Everything I have ever read about Vector<> in actionscript says it must be strongly typed. So
this shouldn't work.
Edit: I am saying it can't be done.
Here see if this helps.
Is it possible to define a generic type Vector in Actionsctipt 3?
Shot in the dock, but try this:
var classType:Class = getDefinitionByName(type) as Class;
...
objects = new Vector.<classType>(poolsize); // line 15
drops the mic
I don't really see the point in using a Vector.<*>. Might as well go with Array.
Anyhow, I just came up with this way of dynamically create Vectors:
public function getCopy (ofVector:Object):Object
{
var copy:Object = new ofVector.constructor;
// Do whatever you like with the vector as long as you don't need to know the type
return copy;
}

Explicitly typing variables causes compiler to think an instance of a builtin type doesn't have a property, which it does

I narrowed the causes of an AS3 compiler error 1119 down to code that looks similar to this:
var test_inst:Number = 2.953;
trace(test_inst);
trace(test_inst.constructor);
I get the error "1119: Access of possibly undefined property constructor through a reference with static type Number."
Now if I omit the variable's type, I don't get that error:
var test_inst = 2.953;
trace(test_inst);
trace(test_inst.constructor);
it produces the expected output:
2.953
[class Number]
So what's the deal? I like explicitly typing variables, so is there any way to solve this error other than not providing the variable's type?
ok, this is a little hard to explain ... first of all, here is how it works:
var test_inst:Number = 2.953;
trace(test_inst);
trace((test_inst as Object).constructor);
to my understanding, this comes from the fact, that the property constructor comes from the ECMAScript-nature of ActionScript 3. It is an ECMAScript property of Object instances and is inherited through prototypes. From the strictly typed world of ActionScript 3 (which also uses a different inheritance mechanism), this property is thus not available.
greetz
back2dos
http://www.kirupa.com/forum/showpost.php?p=1951137&postcount=214
that has all the info you need :)
basically, trace(test_inst["constructor"]) will work.
Object(someobject).constructor will achieve the same thing -- and you don't have to deal with compiler issues.
Object(someinst) === someclass works as well.
dh