Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Syntax Question



What is the right way to code this?

code:
_root.MHmc[j][i].duplicateMovieClip("a", 12);
//option 1
_root.MHmc[j].a._x += 10;
//option 2
_root.MHmc[j]a._x += 10;
//option 3
_root.MHmc[j][i].a._x += 10;
//option 4
_root.MHmc[j][i]a._x += 10;



FlashKit > Flash Help > Flash ActionScript
Posted on: 08-22-2003, 05:48 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Actins:wrong Syntax=correct, Right Syntax=wrong
Has any body made a similar observation:
when I want to load a pic into mc and write

_root.loadMovie("pic.jpg","mc");

I get a little window just the size of my pic but not my stage. But when I write:

_root.mc.loadMovie("pic.jpg");

everything is fine. I have a Mac, OS9.1. Is this related to the flashplayer in mac or what?

Syntax? Why Cant I Do This Way?
Please take a look at the code below. Could someone please explain to me why I cant call a instance by its name until it has played (or that seems to be the case). Basically I cant use the statement: "_root.Intro.gotoAndPlay(1);" in the "else" statement it only allow me to identify it as "_root.gotoAndPlay(2);". Why wont the actionscript allow me to call it as an instance name? It works fine in the "if" portion of the statement...I assume because it has already begun playing. Please clarify this for me.





on (release) {
if (_root.Intro._framesloaded > 0) {
stopAllSounds ();
_root.Stop();
_root.Intro.gotoAndPlay(1);
} else {
_root.gotoAndPlay(2);
}
}


Thanks for your help

Sean

Syntax Help
I have 30 webpages named 1.htm, 2.htm etc.
I'm trying to select one at random and open in a specific frame
Can I use random to construct the URL and getURL to open ?
And if so HOW ?
I'm sure I'm doing something wrong with all the Expression checkboxes but can't work out if there's something deeper wrong in my logic.

Dot Syntax
I have a for loop in which I want to do a tell target..since it's depreciated I thought I try dot syntax.
But I can't figure it out...what I want is this:
_root."char" add i.gotoAndPlay(14)
but that doesn't work
again please help...
Thanks

Dot Syntax
where can i find an in-depth walkthrough of flash 5's dot syntax? i have no experience with javascript, and i'm still using the slashes to target levels and movieclips. sigh... please help!

