FLEX: Target of assignment must be a reference value - apache-flex

how can I fix this error ?
Target of assignment must be a reference value
for (var z:int=0; z<this.tags.getItemAt(i).yearPopularity.length; z++) {
summedPopularity.getItemAt(z) = summedPopularity.getItemAt(z) + tags.getItemAt(i).yearPopularity.getItemAt(z);
}
thanks

I'm not sure you can assign to the value returned by getItemAt()
try:
for (var z:int=0; z<this.tags.getItemAt(i).yearPopularity.length; z++) {
var tempItem:Object = summedPopularity.getItemAt(z) + tags.getItemAt(i).yearPopularity.getItemAt(z);
summedPopularity.setItemAt(tempItem, z);
}

This error means your trying to give a value (or a read only object) a value.
If summedPopularity.getItemAt(z) is the only thing accepting anything,try changing that to a var
var someVariable:Number =0;
for (var z:int=0; z<this.tags.getItemAt(i).yearPopularity.length; z++) {
someVariable = summedPopularity.getItemAt(z) + tags.getItemAt(i).yearPopularity.getItemAt(z);
}
I think this would work fine,
thus denoting summedPopularity.getItemAt(z) is an object type.
trace(summedPopularity.getItemAt(z)); //<<< Debug stop and inspect
Try that, aside from that, you'll have to give us more code and show us what summedPopularity is.
Hope it helps.

I've solved with summedPopularity[i] instead of summedPopularity.getItemAt(i)

Related

easy way of ensuring one element is always in front of everything else?

on a website I want to have an element take up the entire space of the screen (after an event), but I can't seem to manage to get it in front of all the other elements on my website. Do I have to set positions and z-indexes for everything or is there another way of setting the element I want in front of everything else?
Brute force.
function getMaxZ() {
var all = document.querySelectorAll('*');
var len = all.length;
var maxZ = 0;
var dv = document.defaultView;
for (var i = 0; i < len ; i++) {
var el = all[i];
var thisZ = el.currentStyle ? el.currentStyle : dv.getComputedStyle(el, null);
thisZ = thisZ.zIndex.replace(/[^\d]/,'') * 1;
if (thisZ > maxZ) maxZ = thisZ;
}
return maxZ;
}
alert(getMaxZ());
If you want this thing always on top, just set its z-index to 999 (or something higher than you know everything else is).

How to get full category path from a keyword in Tridion

Can any one help me to get full category path from a given keyword. I am giving one example as below,
Example:
Category 1----> Keyword 1 -----> Keyword 11,
say from metadata i got the value "Keyword 11", but i need whole path i.e. /Category 1/ Keyword 1/Keyword 11.
Can anyone help me how to achieve this in Template Building Block using c#.
Maybe you can try and play with one of the following:
keyword.ParentKeywords recursively to create the path you are looking for.
OrganizationalItem oi = keyword.OrganizationalItem; // to get all the organizational items
keyword.OwningRepository
Hope that helps!
Below code should help you to get the path.
bool isRecursive = false;
KeywordField kwdField = (KeywordField)metaFields["kwdField"];
Keyword curKwd = new Keyword(kwdField.Value.Id, engine.GetSession());
string kwdPath = curKwd.Title;
while (!isRecursive) {
if (curKwd.ParentKeywords.Count > 0){
foreach (Keyword kwd in curKwd.ParentKeywords) {
kwdPath = kwd.Title + "/" + kwdPath;
}
curKwd = curKwd.ParentKeywords[0];
} else {
isRecursive = true;
}
}
kwdPath = curKwd.OrganizationalItem.Title + "/" + kwdPath;

Flex 3: Using array item value as an objects name

