Advanced Actionscript; The "Ask Scarecrow" thread

Started by: Scarecrow | Replies: 14 | Views: 2,137

Scarecrow
2

Posts: 9,168
Joined: Oct 2005
Rep: 10

View Profile
Feb 2, 2012 6:45 AM #586068
so because i am starting university this year doing some variety of multimedia shit including flash and games dev, i need a refresher in my scripting.

hence i am opening this thread in the hopes of being asked some challenging questions to job my memory... and maybe even make me learn something in the process instead of sitting on my ass playing LoL.

so if you have a more advanced question post it here and if it seems like a legit problem that you couldn't have solved in google in under 2secs then i'll help you within several days (i am not online constantly and fuck you if you expect me to be).


DISCLAIMER: i reserve the right to assault you with ALL MY RAGE if you ask me how to make a button or post "howe do i maek game"
Highly

Posts: 24
Joined: Feb 2012
Rep: 10

View Profile
Feb 3, 2012 7:13 AM #586994
Quote from Scarecrow
so because i am starting university this year doing some variety of multimedia shit including flash and games dev, i need a refresher in my scripting.

hence i am opening this thread in the hopes of being asked some challenging questions to job my memory... and maybe even make me learn something in the process instead of sitting on my ass playing LoL.

so if you have a more advanced question post it here and if it seems like a legit problem that you couldn't have solved in google in under 2secs then i'll help you within several days (i am not online constantly and fuck you if you expect me to be).


DISCLAIMER: i reserve the right to assault you with ALL MY RAGE if you ask me how to make a button or post "howe do i maek game"


bro remember me? Highly_Scented? I'm an advanced actionscript person now too.

Just gonna ask what's up, how ya doin
Scarecrow
2

Posts: 9,168
Joined: Oct 2005
Rep: 10

View Profile
Feb 3, 2012 11:50 PM #587480
i remember you mang

can't complain how about you
Mage
2

Posts: 795
Joined: Feb 2009
Rep: 10

View Profile
Feb 4, 2012 1:24 AM #587541
Quote from Scarecrow
DISCLAIMER: i reserve the right to assault you with ALL MY RAGE if you ask me how to make a button or post "howe do i maek game"


Okay how can i make a game? lol...i had to say it
But think you will have a hard time in those classes with flash?
Scarecrow
2

Posts: 9,168
Joined: Oct 2005
Rep: 10

View Profile
Feb 4, 2012 2:23 AM #587579
Quote from I Pwn3d Jo0
Okay how can i make a game? lol...i had to say it
But think you will have a hard time in those classes with flash?


i very much doubt it
Scarecrow
2

Posts: 9,168
Joined: Oct 2005
Rep: 10

View Profile
Feb 23, 2012 3:28 AM #607099
so i take it nobody codes here any more?
Arch-Angel
2

Posts: 9,496
Joined: Jan 2007
Rep: 10

View Profile
Feb 23, 2012 4:39 AM #607126
The only AS I knew was how to make buttons in AS2

If you would like you could run me through making buttons in AS3. From my experience the same code doesn't work, and neither does anything I've gotten from a google tutorial lol.
Equinox Fox
2

Posts: 822
Joined: Jan 2012
Rep: 10

View Profile
Feb 23, 2012 4:43 AM #607128
I still code somewhat, but I've had to stop to actually focus on animation and school which kind of sucks.
Scarecrow
2

Posts: 9,168
Joined: Oct 2005
Rep: 10

View Profile
Feb 23, 2012 6:22 AM #607165
Quote from Arch-Angel
The only AS I knew was how to make buttons in AS2

If you would like you could run me through making buttons in AS3. From my experience the same code doesn't work, and neither does anything I've gotten from a google tutorial lol.



import flash.events.MouseEvent;
//imports necessary AS events

myMc.addEventListener(MouseEvent.ROLL_OVER, onRollOverHandler);
myMc.addEventListener(MouseEvent.ROLL_OUT, onRollOutHandler);
myMc.addEventListener(MouseEvent.CLICK, onClickHandler);
myMc.addEventListener(MouseEvent.MOUSE_DOWN, onPressHandler);
myMc.addEventListener(MouseEvent.MOUSE_UP, onReleaseHandler);
//adds event listeners to handle mouse events on a movie clip with instance name "myMc". the listeners
//will throw a function when the events they are looking for occur. eg: if you mouse over the movieclip,
//the "onRollOverHandler" function will fire.

function onRollOverHandler(myEvent:MouseEvent){
trace(“Over”);

}

function onRollOutHandler(myEvent:MouseEvent){
trace(“Out”);

}

function onClickHandler(myEvent:MouseEvent){
trace(“I waited for Press AND Release!!!”);

}

function onPressHandler(myEvent:MouseEvent){
trace(“Press”);

}

function onReleaseHandler(myEvent:MouseEvent){
trace(“Release”);

}
//above: functions with dummy effects for each of the mouse events you can use.


that covers any kind of button you might want. be sure to read the comments.

here is the code for a basic button click, if you're uninterested in the alternatives.



import flash.events.MouseEvent;
//imports necessary AS events

myMc.addEventListener(MouseEvent.CLICK, onClickHandler);
//adds event listeners to handle mouse events on a movie clip with instance name "myMc"

function onClickHandler(myEvent:MouseEvent){
trace(“I waited for Press AND Release!!!”);

}
//function with dummy effect to demonstrate mouse click effect
Javelin
2

Posts: 1,529
Joined: Feb 2010
Rep: 10

View Profile
Feb 23, 2012 6:47 AM #607173
Are the others using the same programme in your uni course?
Scarecrow
2

Posts: 9,168
Joined: Oct 2005
Rep: 10

View Profile
Feb 23, 2012 6:51 AM #607175
among others yes
Jeff
Administrator
1

Posts: 4,356
Joined: Dec 2007
Rep: 10

View Profile
Feb 24, 2012 3:06 PM #607815
What's more efficient or faster for returning a positive integer: Math.abs() or using bitwise shifting?
Scarecrow
2

Posts: 9,168
Joined: Oct 2005
Rep: 10

View Profile
Feb 25, 2012 10:40 AM #608132
bit shifting is much faster. the most efficient method i've found is:
var x:Number = -23;
var nn:Number = (x ^ (x >> 31)) - (x >> 31);
trace(nn);
//returns 23


however this only works for non-float (without decimal places) values.

if you are looking for more optimizations, here is a helpful page i found:
http://blog.coursevector.com/notes-math-optimizations
there are alternatives for most math operations there
Jeff
Administrator
1

Posts: 4,356
Joined: Dec 2007
Rep: 10

View Profile
Feb 25, 2012 12:47 PM #608157
If it only works with non-float values then why didn't you just strict datatype it to Integer? What is the relevance of the number 31 in there?
S-Critical
2

Posts: 2,848
Joined: Feb 2012
Rep: 10

View Profile
Feb 25, 2012 1:21 PM #608169
do you know how to make a scene selection?