scritping simply

A place for tutorials on how to get the most out of Flash

scritping simply

Postby hat973 » Tue Oct 15, 2013 2:26 am

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
Red light panda

:ugeek: Tumbler: Tumbler
:geek: I have a Blog: Red Light Blog
;) I stream to Give me a Watch over at: Picarto
:mrgreen: Donate: Patreon
:roll: Discord:Discord
User avatar
hat973
 
Joined: Mon Apr 23, 2012 11:44 pm

Re: scritping simply

Postby BlueLight » Tue Oct 15, 2013 3:10 pm

Well if your my CS teacher he will tell you that he hates scripts because they lack a compiler.
User avatar
BlueLight
Gangs n' Whores Developer
 
Joined: Sat Jun 04, 2011 7:23 am

Re: scritping simply

Postby OwnerOfSuccuby » Wed Oct 16, 2013 4:44 pm

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.
OwnerOfSuccuby
 
Joined: Fri Jun 11, 2010 8:33 pm

Re: scritping simply

Postby GoRepeat » Mon Oct 21, 2013 12:25 pm

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.
Picarto LiveStream: https://picarto.tv/GoRepeat
Other Stuff: Click Here
User avatar
GoRepeat
Moderator
 
Joined: Wed Jul 21, 2010 1:26 am
Location: Behind the Looking Glass

Re: scritping simply

Postby OwnerOfSuccuby » Tue Oct 22, 2013 10:13 am

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))
OwnerOfSuccuby
 
Joined: Fri Jun 11, 2010 8:33 pm

Re: scritping simply

Postby inkhryptedQuery » Sat Aug 02, 2014 10:15 pm

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 : ]
inkhryptedQuery
 
Joined: Thu Jul 24, 2014 7:21 pm

Re: scritping simply

Postby BlueLight » Sun Aug 03, 2014 7:36 pm

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.
User avatar
BlueLight
Gangs n' Whores Developer
 
Joined: Sat Jun 04, 2011 7:23 am

Re: scritping simply

Postby Zeus Kabob » Sun Aug 03, 2014 10:02 pm

Wait, does he hate Bash?
User avatar
Zeus Kabob
Moderator
 
Joined: Tue Nov 16, 2010 1:16 am
Location: Between some awesome thunderheads

Re: scritping simply

Postby hat973 » Mon Aug 04, 2014 12:38 am

I'm sorry zeus but Who is Bash
Red light panda

:ugeek: Tumbler: Tumbler
:geek: I have a Blog: Red Light Blog
;) I stream to Give me a Watch over at: Picarto
:mrgreen: Donate: Patreon
:roll: Discord:Discord
User avatar
hat973
 
Joined: Mon Apr 23, 2012 11:44 pm

Re: scritping simply

Postby BlueLight » Mon Aug 04, 2014 2:04 am

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!*
User avatar
BlueLight
Gangs n' Whores Developer
 
Joined: Sat Jun 04, 2011 7:23 am

Re: scritping simply

Postby inkhryptedQuery » Mon Aug 04, 2014 7:03 pm

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.
inkhryptedQuery
 
Joined: Thu Jul 24, 2014 7:21 pm

Re: scritping simply

Postby BlueLight » Mon Aug 04, 2014 7:15 pm

He didn't say anything about Bash script.
He mention action script and java script.
User avatar
BlueLight
Gangs n' Whores Developer
 
Joined: Sat Jun 04, 2011 7:23 am

Re: scritping simply

Postby Enkidu » Wed Aug 06, 2014 3:20 am

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.
Enkidu
Newly Registered
 
Joined: Sat Jul 26, 2014 4:44 pm
Location: Denver

Re: scritping simply

Postby hat973 » Fri Aug 08, 2014 9:58 am

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
Red light panda

:ugeek: Tumbler: Tumbler
:geek: I have a Blog: Red Light Blog
;) I stream to Give me a Watch over at: Picarto
:mrgreen: Donate: Patreon
:roll: Discord:Discord
User avatar
hat973
 
Joined: Mon Apr 23, 2012 11:44 pm

Re: scritping simply

Postby BlueLight » Fri Aug 08, 2014 4:27 pm

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];
User avatar
BlueLight
Gangs n' Whores Developer
 
Joined: Sat Jun 04, 2011 7:23 am

Re: scritping simply

Postby hat973 » Sun Aug 10, 2014 4:38 am

mind explaning it a bit better plz
Red light panda

:ugeek: Tumbler: Tumbler
:geek: I have a Blog: Red Light Blog
;) I stream to Give me a Watch over at: Picarto
:mrgreen: Donate: Patreon
:roll: Discord:Discord
User avatar
hat973
 
Joined: Mon Apr 23, 2012 11:44 pm

Re: scritping simply

Postby BlueLight » Sun Aug 10, 2014 5:06 am

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



Last edited by BlueLight on Tue Aug 12, 2014 6:17 am, edited 1 time in total.
User avatar
BlueLight
Gangs n' Whores Developer
 
Joined: Sat Jun 04, 2011 7:23 am

Re: scritping simply

Postby hat973 » Sun Aug 10, 2014 5:39 am

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
Red light panda

:ugeek: Tumbler: Tumbler
:geek: I have a Blog: Red Light Blog
;) I stream to Give me a Watch over at: Picarto
:mrgreen: Donate: Patreon
:roll: Discord:Discord
User avatar
hat973
 
Joined: Mon Apr 23, 2012 11:44 pm

Re: scritping simply

Postby BlueLight » Sun Aug 10, 2014 3:47 pm

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.
User avatar
BlueLight
Gangs n' Whores Developer
 
Joined: Sat Jun 04, 2011 7:23 am

Re: scritping simply

Postby hat973 » Tue Aug 12, 2014 4:28 am

Okay the fist image is of the outer time line the MAIN time line
Spoiler (click to show/hide):

Mc1.png

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
You do not have the required permissions to view the files attached to this post.
Red light panda

:ugeek: Tumbler: Tumbler
:geek: I have a Blog: Red Light Blog
;) I stream to Give me a Watch over at: Picarto
:mrgreen: Donate: Patreon
:roll: Discord:Discord
User avatar
hat973
 
Joined: Mon Apr 23, 2012 11:44 pm

Next

Return to Tutorials



Who is online

Users browsing this forum: Majestic-12 [Bot]