Copy link to clipboard
Copied
Hey to anyone , lets say i have a for() loop that creates an instance of a movieClip newText, which contains textfields inside that get pushed through an Array, and are displayed again by the array when my app is reinitiated.
and in newText i also have a button inside that deletes the information(options), and when that button is pressed another MC(delete) pops up over newText.
What is my best approach to check if this button has been pressed? should i create another Array that passes "true" to the Array, and check if ( arrayCheck["???"] == true) { what do i do here};...etc i'm lost.
because i want to make MC(delete) visibility = true; when the app is reinitiated for the instances of newText, when (options) button has been clicked; any ideas would be highly appreciated????
BELOW IS MY FOR LOOP I HAVE ALREADY
________________________________________________________________________________________________________________________________________________________________________________
var kellog: Number = -5;
//this variable sets in Array index at 1
var general: Number = -1;
for (var i: Number = 0; i < mySaveNewT.data.myNText; ++i) {
newText = new tbox();
newText.x = -220;
newText.y = -513 + i * 69 + 0 * 3.8;
kellog += 6; // this places each array index at the correct textfield in newText
kellogs += 6; // this places each array index at the correct textfield in newText
trace(kellogs, " total cereal");
newText.CN.text = String(unwrap.mySaveData.data.myDataArray[kellog]);
newText.DF.text = String(unwrap.mySaveData.data.myDataArray[2 + kellog + general]);
newText.Ad.text = String(unwrap.mySaveData.data.myDataArray[3 + kellog + general]);
newText.PN.text = String(unwrap.mySaveData.data.myDataArray[4 + kellog + general]);
newText.tap.text = String(unwrap.mySaveData.data.mynText[kellogs]);
newText.tip.text = String(unwrap.mySaveData.data.mynText[kellogs + generals]);
newText.OT.text = String(unwrap.mySaveData.data.myDataArray[5 + kellog + general]);
VWD.addChild(newText);
myDataArrayInProgram = unwrap.mySaveData.data.myDataArray;
myNTextAddition = unwrap.mySaveData.data.mynText;
}
then why are you assigning it to i?
again, use the code i suggested but change btn to options (if that's really your buttons name).
var so:SharedObject=SharedObject.getLocal("kellogs","/");
if(so.data.btnClickA && so.data.btnClickA.length>0){
for(var i:int=0;i<so.data.btnClickA.length;i++){
trace('button',so.data.btnClickA,'was clicked')
}
} else {
so.data.btnClickA=[];
}
for (var i: Number = 0; i < mySaveNewT.data.myNText; ++i) {
newText = new tbox();
newText.x = -220;
newText.options.addEventListener
...Copy link to clipboard
Copied
your button should have an instance name. assign listeners to each one in your for-loop.
eg, if tbox extends a MovieClip and your button is btn:
for (var i: Number = 0; i < mySaveNewT.data.myNText; ++i) {
newText = new tbox();
newText.x = -220;
newText.btn.addEventListener(MouseEvent.CLICK,buttonF);
.
.
}
function buttonF(e:MouseEvent):void{
trace(MovieClip(e.currentTarget.parent).CN.text);
}
Copy link to clipboard
Copied
this works in short, but i run into the problem, that when i kill my app, the MC(delete) isnt there
i.e, if "i" = 3, and there is 3 newText on stage, and btn is pressed on the 2nd newText on stage. when i kill my app how can i reinitiate MC(delete)
thx kglad!!!
Copy link to clipboard
Copied
what do you mean by 'kill my app'?
and what do you want to happen when the button in the 2nd tbox is clicked?
Copy link to clipboard
Copied
im using flash, and after i test movie when i exit. thats what i mean by kill app,
im trying to listen for the btn being clicked, and when that happens to store that click in maybe an Array, so when i reinitiate my app that MC(delete) is over the 2nd tbox (or any tbox btn that has been clicked) hope what im saying is making sense.
so if 2nd, 6th,10th,or 20th btn in tbox is clicked, i want to have that info stored to be reinitiated possibly through an array.
thank you
Copy link to clipboard
Copied
to save data to be used when you next open your flash app, use the sharedobject.
var so:SharedObject=SharedObject.getLocal("kellogs","/");
if(so.data.btnClickA && so.data.btnClickA.length>0){
for(var i:int=0;i<so.data.btnClickA.length;i++){
trace('button',so.data.btnClickA,'was clicked')
}
} else {
so.data.btnClickA=[];
}
for (var i: Number = 0; i < mySaveNewT.data.myNText; ++i) {
newText = new tbox();
newText.x = -220;
newText.btn.addEventListener(MouseEvent.CLICK,buttonF);
newText.ivar=i;
.
.
}
function buttonF(e:MouseEvent):void{
var i:int=MovieClip(e.currentTarget.parent).ivar;
if(so.data.btnClickA.indexOf(i)==-1){
so.data.btnClickA.push(i);
}
}
Copy link to clipboard
Copied
thx im going to try this out now
Copy link to clipboard
Copied
you're welcome.
(p.s when using the adobe forums, please mark helpful/correct responses, if there are any.)
Copy link to clipboard
Copied
im getting this error
Column 6 | 1083: Syntax error: else is unexpected. |
if(so.data.btnClickA && so.data.btnClickA.length>0){
for(var i:int=0;i<so.data.btnClickA.length;i++){
trace('button',so.data.btnClickA,'was clicked')
}
} else {
so.data.btnClickA=[];
}
Copy link to clipboard
Copied
then you misplaced that code within some other brackets.
copy and paste the code from message 5. just add whatever you need in place is of the ellipses in the for-loop.
Copy link to clipboard
Copied
one last thing thats popping up is
1067: Implicit coercion of a value of type Number to an unrelated type opt. |
newText.options = i;
for (var i: Number = 0; i < mySaveNewT.data.myNText; ++i) {
newText = new tbox();
newText.x = -220;
newText.btn.addEventListener(MouseEvent.CLICK,buttonF);
newText.ivar=i;
.
.
}
function buttonF(e:MouseEvent):void{
var i:int=MovieClip(e.currentTarget.parent).ivar;
if(so.data.btnClickA.indexOf(i)==-1){
so.data.btnClickA.push(i);
}
}
Copy link to clipboard
Copied
what's
newText.options = i;
Copy link to clipboard
Copied
its the btn
Copy link to clipboard
Copied
then why are you assigning it to i?
again, use the code i suggested but change btn to options (if that's really your buttons name).
var so:SharedObject=SharedObject.getLocal("kellogs","/");
if(so.data.btnClickA && so.data.btnClickA.length>0){
for(var i:int=0;i<so.data.btnClickA.length;i++){
trace('button',so.data.btnClickA,'was clicked')
}
} else {
so.data.btnClickA=[];
}
for (var i: Number = 0; i < mySaveNewT.data.myNText; ++i) {
newText = new tbox();
newText.x = -220;
newText.options.addEventListener(MouseEvent.CLICK,buttonF);
newText.ivar=i;
.
}
function buttonF(e:MouseEvent):void{
var i:int=MovieClip(e.currentTarget.parent).ivar;
if(so.data.btnClickA.indexOf(i)==-1){
so.data.btnClickA.push(i);
}
}
Copy link to clipboard
Copied
Ok i understand, but when left newText.ivar.
i get this error
,Line 416, Column 13 | 1119: Access of possibly undefined property ivar through a reference with static type tbox. |
I'm sorry for all these questions, but this is the last thing left for me to do, and its driving me crazy. thx!!!!!!
Copy link to clipboard
Copied
i assume tbox extends MovieClip, correct? if so, change that line to:
MovieClip(newText).ivar=i;
Copy link to clipboard
Copied
Thx for all your help. it didnt work for me but you led me in the right direction. I should be able to figure it out now
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now