PDA

View Full Version : having an f problem


Seanx
10-03-2006, 09:18 AM
this is really frustrating. really really frustrating.

I have this jsfl that works fine:

for(i in fl.getDocumentDOM().selection){
fl.getDocumentDOM().selection[i].actionScript = "on (press) {gotoAndStop (1);}";
}

which of course simply adds the code to the buttons that are selected when the jsfl is run.

then I have this code:

for(i in fl.getDocumentDOM().selection){
fl.getDocumentDOM().selection[i].actionScript = "on (press) {_global.ARRAY = new Sound(); _global.ARRAY.loadSound("Sound01.mp3", true);}";
}

which, no matter how many spaces I take out or put in between each segment, returns the following error when I select the button and try to run the jsfl:

missing ; before statement

Im on the verge of a nervous breakdown here.
If I only knew what the f computer wanted I could f write what it f wants.

MIXPOSURE
10-03-2006, 11:26 AM
Hi,

I'm still getting my feet wet with jsfl, but you may be having an issue with the quotes around the mp3 file. I'd try to slash the quotes or declare the var before the statement, and then use /n to format the statement so that it prints as close to "norm" as possible.
e.g.
var myMp3 = "Sound01.mp3";
'on (press) {_global.ARRAY = new Sound(); \n' + '_global.ARRAY.loadSound(myMp3, true);}';

I may be way off but that's what my newb noggin would try for the f of it.

jjbilly
10-03-2006, 11:26 AM
Looks like you've nested quotes but used the same one twice - either use \" to escape the inner ones, or use ' for the outer ones.

Seanx
10-03-2006, 09:57 PM
thank you both so much - now that I know I have to use ' if I have " inside the code I want pasted, I have one more question -

what is the general rule regarding spaces between AS code segments - I ask because I can't just take a code out of the IDE AS window and paste it into a new jsfl between the quotes for a new type of code-pasting jsfl - I've had the most success, in the IDE, taking out all the paragraph returns - and sometimes spaces here and there, but I haven't hit on an ironclad rule yet

also, because of having to take out all the paragraph returns and some spaces, the code that gets pasted on my buttons is all in one long line, which is irritating. I'd prefer having it the way it looked in the AS window before I took out all the stuff jsfl seems not to like

is there some way to annotate an AS paragraph return when making these code-pasting jsfls?

thanks again for the '/" help - a huge lifesaver!

MIXPOSURE
10-04-2006, 04:06 AM
Well, my answer to most of that is "You got me!".
I've been having pretty good luck just formatting as normal in AS first.


this.play();
this._visible=true;
this._alpha=true;

...then add newline marker and wrap each line in quotes. (My method is to start by first adding singlequotes at beginning of each line and then copy * \n'* (w/o asterisks) to clipboard and paste at end of each line (except last)

'this.play(); \n'
'this._visible=true; \n'
'this._alpha=true;'

..Now to add to your jsfl statement just copy paste each line and use a + between them.

actionScript = 'this.play(); \n' + 'this._visible=true; \n' + 'this._alpha=true;';

..or see if it would choke on this for easier-to-read formatting:

actionScript =
'this.play(); \n' +
'this._visible=true; \n' +
'this._alpha=true;';

Seanx
10-04-2006, 04:44 AM
wow - that's exactly the kind of answer I like - thanks so much - I'll try that and let you know how it works out!

mooska
10-07-2006, 10:43 AM
Besides newline sign theres also \t witch is tab, very usefull.
soon(press){
trace("hello");
}
will look like this
actionscript = 'on(press){\n\ttrace("hello");\n}';

Seanx
10-07-2006, 06:31 PM
thanks to both of you - mooska that tab thing is great