Dot Syntax
can someone convert this to flash 5 syntax (not that this won't work in 5

height = getProperty ("../../body_text/" add ../../body_text:scrollTarget add "/scrolling", _height );

thanks

Need Some Help With My Syntax
Here's the question:

If I have a variable x getting a random number

ie. x = Math.random()

How do I get the value of x to show up in a loadMovie URL?

ie. mymovie.swf?x

(I want x to be the random number, instead of it interpreting it as the actual letter x)

Any suggetions would greatly appreciated. Thanx.

Bad Syntax?
I know I'm just writing this wrong. I know this because I always write actions with variables wrong. How do I write:

'_root.darts.whole_game.buggy.bug_run_' + Number( _root.darts.whole_game.whichbug) + '.stop()'


I just want to send a Stop acticton to a movie clip using the variable "whichbug"

Thanks

Frequent-C

Bad Syntax
Why does this work
_root.Explode_1.duplicateMovieClip ("Explode_2", 1);


but this doesnt
"_root.Explode_" + _root.CurrentBall + ".duplicateMovieClip ("Explode_2", 1);"

Right Syntax?
how to attach several for example _levels 1-10:

for (...)
level[+n] ...

whats the right syntax for _level+variable

Need Some Syntax Help... I Think...
ok, in this example:

getURL("javascript:functionName(variable1,variable 2,cariable3)");


I want to use a dynamic variable for "functionName" so I can change the function I am calling at runtime.

so i would assume it would look something like:

getURL("javascript:"_root.variableName"(variable1, variable2,variable3)");

but that does not work... and this is most likely a result of my not understanding JS as well as I should.,.. but could anyone shed some light ont his for me?

Raiven...

thx in advance

Help With Dot Syntax
What am I doing wrong?

//This is how you would do it without the dot syntax
for(i=1; i<=10; i++) {
target = "target" + i;
tellTarget (target) {
gotoAndPlay(2);
}
}


//This doesnt't work because there is no movie named "target", only ones named "target1","target2"...

for(i=1; i<=10; i++) {
target = "target" + i;
target.gotoAndPlay(1);
}


//This is what I'm trying do do, but I can't get it to work in the for loop
target1.gotoAndPlay(1);
target2.gotoAndPlay(1);
target3.gotoAndPlay(1);
target4.gotoAndPlay(1);
target5.gotoAndPlay(1);
target6.gotoAndPlay(1);
target7.gotoAndPlay(1);
target8.gotoAndPlay(1);
target9.gotoAndPlay(1);
target10.gotoAndPlay(1);


Please help me, Thanks

Syntax
I need some help putting a loop together.

1 function coinHit() {
2 i = 1;
3 while (i<=3) {
4 if (_root.coin+i.hitTest(_root.ball)) {
5 _root.coin+i.play();
6 }
7 i++;
8 }
9 }


I have tried every combination I can think of, to get this to work.

I have three coins. (coin1, coin2 and coin3) I want to run a hitTest on each of those three coins, by calling this single function. However, I don't know how to write lines 4 and 5 correctly.

Can anyone help?

Also, where can I find this out in future? Does anyone know whwre I can look up concatenation like this? I always get stuck on this. A mental block /

Thanks.

Dot Syntax
hi | i'm building a shell for a movie and i'm having one problem. on the main timeline i have a movie with a button. on release, that button sets a variable on the main timeline and it also jumps back to the main timeline and has the playhead go to frame 3, i.e.

on(release) {
myVariable=1;
_root.gotoAndPlay(3);
}

-- this part is working fine --

on frame 3 of the main timeline is another movie which has a condition:

if(_root.myVariable=1 {
placeholder.loadMovie("one.swf");
}

the problem is that the placeholder movie clip (which has the instance name of placeholder) isn't loading the external movie -- which is targeted correctly. i also ran a trace statement in this second movie just to make sure that _root.myVariable=1; -- and it did. does anyone have any ideas why my placeholder isn't responding to the command?

thanks, - matt.

Syntax?
Is their an on line source for flash like the java doc are for java? To help explain all the syntax?

Thanks
JOptionPane

Syntax Help
Ok,

I'm trying to preload a external swf but i cant seem to get it to preload right. Can anyone help me out with the correct syntax?

Dot Syntax Help
I made a slideshow that fades in and out. With a link back to the root time line in the last frame like so _root.nextFrame(); then it would go to the next frame in the root time line and start the next movie and it all worked well. Then I made it in to a movie called slideshow with an instance name of sh can anyone tell me what the path would be to make it work again? What I basically have is a movie inside a movie and I want it to go to the next frame on the root time line of the outside movie. Hope this makes sense.

Thanks
JOptionPane

Another Old Syntax
hi,
what is this in mx actionscript n

its the ":" that paticularly confuses me

Code:
ny = eval("../" add n add ":ymov");

thanks
mark

Syntax Help?
Could anyone tell me the syntax for 'on click' tell a movie clip to go to frame 2 (of itself) and play. (ie: so a button is clicked and another movie clips plays from frame 2)

it used to be telltarget didn't it?

thanks

IF Syntax
I want to use the IF statement to determine whether or not a movie should play and would like to know how to lay it out.

These are the factors:

If the movie is at frame 6 then play the movie
but if is at any other frame then dont play.

This will be activated by clicking on a button.

Thanks - Joe

Syntax
Could anyone give me the correct syntax here.

If you are finding the x position of an object using it's library identifier you use this
for (x=0;x<100;x++)
x=_root["identifier"+i]._x

What is it if you are using it's instance name?

x=_root.identifier[i]._x

would this be it???

Thanks

What Does The Syntax 'in' Mean?
I have a sample .fla I got from FK that I am learning how to build an mp3 from. one of the functions is this.
code:
function select(){
for(i in playlist_mc.target_mc){
if(playlist_mc.target_mc[i].songNum != songNum){
playlist_mc.target_mc[i].gotoAndStop(1);
}
else{
playlist_mc.target_mc[i].gotoAndStop(2);
}

}

}


What does the 'in' mean in the line
for(i in playlist_mc.target_mc){

There is no listing for this in Flash's reference.

Syntax Help
Is this syntax correct? I'm not sure how to interpolate the i variable in this for loop:


Code:
for (i=1; i <= 3; i++) {
pic[i]_mc._alpha = 0;
}


What I'm trying to get is simply:

pic1_mc._alpha = 0;
pic2_mc._alpha = 0;
pic3_mc._alpha = 0;

Syntax
Hi

what is the syntax to specify something like this

idClients = new array("Party22","Fox22","Elite");
//load the names from the array (as dynamic text)
for(i=0;i<11;i++)
{
idText+i.text = idClients[i]; //this bit here
}

how do u write idText+i.text so it works as if idText+i is one variable ??? It should be something with [] but I can't remember. Also is there a way to maybe load these names from single external file insted of array and how would I specify as many variables as needed in one file so when u pull it in each text field pulls right variable contents. i know how to have a txt file with single variable but not multiple variables.

Cheers

What's The Syntax?
Hi all, I have a movie with an empty MC called "container" in which I need to attach "pages" from the library. on each page I'll have 2 buttons, next and previous. Also on the first frame of each page I have this:

_root.currentpage = 1; (or 2, 3, 4 etc)

The pages are linked as page1, page2, page3 etc.

What I want to do is have the "next" button attach the next page by it's number and then go to a frame label on that page. I don't know the proper syntax but here's what I've got:

on (release) {

container.attachMovie("page" + (_root.currentpage + 1) ,"page" +(_root.currentpage + 1),1);

container.page+(_root.currentpage).gotoAndStop("pa ge");
}

Can anyone help me out?

Syntax For 'using'
I recently saw in the middle of a thread a cunning way of putting 'using' then I think, a path, and then a whole load of variables so you didn't have to rewrite the path the whole time.

Would be really useful if someone could let me know what the syntax was.

Thanks.

XML Syntax
Hi, I get an error when trying to view the following xml.

<coworker1 imageURL="Einstein.jpg" linkURL="http://iwww.org.distr.com/news_detail.asp?news_id=88183"></coworker1>

The '=' sign is not accepted. Anyone now how to rewrite the XML to get it to work.

Thanks!
/october

Syntax
I'm sure this is easy but i don't know why this isn't working. The path is correct but it keep giving me this error. It is written on an MC.

onClipEvent (enterFrame)
_root.cater.cattext._visible = false;


BUG REPORT
Scene=catering, Layer=cater, Frame=1: Line 2: '{' expected
_root.cater.cattext._visible = false;

Syntax
hi

what is the syntax to get dot+i to work ?
dot is the name of a movie clip ??? undefined at the moment?

for(i=1;i<96;i++)
{
cordX[i] = getProperty((dot+i), _x);

cheers

For.in Syntax Help.
Brain is not working properly today.
Why isnt this code working? I need to continue coding yet Iam totally stumped why this isnt working. What Iam I not seeing here ?


Quote:




onClipEvent (load) {
for (c = 1; c <= 5; c++) {
_root.mc_bm.mc0[c]._visible = 0
//_root.mc_bm.mc01._visible = 0
}
}






Quote:




onClipEvent (load) {
for (c = 1; c <= 5; c++) {
Trace( "mc0"+[c]+"._visible = 0" )
Eval(mc0[c]._visible = 0)
//mc04._visible = 0
}
}

Syntax Help
code:
this.["MC"+b].["holder"+b].loadMovie("totalmovie"+b+".swf");

this.["MC"+b]["holder"+b].loadMovie("totalmovie"+b+".swf");

this.["MC"+b+".holder"+b].loadMovie("totalmovie"+b+".swf");


Flash doesnt like any of these....

What is correct here

Syntax
hi.. i came across this fla file..

and it has this line of code in it.

/:target_bg = _level0.target_bg0;

what does "/:" mean?

and how do i find "_level0.target_bg0" in the movie without going through the entire libray list.. i tried using the movie explorer.. but i cant find "target_bg0".

any help guys?

Syntax Help.....?
Hi guys.

I have the following code, where rana,ranb,ranc and rand are all numbers. boolVal is either > or <.


Code:
if ((rana/ranb)+boolVal+(ranc/rand))
{
//do something
}
else
{

//do something else
}


The trouble is it doesn't work!! I'm sure there's a way of passing a var (boolVal) into an if statement like this, but my syntax is incorrect.

Can someone please tell me how it's done?

Syntax Help Please
I currently have

scroll_btn.onDragOut = function () {
delete this.onEnterFrame;
}

scroll_btn.onRelease = function () {
delete this.onEnterFrame;
}

I am sure they can be combined into one function but can't get the syntax to work.

Something like

scroll_btn.onRelease, onDragout = function () {
delete this.onEnterFrame;
}


Any ideas?

Help With Syntax
Hey

here is an easy one for you scripting gurus. I am loading images from a folder into an empty Movieclip.

So i have this:

this.createEmptyMovieClip("image",1);
image.loadMovie("images/fashion/f1.jpg");

what i want to do is have a variable called imageNum reference the image number i am currently calling too. Basically i just need to know the syntax for something like this:

image.loadMovie("images/fashion/f+imageNum+.jpg");

i can't seem to figure out how to place imageNum into the name of the image i want to load...hope that makes sense

any help would be much appreciated

Syntax Help
Hi Gang

Anyone see whats wrong with this?

function attach_template (path, templatename, stagename, depth, x, y) {
myLevel[path].attachMovie(templatename, [stagename], depth);
myLevel[path][stagename]._x = x;
myLevel[path][stagename]._y = y;

myLevel.nextY += myLevel[path][stagename]._height;

}

with myLevel referring to the _root

Thanks
Phil

Syntax Help
Hi, i am new to actionscript and am going through other peoples code trying to understand. Perhaps someone can help me understand this syntax.

if (viewer._alpha > 10 && fadeOut) --> I know this means if viewer._alpha is less than 10 then.... BUT what does the && mean to the fadeout?

if (viewer._alpha < 100 && fadeIn && !fadeOut) --> what does the ! sign in front of foundout do? And what is this essentially saying?

It is probably simple, but if I want to eventually start writing my own stuff then I need to know what it means and does.

Does anyone know anygood sites to teach this stuff?

Simon

If - Else If Syntax
Hi, I'm attempting to create a dynamic weather movie so only a text file has to be edited. I have the variables working in a text box but I am also trying to control the pictures (sunny, cloudy, etc.) with the variable. What I did is created a new movie symbol with 7 frames with a stop on each frame. I have a different symbol for each day.

I am trying to make a "if" statement to make it go to the frame I need based on the variable motx (Monday Text) I have a text box below the symbol using the same variable that is working. I have tried the "if" statement a couple ways and it either stops on the first "if" or passes all "ifs". I tried using "else if" and just multiple "ifs".

I would like to dao it this way but if there is a better way that could work too. I am using Flash MX

Here is where I'm at with it.

This passes all if's even though the variable is sunny

[HTML]onClipEvent (load) {
if (motx == "sunny") {
gotoAndPlay(1);
} else if (motx == "pcloudy") {
gotoAndPlay(2);
} else if (motx == "mcloudy") {
gotoAndPlay(3);
} else if (motx == "mixed") {
gotoAndPlay(4);
} else if (motx == "showers") {
gotoAndPlay(5);
} else if (motx == "windy") {
gotoAndPlay(6);
} else {
gotoAndPlay(7);
}
} [/HTML]
Thanks for the help. Chris

What's The Right Syntax For This
hi!
i want to make an empty movie clip inside inside my loader (main swf where all my movies are loaded) but cant figure out the right syntax for this. can someone help me?

here is my code:

_root.loader.createEmptyMovieClip("soundTwo_mc",_r oot.loader.getNextHighestDepth());

I think "soundTwo_mc" was not created because there was no string in the code.. so i tried this one:

_root.loader.createEmptyMovieClip(_root.loader("so undTwo_mc"),_root.loader.getNextHighestDepth());


But still not working...


is this the right reference code to make it work:

createEmptyMovieClip(name:String,depth:Number)


thanks

Syntax Help
I am attempting to dynamically write this

_root.myxml.stateItems1[2];

now this works but is viewed as a string still:
code:
eval("_root.myxml.stateItems"+_root.stateNum+"["+(i-2)+"]");


How shall I go about extracting the value from the array?

Thanks,
1M.

Syntax (help Please)
I have an externally loaded SWF in my main movie. This SWF has frame actions to set a variable equal to the frame number that you are on in its timeline.

My main movie loads in this SWF just fine. If the user navigates to a frame number in the loaded SWF, I want the main movie to "remember" where they were if they were to navigate somewhere else in the main movie and eventually return. As I have the site now, the loaded SWF reverts back to frame 1. Upon reloading that SWF, I'd like the variable to tell the SWF to load up on the frame indicated.

What is the proper way (syntax) for saying the following:

load movie 'x' into movie clip 'y' and navigate to frame 'z' (z being the var)

Hope that was clear...

[F8] Is This The Right Syntax?
Does this look right? I want to create an empty movieclip and place it at x: 220 and y: 114 , but it is not working for some reason

code:
function createimageHolder():Void{
this.createEmptyMovieClip("imageHolder", this.getNextHighestDepth(), {_x:220, _y:114});
loadMovie("Work1.swf", imageHolder);
};

[F8] Syntax Help ...
Thsi is the problem area for a rathe rlong bit of code.

Basically, I'm loading a long list of varaibles from a txt file. Then, from a pulldown menu you can choose between the "datasets" in that txt file.

For example, there are 10 sectors, each with variables for "sales" and "medianChange". So thevariables in the txt file are declared sales1, sales2, sales 3, sales 4 etc ....

So the pulldown menu will determine the dataset, "sales" or "medianChange". Thsi works just fine.

But I'm having problems adding the number to the end of the dataset value in a for loop.

I think my problem is how I'm sticking it all together ... myLoad[(datasetValue)+i]

Here's a snippet ...


Code:
newHigh = Math.max(parseInt(myLoad[(datasetValue)+i]), newHigh);


Can someone help me figure this out?

Thanks,
Layne

A Little Syntax Help Plz
hallo all

could you plz help make this work. i know it must be the syntax, but i cant figure it out:

for (var i:int =1; i<4; i++) {
var spy[i]:String = new String();
}

i want to create 3 string instances called spy1, spy2 and spy3.

thnx

As2 Syntax In As3?
If you have nested MovieClips, i thought the only way to target this by instance name was like so

var mc=this.getChildByName("parentMC")
var mc2=parentMC.getChildByName("nestedMC")

but i just read a code exmaple that was like this:

parentMC.mc2

is'nt that as2???

Help With Syntax
Hi all I am trying to create a bingo game as a learning curve to learn actionscript. I need some help please with some coding. I am generating a random number. Then making that visible on another movie clip. Then what I am hoping to do is make the numbers on the bingo cards that have instance names bingocard1, bingocard2 etc then they have on them dynamic text boxes with instance names number1 , number2 etc. Then i am trying to make any numbers that are equal to the bingonumber on the bingo cards dissapear but at the moment all the numbers dissapear. Can some one please tell me if I am going about it wrong or if my following code is wrong. There are 6 cards with 25 numbers on each.

var bingonumberlist2 = Math.ceil(Math.random()*75); // random bingo number
_root.numberlist["number"+bingonumberlist2]._visible = true; // number list
for (t = 0; t <=6 ; t++) { // code to make the number on cards dissapear
for(s = 0; s <= 25; s++) {
eval(_root["bingocard"+t]["card"+t+"number"+s]);
if (_root["bingocard"+t]["card"+t+"number"+s] == bingonumberlist2);
_root["bingocard"+t]["number"+s]._visible = false;
}
}

Help With Syntax
Hello. Can someone help me make this work in Flash 8. Its basicly just an object moving and bouncing of walls but since I need to export in Flash 8 it doesnt work properly anymore. If anyone can spot some wrong syntax Id be grateful if you could correct it for me. Thanks.

Code:
initial_paddle_dx = 0;
initial_ball_dx = 4;
initial_ball_dy = -2;
boundry_left = 50;
boundry_right = 450;
boundry_top = 50;
boundry_bottom = 450;

Code:
onClipEvent (load) {
dx = _parent.initial_ball_dx;
dy = _parent.initial_ball_dy;
left = _parent.boundry_left+_parent.boundry_width/2+_width/2;
right = _parent.boundry_right-_parent.boundry_width/2-_width/2;
top = _parent.boundry_top+_parent.boundry_width/2+_width/2;
bottom = _parent.boundry_bottom-_parent.boundry_width/2-_width/2;
}
onClipEvent (enterFrame) {
if ((_x>=right) or (_x<=left)) {
dx = -dx;
}
if (_y<=top) {
dy = -dy;
}
if (_y>=bottom) {
dy = -dy;
}
if (hitTest(_parent.paddle_main)) {
dy = -dy;
}
_x += dx;
_y += dy;
}

[for] Syntax
Hi,
I'm tring to unload a series of three _mc using a "for" cycle nested in a function called by a button.
To check the correct execution I placed a couple of "trace", wich reveal me that the first one is correctly invoked, but not the second. Probably I made a mistake caused by my inexperience, even if using the appropriate button built in Flash, to check for any errors, it shows that everything is ok.

Can anyone be so kind to have look to my code and see what is not correct, please?
Thanks in advance.

function deleteThumb(){
trace("deleteThumb called");
for(var x=3; x<=0; x--){
trace("x value = "+x);
unloadMovie("thumbnail_mc"+fixValue);
fixValue--;
}
fixValue = 0;
}

Is Syntax Right
Hi all,
could some one please tell me if the syntax of this will be right as I have a number of them going into a function that I will be calling

if(_root["bingocard"+n]["blotter"+(m+1)]._visible==true){
numberstogo-=1;
}

Need AS Syntax
In Flash, there's a Datechooser component. What AS function can I use to seperate the Date, Month, Year, of the chosen date into three seperate variables?

Copyright © 2005-08 www.BigResource.com, All rights reserved