If I have a list of items in an array that represent the names of modules:
var phaseNames:Array = new Array("directorsPrep", "checkIO", "pickupPhoto", "pickupPhoto", "syncing", "dailies", "pictureEdit", "soundEdit", "soundMix", "colorCorrection", "finishing");
and I want to go through each one of these and call a function within each instance of each module, how would I go about doing so. So far, I have the following:
private function changeStartViewDate(numDays:Number):void
{
startViewDate = rightDate(startViewDate.getMonth(), startViewDate.getDate() + numDays, startViewDate.getFullYear());
getDateInfo();
determineCalendarWeek();
var phaseNames:Array = new Array("directorsPrep", "checkIO", "pickupPhoto", "pickupPhoto", "syncing", "dailies", "pictureEdit", "soundEdit", "soundMix", "colorCorrection", "finishing");
for (var i:int = 0; i < wholeProject.length; i++)
{
wholeProject[i].moveProject(Number((1-2) * numDays));
}
for (i = 0; i < phaseNames.length; i++)
{
for (var j:int = 0; j < [phaseNames[i]].length; j++)
{
[phaseNames[i]].movePhase(Number((-1) * numDays));
}
}
}
But when I try to save it, I get the following error:
1084: Syntax Error: expecting identifier before dot.
It's telling me the error is on the following line:
[phaseNames[i]].movePhase(Number((-1) * numDays));
I tried doing something like the following, but it didn't work:
[phaseNames[i].movePhase(Number((-1) * numDays))];
The above attempt of trying to figure this out gave me the following error
1064: Invalid metadata.
Any help would be appreciated.
I am going to assume that:
Each value of your phaseNames array references an actual instance of some other class [and not the name of the class]
The instance defined in the phaseNames array is a child of the current class.
You should be able to do something like this:
var childName = phaseNames[0];
var myChild : myObjectType = this[childName];
// then call function
myChild.doStuff();
This approach is not dissimilar to what you have; I'm just doing it in more lines. I'm also adding the this keyword to access the child.
I bet if you tried this, directly, it would work:
this[phaseNames[i]].movePhase(Number((-1) * numDays));
I have to wonder why you haven't created an array of all the instances instead of an array of all the variables names that point to the instances.

Error on binding the grid with a list

List<business.clspluginsprp> objprp = new List<business.clspluginsprp>();
business.clsplugins obj = new business.clsplugins();
for (Int32 i = 0; i < k.Length; i++)
{
Int32 z = Convert.ToInt32(k.GetValue(i));
objprp.Add(obj.fnd_plugins(z));
}
GridView2.DataSource = objprp;
GridView2.DataBind();
An error arrived which is as: The best overloaded method match for 'System.Collections.Generic.List.Add(business.clspluginsprp)' has some invalid arguments while the other error is : Argument 1: cannot convert from 'System.Collections.Generic.List' to 'business.clspluginsprp'
Try changing this:
objprp.Add(obj.fnd_plugins(z));
to this:
objprp.AddRange(obj.fnd_plugins(z));
Since it seems fnd_plugins returns a list in and of itself. This will also error if fnd_plugins does not return a List generic implementation. Posting the signature of fnd_plugins will help debug this.
Thanks.
Assuming fnd_plugins returns a List of clsplugins objects, then you want to use AddRange instead of Add. AddRange lets you add multiple values in one call.

Is there a version of the removeElement function in Go for the vector package like Java has in its Vector class?

I am porting over some Java code into Google's Go language and I converting all code except I am stuck on just one part after an amazingly smooth port. My Go code looks like this and the section I am talking about is commented out:
func main() {
var puzzleHistory * vector.Vector;
puzzleHistory = vector.New(0);
var puzzle PegPuzzle;
puzzle.InitPegPuzzle(3,2);
puzzleHistory.Push(puzzle);
var copyPuzzle PegPuzzle;
var currentPuzzle PegPuzzle;
currentPuzzle = puzzleHistory.At(0).(PegPuzzle);
isDone := false;
for !isDone {
currentPuzzle = puzzleHistory.At(0).(PegPuzzle);
currentPuzzle.findAllValidMoves();
for i := 0; i < currentPuzzle.validMoves.Len(); i++ {
copyPuzzle.NewPegPuzzle(currentPuzzle.holes, currentPuzzle.movesAlreadyDone);
copyPuzzle.doMove(currentPuzzle.validMoves.At(i).(Move));
// There is no function in Go's Vector that will remove an element like Java's Vector
//puzzleHistory.removeElement(currentPuzzle);
copyPuzzle.findAllValidMoves();
if copyPuzzle.validMoves.Len() != 0 {
puzzleHistory.Push(copyPuzzle);
}
if copyPuzzle.isSolutionPuzzle() {
fmt.Printf("Puzzle Solved");
copyPuzzle.show();
isDone = true;
}
}
}
}
If there is no version available, which I believe there isn't ... does anyone know how I would go about implementing such a thing on my own?
How about Vector.Delete( i ) ?
Right now Go doesn't support generic equality operators. So you'll have to write something that iterates over the vector and removes the correct one.

Resources