homepage Welcome to WebmasterWorld Guest from 54.161.214.221
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Flash and Shockwave
Forum Library, Charter, Moderator: open

Flash and Shockwave Forum

    
Similar Variable Names
movieclip1, movieclip2, movieclip3
MartinWeb




msg:4067823
 3:19 am on Jan 26, 2010 (gmt 0)

Hello. Does anyone know how to have flash Action Script check for movieclips with similar names? Here is an example:


if(movieclip1._y==theothervariable){
}
if(movieclip2._y==theothervariable){
}

But condensed similar to an array?:

var checking = 1;
while (checking<3){
if(movieclip[checking]==theothervariable){//This is the part that I am not sure on.
//The other code
}
checking++;
}

Any help would be greatly appreciated!

 

rocknbil




msg:4068359
 7:59 pm on Jan 26, 2010 (gmt 0)

Regular expressions is available in AS, but I wouldn't use that approach. I'd **probably** (depending on context) lay down a reliable method of naming, and follow it. For example, let's say, using XHTML, you import a video playlist. The .flv's can be any name, at any time, but when you import them you put all references into an array, something like

(standard Flash CML import/parse, then as you look through the XML nodes)
images[k]=image;
captions[k]=cap;

Which assigns them an index in the array.

So now when you create movie symbol names,

for (i=0;i<images.length;i++) {
moviename= 'moviename'+i;
}

And you'd access and parse the movie symbols the same way.

MartinWeb




msg:4068631
 1:08 am on Jan 27, 2010 (gmt 0)

So now that I have the moviename variable: "moviename1",how can I put it into my script? For example, how can I find the _x axle of it? Thank you!

rocknbil




msg:4068700
 3:28 am on Jan 27, 2010 (gmt 0)

for (i=0;i<images.length;i++) {
moviename= 'moviename'+i;
trace(eval('_root.'+moviename+'._x'));
}

Would be my first guess. Honestly, off the top, don't know, I'd have to get in and play with it.

I use eval there because I've had some come-and go problems with dynamically named movie symbols, the specifics are sadly absent, also due to having too much stuff crammed in my head. :-\

MartinWeb




msg:4068719
 4:28 am on Jan 27, 2010 (gmt 0)

Great, thanks!

MartinWeb




msg:4069522
 2:42 am on Jan 28, 2010 (gmt 0)

How can I make it so that that movieclip will go forward a frame?


eval('_root.'+moviename+'.nextFrame()');

That doesn't work: Do you know what would? Thank you!

rocknbil




msg:4069584
 5:16 am on Jan 28, 2010 (gmt 0)

I think you want something like goToAndPlay() or goToAndStop().

eval('_root.'+moviename+'.goToAndPlay(5)');

Should start on frame 5.

MartinWeb




msg:4070111
 11:22 pm on Jan 28, 2010 (gmt 0)

Hmmm.... that doesn't seem to work.

rocknbil




msg:4070650
 6:22 pm on Jan 29, 2010 (gmt 0)

As said, I'd have to play with it, not sure if I'm helping or diverting . . .

Tray eval only on the name, like

var obj = eval('_root.'+moviename);
obj.goToAndPlay(1);

MartinWeb




msg:4070855
 3:13 am on Jan 30, 2010 (gmt 0)

SetProperty seems to be working

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Flash and Shockwave
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved