Page 1 of 2

scritping simply

PostPosted: Tue Oct 15, 2013 3:26 am
by hat973
Iv have a problem with scripting simply I have a lurning problem that really pissing me off when it comes to scripting so this form will be for scripts so if I get a script that annoyes me or you guys get a script that pisses u off post it here and see if some one can see what wrong with it post your animation and flash files to with the script you use and see if the vets can help

Re: scritping simply

PostPosted: Tue Oct 15, 2013 4:10 pm
by BlueLight
Well if your my CS teacher he will tell you that he hates scripts because they lack a compiler.

Re: scritping simply

PostPosted: Wed Oct 16, 2013 5:44 pm
by OwnerOfSuccuby
I do not know what to do if some MovieClipObject with some script in it leaves stage on the new frame. Then compiler try to use that object one mor e time but can not so he write warnings about it. The same for objects with event listeners - i do not know how to stop them when main stage goes to another frame with out them.

Re: scritping simply

PostPosted: Mon Oct 21, 2013 1:25 pm
by GoRepeat
OwnerOfSuccuby Wrote:I do not know what to do if some MovieClipObject with some script in it leaves stage on the new frame. Then compiler try to use that object one mor e time but can not so he write warnings about it. The same for objects with event listeners - i do not know how to stop them when main stage goes to another frame with out them.


Code: Select All Code
stage.removeEventListener(Event.THING, function);


Inside the movie clip:

Code: Select All Code
if(MovieClip(this.parent)!=null){
      your embedded code
}


That way if the object is removed before the frame shifts, its parent becomes null and it won't run and throw off errors.

Re: scritping simply

PostPosted: Tue Oct 22, 2013 11:13 am
by OwnerOfSuccuby
Test this code:

Code: Select All Code
this.addEventListener(Event.ENTER_FRAME,fT)

function fT(e:Event){
  if(MovieClip(this.parent)!=null){
    trace("I am in");
  }
  else {
   trace("removing");
   this.removeEventListener(Event.ENTER_FRAME,fT);
  }
}


Yes it is very good way to check and deleate dead listeners thank you for idea.

I do not know that it is possible to check it this way:
Code: Select All Code
( if(MovieClip(this.parent)!=null))

Re: scritping simply

PostPosted: Sat Aug 02, 2014 11:15 pm
by inkhryptedQuery
BlueLight Wrote:Well if your my CS teacher he will tell you that he hates scripts because they lack a compiler.


Haha : D

So .. Your CS teacher also has a grey beard I take it : ]

Re: scritping simply

PostPosted: Sun Aug 03, 2014 8:36 pm
by BlueLight
inkhryptedQuery Wrote:
BlueLight Wrote:Well if your my CS teacher he will tell you that he hates scripts because they lack a compiler.


Haha : D

So .. Your CS teacher also has a grey beard I take it : ]

Yep, and a firm hatred of Javascript.

Re: scritping simply

PostPosted: Sun Aug 03, 2014 11:02 pm
by Zeus Kabob
Wait, does he hate Bash?

Re: scritping simply

PostPosted: Mon Aug 04, 2014 1:38 am
by hat973
I'm sorry zeus but Who is Bash

Re: scritping simply

PostPosted: Mon Aug 04, 2014 3:04 am
by BlueLight
Zeus Kabob Wrote:Wait, does he hate Bash?

We only had a couple of conversations on the topic.
He didn't rant but he kinda listed off the trouble with java script that he was having. For instances it would suddenly stop working for not good reason, which related to the fact that it's very open and assumes you know what your doing at every moment. Is the var A getting keyboard here? Well what happens if you treat var A as a number and not a person? *EXPLOSION!*

Re: scritping simply

PostPosted: Mon Aug 04, 2014 8:03 pm
by inkhryptedQuery
Think Zeus was talking about BASH Scripting. Linux bash scripting.

Haha. Yeah, javascript is a wild boar you have to ride into battle.

Because .. EVERYTHING IS AN OBJECT. Functions are closures and classes.
Private and public variables are assumed.

Lots of obfuscation, but so much power and versatility.
Run your server and your client and even your database all-in-one.

Re: scritping simply

PostPosted: Mon Aug 04, 2014 8:15 pm
by BlueLight
He didn't say anything about Bash script.
He mention action script and java script.

Re: scritping simply

PostPosted: Wed Aug 06, 2014 4:20 am
by Enkidu
BlueLight Wrote:
Zeus Kabob Wrote:Wait, does he hate Bash?

