-
Designer, Programmer, Musician
Edit an especific string into a dynamic textbox
Hello guys! Long time.
I'm creating this "Phone Contacts Numbers Saving Tool" for people who constantly losing their phone contacts numbers. I achieved making 2 dynamic textboxes "Name" "Number" so you put your name and number, then a button to "Create Contact". Then that info is saved into 2 dynamic textboxes columns, one is for Names and the other for Numbers. This is the script:
Code:
var saveState2:SharedObject = SharedObject.getLocal("cookie2");
if(saveState2.data.Names==undefined && saveState2.data.Numbers==undefined ){
}
else {
Names.text =saveState2.data.Names;
Numbers.text = saveState2.data.Numbers;
}
btn.onPress=function(){
Names.text += name1.text
Numbers.text += number1.text
saveState2.data.Names=Names.text;
saveState2.data.Numbers=Numbers.text;
}
btn2.onPress=function(){
saveState2.clear();
Numbers.text=""
Names.text=""
}
stop();
I want to be able to "edit" or "delete" an specific contact/number from the list. Every time you click the "create contact button" it adds the name and the number with
Code:
Names.text += name1.text
Numbers.text += number1.text
Ideas? Thanks
Last edited by angelhdz; 09-11-2012 at 10:47 PM.
Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries
-
Designer, Programmer, Musician
The numbers and names are automatically saved into a Shared Object, so, everytime you open the flash, it shows all your contact numbers and names. But now i need to be able to edit these numbers/names, or/and delete them.
Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries
-
.
Hi,
This might put you in the right direction.
Code:
var Named = [];
var Numbered = [];
var saveState2:SharedObject = SharedObject.getLocal("cookie2");
if (saveState2.data.Names == undefined && saveState2.data.Numbers == undefined)
{
Names.text = "";
Numbers.text = "";
}
else
{
Names.text = saveState2.data.Names;
Numbers.text = saveState2.data.Numbers;
}
btn.onPress = function()
{
RememberStuff(name1.text,number1.text);// input text boxes
};
btn2.onPress = function()
{
saveState2.clear();
Names.text = "";
Numbers.text = "";
Named = [];
Numbered = [];
};
function RememberStuff(A, B)
{
Named.push(A);
Names.text = Named;
Numbered.push(B);
Numbers.text = Numbered;
saveState2.data.Names = Names.text;
saveState2.data.Numbers = Numbers.text;
}
good luck as i'm away for a couple of days
-
Designer, Programmer, Musician
Thanks fruitbeard, and have a great vacation/travel/whatever you going to be away for/ hehehe
Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries
-
.
Hi,
Here you go angel, you will need to mess around with it to do everything you need it to do, but try this.
Attachment 73797
its CS6 i think you use it,
you might need to clear the saved data first, but you can use the button inside it
and the code inside is
Code:
var Named = [];
var Numbered = [];
name1.restrict = "A-Za-z. ";
number1.restrict = "0-9-. ";
var saveState2:SharedObject = SharedObject.getLocal("cookie2");
if (saveState2.data.Names == undefined && saveState2.data.Numbers == undefined)
{
Names.text = "";
Numbers.text = "";
}
else
{
Named = saveState2.data.Names;
Numbered = saveState2.data.Numbers;
Names.text = Named;
Numbers.text = Numbered;
MakeColumns();
}
btn.onPress = function()
{
if (name1.text == "")
{
//do nothing
}
if (number1.text == "")
{
//do nothing
}
else
{
RememberStuff(name1.text,number1.text);// input text boxes
name1.text = "";
number1.text = "";
}
};
btn1.onPress = function()
{
name1.text = "";
number1.text = "";
};
btn2.onPress = function()
{
saveState2.clear();
Names.text = "";
Numbers.text = "";
Named = [];
Numbered = [];
};
function RememberStuff(A, B)
{
Named.push(A);
Numbered.push(B);
saveState2.data.Names = Named;
saveState2.data.Numbers = Numbered;
MakeColumns();
}
function MakeColumns()
{
Named = saveState2.data.Names;
Numbered = saveState2.data.Numbers;
Names.text = Named;
Numbers.text = Numbered;
var ListA = Names.text;
var SearchA = ",";
var ReplaceA = "\n";
NewListA = ListA.split(SearchA);
if (NewListA.length > 0)
{
Names.text = NewListA.join(ReplaceA);
}
var ListB = Numbers.text;
var SearchB = ",";
var ReplaceB = "\n";
NewListB = ListB.split(SearchB);
if (NewListB.length > 0)
{
Numbers.text = NewListB.join(ReplaceB);
}
}
-
.
Hi.
Here it is again with remove name and number details function()
Attachment 73799
-
.
Hi,
Yet another revised edition with replace and remove functions.
you can ignore the first 2 if you so wish.
Attachment 73801
-
Designer, Programmer, Musician
Wow fruitbeard thats great!
But now i have this mental issue. If user wants to delete a "contact", they would have to count the line of that contact in order to delete it. Suppose the contact is Richard, but theres a lot of contacts with A, B, C, D, etc, the user will have to count one, two, three, twenty, twenty one hehe.
So, i'm thinking in a way of creating the Names and the number dynamic textboxes "dynamically", so each contact is loaded in it's own textbox or an empty movieclip, and theres a "X" button to delete the desired contact. E.g if i want to delete "Richard" i simply scroll down a main scrollpane with all the generated dynamic texboxes or movieclips, and besides "Richard's" name or number, theres an "X" button, I press it and that dynamic texbox or that movieclip get removed.
Could it be possible? Thanks for the help.
Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries
-
.
Hello Angel
Here you go, not quite what you desired but it does give you line numbers to make it easier to control, plus some added functionality.
just clear the shared data first then do your business.
Attachment 73803
how do you delete attachments from your profile, it has me stumped?
-
Designer, Programmer, Musician
Thanks, that worked.
But i know you know it's much better the way I said last, if each time you press "Add details" an empty movieclip or a dynamic textbox is created one below the other forming a column, then you just "remove" that moveclip or that dynamic textbox in order to delete/remove a contact. I'm not good with creating dynaamically movieclips or textboxes and modifying it so I will have to read a lot.
By now, i will study your script to learn, and I will put the names and numbers textboxes inside a Scroll pane, so the names are aligned with the numbers always, and you only scroll down the scroll pane. good job you're the best thanks
Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries
-
.
Hi,
here is a cleaned up version of the code from the one you have, bits removed and better coded.
copy all and overwrite original, if you so wish.
Code:
var Named = [];
var Numbered = [];
var i = 0;
Name1.restrict = "A-Za-z. ";
Number1.restrict = "0-9-. ";
Names.html = true;
Numbers.html = true;
//Number1.restrict = "0-9-.\\N\\o\\n\\e ";//allows the word "None" to be written
var saveState2:SharedObject = SharedObject.getLocal("cookie2");
if (saveState2.data.Names == undefined && saveState2.data.Numbers == undefined)
{
Names.text = "";
Numbers.text = "";
HowManyLines.text = "0";
}
else
{
Named = saveState2.data.Names;
Numbered = saveState2.data.Numbers;
Names.text = Named;
Numbers.text = Numbered;
MakeColumns();
}
btn.onPress = function()
{
if (Name1.text == "")
{
//do nothing
}
if (Number1.text == "")
{
//do nothing
}
else
{
RememberStuff(Name1.text,Number1.text);
Name1.text = "";
Number1.text = "";
}
};
btn1.onPress = function()
{
Name1.text = "";
Number1.text = "";
Remove.text = "";
ReplaceName.text = "";
ReplaceNumber.text = "";
};
btn2.onPress = function()
{
saveState2.clear();
Names.text = "";
Numbers.text = "";
Name1.text = "";
Number1.text = "";
Remove.text = "";
ReplaceName.text = "";
ReplaceNumber.text = "";
HowManyLines.text = "0";
Named = [];
Numbered = [];
i = 0;
HowMany = null;
};
btn3.onPress = function()
{
if (Remove.text == "")
{
//do nothing
}
else
{
Named.splice(Remove.text - 1,1);
Numbered.splice(Remove.text - 1,1);
Remove.text = "";
MakeColumns();
}
};
btn4.onPress = function()
{
if (ReplaceName.text == "")
{
//do nothing
}
if (Name1.text == "")
{
//do nothing
}
else
{
Named[ReplaceName.text - 1] = ReplaceName.text + " - " + Name1.text;
ReplaceName.text = "";
Names.text = "";
Numbers.text = "";
MakeColumns();
}
};
btn5.onPress = function()
{
if (ReplaceNumber.text == "")
{
//do nothing
}
if (Number1.text == "")
{
//do nothing
}
else
{
Numbered[ReplaceNumber.text - 1] = ReplaceNumber.text + " - " + Number1.text;
ReplaceNumber.text = "";
Names.text = "";
Numbers.text = "";
MakeColumns();
}
};
function RememberStuff(A, B)
{
Named.push([i + 1] + " - " + A);
Numbered.push([i + 1] + " - " + B);
saveState2.data.Names = Named;
saveState2.data.Numbers = Numbered;
MakeColumns();
}
function MakeColumns()
{
HowMany = (Named.length + Numbered.length) / 2;
HowManyLines.text = HowMany;
Named = saveState2.data.Names;
Names.text = Named;
var ListA = Names.text;
var SearchA = ",";
var ReplaceA = "\n";
NewListA = ListA.split(SearchA);
Names.text = NewListA.join(ReplaceA);
Numbered = saveState2.data.Numbers;
Numbers.text = Numbered;
var ListB = Numbers.text;
var SearchB = ",";
var ReplaceB = "\n";
NewListB = ListB.split(SearchB);
Numbers.text = NewListB.join(ReplaceB);
for (i = 0; i < HowMany; i++)
{
Names.text = Names.text;
Numbers.text = Numbers.text;
}
if (HowMany > 0)
{
Remove.restrict = "1-" + HowMany;
ReplaceName.restrict = "1-" + HowMany;
ReplaceNumber.restrict = "1-" + HowMany;
}
else
{
Remove.restrict = "";
ReplaceName.restrict = "";
ReplaceNumber.restrict = "";
}
}
Last edited by fruitbeard; 09-12-2012 at 01:32 PM.
-
Designer, Programmer, Musician
About the profile attachments, let me see if i can help
Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries
-
Client Software Programmer
-
Designer, Programmer, Musician
Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries
-
.
Hi,
was wondering how you were getting on with your project thing?
Advancement
-
Client Software Programmer
yo! who me or angel
-
Designer, Programmer, Musician
Hehe, me or Basses? xD If me, well, I paused all my p rojects. My relationship ended and I'm in this hard time. I hope get better soon and continue my projects. How about yours? Basses? Fruitbeard?
Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries
-
Client Software Programmer
well im working mega slow because of school but little things are being upgraded in my mmo as you can see I got organized now :P even the servers home made and credit to nig13 for helping me with database
-
Designer, Programmer, Musician
Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries
-
Client Software Programmer
Thanks, I barely come online now I miss the yellow (if youve noticed im never on)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|