It is INCREDIBLE how all of us have being spoiled into stateful programming, I have had the hardest time trying to think stateless. So i have take baby steps.
This next Flex program is very simple, but it exemplifies some of Flex's main features.
So here it is:
creationComplete="creationCompleteHandler();"
>
private function creationCompleteHandler():void
{
userRequest.send();
}
]]>
[Bindable]
var jailh:Array =new Array;
]]>
public function addToarray(Mymine:String):void{
var match:String = Mymine;
var isChecked:int = 0 ;
for (var i:int = 0; i < jailh.length; i++)
{
if (jailh[i] == match) {
dwindow.text="";
if (jailh.length == 1)
{
dwindow.text +="\n Will shift array"+ '\n'
jailh.shift();}
else
{
dwindow.text +="\n splice:\t"+i+','+(i+1)+'\n'
jailh.splice(i,i+1);
}
isChecked=1;
dwindow.text +="Deleted"+ '\n'
dwindow.text +="Current Length! " +String(jailh.length)+ '\n' ;
myarray.text=jailh.join("\n");
break;
}
}
if (isChecked==0){
jailh.push(Mymine);
dwindow.text="Current Length " +String(jailh.length);
myarray.text=jailh.join("\n");
}
}
]]>
Basically this is a series of checkboxes that are pulled from an XML using an HTTPService call, then when checked they are added to an array... if the are checked again they are looked up for a match in the array, if there is a match the values are deleted.
Hopefully this will help someone, I know that if I had found such an example It would have saved me hours!
Thanks!
Alejandro
No comments:
Post a Comment