We only had a couple of conversations on the topic.
He didn't rant but he kinda listed off the trouble with java script that he was having. For instances it would suddenly stop working for not good reason, which related to the fact that it's very open and assumes you know what your doing at every moment. Is the var A getting keyboard here? Well what happens if you treat var A as a number and not a person? *EXPLOSION!*


The thing with javascript is that if there is an error at any point in your code that isn't handled, it stops running everything from that point forward. So you address this by wrapping your code in a try/catch block like this:

Spoiler (click to show/hide):

Code: Select All Code
<script>
try {

//the code you want to work

}
catch(error) {

//what to do if it doesn't work the right way.

}

</script>


Also any code you wrap in try/catch will not stop execution, unless you have an error in your catch block. You can also nest them, which is useful for error logging. Usually you wrap your entire script in a try catch block to catch any other uncaught errors, then wrap individual chunks of code in their own try catch block also, so you can handle errors individually.

The biggest thing that gets people is not really knowing what is going on at any given point in time. The easiest way to deal with this is to use console.log() and console.dir() to get a feel for what is going on. console.log('message of some sort') will output to your error console, which you can show in most browsers by right clicking anything and choosing inspect element, then clicking the console tab. This is less intrusive than using alert('some message'), because it doesn't literally throw things in your face all the time. The purpose of console.dir() is to output the contents of an array or object into the console so you can tell what it is. So within an object function (anywhere in it), you can do console.dir(this) to figure out what the object is. You can also do the same thing with any other variable, array or object to figure out everything that the system knows about it, including about a billion things you didn't even know were there or that you could use. Using these techniques makes javascript a lot more friendly and removes the feel-in-the-dark part.

Re: scritping simply

PostPosted: Fri Aug 08, 2014 10:58 am
by hat973
I basicly made this for Scripting like AS2 and AS3 specking of witch dose any one have any ideas on what how i could do 3 diffrent types of story like a pick a gender kinda thing and it changes the rest of the game to fit the gender the player picks

Re: scritping simply

PostPosted: Fri Aug 08, 2014 5:27 pm
by BlueLight
So the problem with this question is that it's so general that their are goggle of possibly solutions. So how i would do it without seeing or having any code in mind is have a method/function called getStory(index) which would return the next part of the story but is able to detect if the user is male, female, or herm.
Inside of it it will have 3 arrays or well 1, 2 dimensional array. First it will figure out which array it should use and then it will plug in the index to get a string.
Your return statement should look close to but maybe not exactly like this.

return storyArray[genderNum][index];

Re: scritping simply

PostPosted: Sun Aug 10, 2014 5:38 am
by hat973
mind explaning it a bit better plz

Re: scritping simply

PostPosted: Sun Aug 10, 2014 6:06 am
by BlueLight
This would be what i'm talking about but in java not Actionscript. Oh and by the way.... Don't ask me to design a Syntax highlighter. I'd color blind the programmer.


public class foo {
boolean hasMaleParts;
boolean hasFemaleParts;
String[][] storyArray = {
{"MALE1","MALE2","MALE3","MALE4","MALE5","MALE6","MALE7","MALE8"},
{"FEMALE1","FEMALE2","FEMALE3","FEMALE4","FEMALE5","FEMALE6"},
{"FUTA1","FUTA2","FUTA3","HERM1","HERM2","HERM3"}
}

public string getStory(int index){
int genderNum= -1;

if(hasMaleParts&&hasFemaleParts){
genderNum = 2;
} else if(hasFemaleParts){
genderNum = 1;
}else if(hasFemaleParts){
genderNum = 0;
}//end if else block.
return storyArray[genderNum][index];

}//end method

}//end class




Re: scritping simply

PostPosted: Sun Aug 10, 2014 6:39 am
by hat973
Aw okay uh ill see if i can understand this code then blue If Button Male is click play frames labed male 1-10 if female button picked play frames labed female 1-10

Re: scritping simply

PostPosted: Sun Aug 10, 2014 4:47 pm
by BlueLight
I made a mistake with the array. Sorry. Should be String[][].

However this code detects what gender you are. Then when you pass in a index value it returns the string for your gender at that index.
That's how i would do multiple story line without know what other features their are.

Re: scritping simply

PostPosted: Tue Aug 12, 2014 5:28 am
by hat973
Okay the fist image is of the outer time line the MAIN time line
Spoiler (click to show/hide):

Mc1.png
Mc1.png (7.51 KiB) Viewed 1955 times

the 2nd is the timeline in it all those frames in the 2nd are mc I want to keep on this time line what would i use for as2 coding in that frame
Spoiler (click to show/hide):

MC2.png
MC2.png (9.61 KiB) Viewed 1955 times