FORUMS: list search recent posts

readUTF with if then statements

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
matt watts
readUTF with if then statements
on Nov 14, 2009 at 12:31:51 am

if then statements confusion
I am reading information from binary sockets.

I have an array of movie clips, each with a different instance name:
ex: MCarray:Array=new Array (mc1,mc2,mc3,mc4,mc5);
I have already done all the coding for the arrays so theres no confusion there.

I need a statement that says:
Code:
"if the incoming variable refers to mc1+2, then make mc1 go to frame 2"
"if the incoming variable refers to mc2+2, then make mc2 go to frame 2"
if the incoming variable referrs to mc3+2, then make mc3 go to frame 2"
and so on....

does that make sense? anyway the problem with that is that i just want ONE statement because I will eventually have over a hundered movie clips, and so I don't want to make a hundred if-then statements for each function.

there must be a way to say
Code:
my.addEventListener(ProgressEvent.SOCKET_DATA, myfunction);
function myfunction(e:ProgressEvent):void{
if("incoming variable=one of the movie clips from the array"+"2"){
MCarray.(make that movie clip which was named go to frame 2);
}
}
any ideas? thanks

one idea i was given was this, but it doesnt entirely work so if anyone has anyideas that could fix it? var ONarray:Array=new Array("on1","on2","on3","on4","on5",
"on6","on7","on8","on9","on9",
"on10","on11","on12","on13",
"on14","on15","on16","on17",
"on18","on19","on20","on21","on22",
"on23","on24","on25","on26","on27",
"on28","on29","on30","on31","on32");
var onLastDown:MovieClip=null;
s.addEventListener(ProgressEvent.SOCKET_DATA, onDATA);
function onDATA(e:ProgressEvent):void{
var d:String=s.readUTFBytes(s.bytesAvailable);
trace(d);
var embeddedNums:Array = d.match(/\d+/g);
var clipIndex:int = Number(embeddedNums[0]) -1; //because arrays start at 0.
var frameIndex:int = Number(embeddedNums[1]);
this[ONarray[clipIndex]].goToAndStop(frameIndex);
}

for (var i:uint; i < ONarray.length; i++) {
var ON:MovieClip=getChildByName(ONarray[i]) as MovieClip;
ON.buttonMode = true;
ON.addEventListener(MouseEvent.MOUSE_DOWN, onPRESS);
ON.addEventListener(MouseEvent.MOUSE_UP, onRELEASE);
ON.doubleClickEnabled=true;
ON.addEventListener(MouseEvent.DOUBLE_CLICK, onDC);
ON.stop();
var clipName:String=ON.name;

}

and this is the error i get form that when i try to input "on1+2":o
n1+2
TypeError: Error #1006: goToAndStop is not a function.
at D3264NEW_fla::MainTimeline/onDATA()


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]