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:
"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
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",
var onLastDown:MovieClip=null;
s.addEventListener(ProgressEvent.SOCKET_DATA, onDATA);
function onDATA(e:ProgressEvent):void{
var d:String=s.readUTFBytes(s.bytesAvailable);
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]);

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.addEventListener(MouseEvent.DOUBLE_CLICK, onDC);


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

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved