May 25, 2013, 07:18:58 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Prowlie Welcome back! The site migration is complete and normal service resumed.
Advanced search
Pages: 1 [2] 3   Go Down
Print
Author Topic: What Does this button do? AS3 Help  (Read 9358 times)
0 Members and 1 Guest are viewing this topic.
TheGrayK
That Awesome Guy You Know
Senior Member
****
Offline Offline

Gender: Male
Posts: 907

Daredevil Extraordinair!


« Reply #15 on: September 06, 2009, 04:36:29 AM »

Not unclear I got it I just wanted to keep others from being confused  Grin
Anyway my first successful, practical, completely original code !

Code:
finger.alpha=0;

finger.addEventListener(MouseEvent.MOUSE_OVER,mouseover);
function mouseover(event:MouseEvent):void{
finger.alpha=100;
}

finger.addEventListener(MouseEvent.MOUSE_OUT,mouseout);
function mouseout(event:MouseEvent):void{
finger.alpha=0;
}

I know I could probably find this out by looking around a bit but I'm to lazy so here I go,
Is there a hotkey for accessing the actionscript window?
Logged

The novelty of my own mortality has yet to be torn,
While the vulgarity of my existence has made its welcome worn.
Jaehl
Mobal Gloderator
Global Moderator
Veteran
***
Offline Offline

Gender: Male
Posts: 1418


/* No comment */


WWW
« Reply #16 on: September 06, 2009, 04:57:07 AM »

F9 Smiley
Logged


<a href="http://i17.photobucket.com/albums/b90/Jaehll/Actionscript_Banner.swf" target="_blank">http://i17.photobucket.com/albums/b90/Jaehll/Actionscript_Banner.swf</a><a href="http://img.photobucket.com/albums/v661/Vector88/motm.swf?vTitle=oct%2Fnov%2007.swf" target="_blank">http://img.photobucket.com/albums/v661/Vector88/motm.swf?vTitle=oct%2Fnov%2007.swf</a>
Sarus translator:
<a href="http://www.jaehl.com/files/progress.swf" target="_blank">http://www.jaehl.com/files/progress.swf</a>
TheGrayK
That Awesome Guy You Know
Senior Member
****
Offline Offline

Gender: Male
Posts: 907

Daredevil Extraordinair!


« Reply #17 on: September 06, 2009, 04:58:23 AM »

Thanks!  Grin
Logged

The novelty of my own mortality has yet to be torn,
While the vulgarity of my existence has made its welcome worn.
TheGrayK
That Awesome Guy You Know
Senior Member
****
Offline Offline

Gender: Male
Posts: 907

Daredevil Extraordinair!


« Reply #18 on: September 06, 2009, 06:39:14 AM »

Ok so I have kinda stopped reading the manual (its a little overwhelming  argh!)
And i was how to make this work you should be able to see what im trying to do here
Code:
spiral.addEventListener(MouseEvent.CLICK, up);
spiral.addEventListener(MouseEvent.MOUSE_UP, up)
function up(event:MouseEvent):void{
spiral.scaleX=+1;
spiral.scaleY=+1;
}
Logged

The novelty of my own mortality has yet to be torn,
While the vulgarity of my existence has made its welcome worn.
Jaehl
Mobal Gloderator
Global Moderator
Veteran
***
Offline Offline

Gender: Male
Posts: 1418


/* No comment */


WWW
« Reply #19 on: September 06, 2009, 07:39:53 AM »

Well, for one thing, =+ doesn't really mean anything. (Basically you're just making the variable equal to +1, so the plus sign is superfluous.)

I'm going to assume you meant +=. Smiley

Also, MouseEvent.CLICK and MouseEvent.UP are quite similar, so you don't need both of them. The difference between them is that CLICK requires you to press the mouse button down while you're hovering over the object, and release it while still hovering over it, whereas with UP, you could press the mouse button down elsewhere, move the cursor over the object and release it.

Hope that helps.  Wink
Logged


<a href="http://i17.photobucket.com/albums/b90/Jaehll/Actionscript_Banner.swf" target="_blank">http://i17.photobucket.com/albums/b90/Jaehll/Actionscript_Banner.swf</a><a href="http://img.photobucket.com/albums/v661/Vector88/motm.swf?vTitle=oct%2Fnov%2007.swf" target="_blank">http://img.photobucket.com/albums/v661/Vector88/motm.swf?vTitle=oct%2Fnov%2007.swf</a>
Sarus translator:
<a href="http://www.jaehl.com/files/progress.swf" target="_blank">http://www.jaehl.com/files/progress.swf</a>
TheGrayK
That Awesome Guy You Know
Senior Member
****
Offline Offline

Gender: Male
Posts: 907

Daredevil Extraordinair!


« Reply #20 on: September 06, 2009, 11:55:24 AM »

Thank you Jaehl    Smiley
I was assuming up meant direction and not release
and you helped out alot here is the new code and
I changed it from clicking to mouse over left the name of the
function the same im not trying to build something large just playing.
Code:
spiral.addEventListener(MouseEvent.MOUSE_OVER, up);
function up(event:MouseEvent):void{
spiral.scaleX+=.01;
spiral.scaleY+=.01;
}

And here is the result!
<a href="http://www.truploader.com/uploads/209914makeabigspiral.swf" target="_blank">http://www.truploader.com/uploads/209914makeabigspiral.swf</a>
Logged

The novelty of my own mortality has yet to be torn,
While the vulgarity of my existence has made its welcome worn.
supermoose
Full Member
***
Offline Offline

Gender: Male
Posts: 240


Yes. I beat IWBTG. Only took ~60 hours of play.


« Reply #21 on: September 07, 2009, 05:03:05 PM »

also, +=1 is a "sloppy" way of doing this call.  The "professional" way of doing is is ++.  This doesn't work for an increment of 0.01 like your second example has, but to increment a counter, or to increase any variable by 1, use ++.  It's not an important difference, but if you want to officially publish any of your code, it may make you look a smidge more pro.

Code:
spiral.addEventListener(MouseEvent.CLICK, up);
spiral.addEventListener(MouseEvent.MOUSE_UP, up)
function up(event:MouseEvent):void{
spiral.scaleX++;
spiral.scaleY++;

[Edit]  Jaehl is right, I didn't hit backspace enough times.  I need to stop editing code at 3 am  Grin
« Last Edit: September 08, 2009, 04:20:26 AM by supermoose » Logged

Jaehl
Mobal Gloderator
Global Moderator
Veteran
***
Offline Offline

Gender: Male
Posts: 1418


/* No comment */


WWW
« Reply #22 on: September 07, 2009, 10:32:08 PM »

Code:
spiral.addEventListener(MouseEvent.CLICK, up);
spiral.addEventListener(MouseEvent.MOUSE_UP, up)
function up(event:MouseEvent):void{
spiral.scaleX=++;
spiral.scaleY=++;
That should be ++, rather than =++. Smiley
Logged


<a href="http://i17.photobucket.com/albums/b90/Jaehll/Actionscript_Banner.swf" target="_blank">http://i17.photobucket.com/albums/b90/Jaehll/Actionscript_Banner.swf</a><a href="http://img.photobucket.com/albums/v661/Vector88/motm.swf?vTitle=oct%2Fnov%2007.swf" target="_blank">http://img.photobucket.com/albums/v661/Vector88/motm.swf?vTitle=oct%2Fnov%2007.swf</a>
Sarus translator:
<a href="http://www.jaehl.com/files/progress.swf" target="_blank">http://www.jaehl.com/files/progress.swf</a>
TheGrayK
That Awesome Guy You Know
Senior Member
****
Offline Offline

Gender: Male
Posts: 907

Daredevil Extraordinair!


« Reply #23 on: September 09, 2009, 05:21:39 PM »

Okay so now i ask how would i make this object continuously scale up without having to repeat what ever action i have assigned to call that function?
If that makes sense?
Logged

The novelty of my own mortality has yet to be torn,
While the vulgarity of my existence has made its welcome worn.
Jaehl
Mobal Gloderator
Global Moderator
Veteran
***
Offline Offline

Gender: Male
Posts: 1418


/* No comment */


WWW
« Reply #24 on: September 09, 2009, 10:25:28 PM »

Something like this would do:
Code:
//This variable determines whether the spiral should be scaling up or not
var keepScaling:Boolean = false;

//Seeing as how it's a very simple function, rather than declaring it elsewhere, I created an anonymous function inside the event listener
spiral.addEventListener(MouseEvent.CLICK, function() { keepScaling = true; });

//Assigns an event that is called each time the timeline begins a new frame
addEventListener(Event.ENTER_FRAME, main);
function main(event:Event) {
if (keepScaling) {
spiral.scaleX += 0.1;
spiral.scaleY += 0.1;
}
}
« Last Edit: September 10, 2009, 12:18:21 PM by Jaehl » Logged


<a href="http://i17.photobucket.com/albums/b90/Jaehll/Actionscript_Banner.swf" target="_blank">http://i17.photobucket.com/albums/b90/Jaehll/Actionscript_Banner.swf</a><a href="http://img.photobucket.com/albums/v661/Vector88/motm.swf?vTitle=oct%2Fnov%2007.swf" target="_blank">http://img.photobucket.com/albums/v661/Vector88/motm.swf?vTitle=oct%2Fnov%2007.swf</a>
Sarus translator:
<a href="http://www.jaehl.com/files/progress.swf" target="_blank">http://www.jaehl.com/files/progress.swf</a>
TheGrayK
That Awesome Guy You Know
Senior Member
****
Offline Offline

Gender: Male
Posts: 907

Daredevil Extraordinair!


« Reply #25 on: October 12, 2009, 01:21:53 PM »

Code:
gotoAndStop(1);

test.addEventListener(MouseEvent.MOUSE_OVER, hovertest);
function hovertest(event:MouseEvent):void{
gotoAndPlay (1);
}

test.addEventListener(MouseEvent.MOUSE_OUT, outtest);
function outtest(event:MouseEvent):void{
gotoAndStop (1);
}


Anybody have an idea as to why this isn't working at all?
Logged

The novelty of my own mortality has yet to be torn,
While the vulgarity of my existence has made its welcome worn.
brettamatowski
You have 934,901 messages, 934,901 are new.
MotM
Senior Member
**
Offline Offline

Gender: Male
Posts: 559


Character design for next game in progress.


WWW
« Reply #26 on: October 12, 2009, 01:43:10 PM »

I had explained quite a bit until my internet crashed, so here it is in short.

You should have two different keyframes for each function.  The first keyframe should be your MOUSE_OUT, and the next keyframe should be your MOUSE_OVER.

Which leaves you with:

Code:
gotoAndStop(1);

test.addEventListener(MouseEvent.MOUSE_OVER, hovertest);
function hovertest(event:MouseEvent):void{
gotoAndPlay (2);
}

test.addEventListener(MouseEvent.MOUSE_OUT, outtest);
function outtest(event:MouseEvent):void{
gotoAndStop (1);
}

Atleast I think this would work.  I'm fairly new to coding as well, but I know quite a bit from reading up on some stuff.
Logged

TheGrayK
That Awesome Guy You Know
Senior Member
****
Offline Offline

Gender: Male
Posts: 907

Daredevil Extraordinair!


« Reply #27 on: October 12, 2009, 01:52:54 PM »

Thanks I think I was Just about to make that discover I just hadn't looked at the code yet
I made an extra frame at the beginning to set up for this though.
Thanks for the help man it is much appreciated.

Edit:
Ok so I did all of the frame adjustments but know something strange is happening here is the code and the swf so you can see for your self
Code:
test.gotoAndStop(1);

home.addEventListener(MouseEvent.MOUSE_UP, homeclick);
function homeclick(event:MouseEvent):void{
var request = new URLRequest("http://toonani.webs.com/");
    navigateToURL(request,"_self");
}

about.addEventListener(MouseEvent.MOUSE_UP, aboutclick);
function aboutclick(event:MouseEvent):void{
var request = new URLRequest("http://www.toonani.webs.com/about.htm");
    navigateToURL(request,"_self");
}

contact.addEventListener(MouseEvent.MOUSE_UP, contactclick);
function contactclick(event:MouseEvent):void{
var request = new URLRequest("http://www.toonani.webs.com/contact.htm");
    navigateToURL(request,"_self");
}

works.addEventListener(MouseEvent.MOUSE_UP, worksclick)
function worksclick(event:MouseEvent):void{
var request = new URLRequest("http://www.toonani.webs.com/works.htm");
    navigateToURL(request,"_self");
}

test.addEventListener(MouseEvent.MOUSE_OVER, hovertest);
function hovertest(event:MouseEvent):void{
test.gotoAndPlay(2);
}

test.addEventListener(MouseEvent.MOUSE_OUT, outtest);
function outtest(event:MouseEvent):void{
test.gotoAndStop(1);
}
<a href="http://www.truploader.com/uploads/181509Test.swf" target="_blank">http://www.truploader.com/uploads/181509Test.swf</a>

The circle is the test instance and I have a black bg set behind at 1 opacity to set up borders so that things like this dont happen.

Edit:
I also have some action script inside the movie clip telling it to stop before it loops. I dont think that would mess it up though.

« Last Edit: October 12, 2009, 02:10:22 PM by TheGrayK » Logged

The novelty of my own mortality has yet to be torn,
While the vulgarity of my existence has made its welcome worn.
TheGrayK
That Awesome Guy You Know
Senior Member
****
Offline Offline

Gender: Male
Posts: 907

Daredevil Extraordinair!


« Reply #28 on: October 12, 2009, 05:10:01 PM »

Bump so that everyone will know!
I Fixed it and I am very dumb!
I had a timeline in the scene that was the problem
really.
anyway here is all of the effin code and the swf.
<a href="http://toonani.webs.com/misc/Tabbednavi.swf" target="_blank">http://toonani.webs.com/misc/Tabbednavi.swf</a>
Code:
home.gotoAndStop(1);
about.gotoAndStop(1);
contact.gotoAndStop(1);
works.gotoAndStop(1);

home.addEventListener(MouseEvent.MOUSE_UP, homeclick);
function homeclick(event:MouseEvent):void{
var request = new URLRequest("http://www.toonani.webs.com/");
    navigateToURL(request,"_self");
}

home.addEventListener(MouseEvent.MOUSE_OVER, homehover);
function homehover(event:MouseEvent):void{
home.gotoAndPlay(2);
}

home.addEventListener(MouseEvent.MOUSE_OUT, homeout);
function homeout(event:MouseEvent):void{
home.gotoAndStop(1);
}

about.addEventListener(MouseEvent.MOUSE_UP, aboutclick);
function aboutclick(event:MouseEvent):void{
var request = new URLRequest("http://www.toonani.webs.com/about.htm");
    navigateToURL(request,"_self");
}

about.addEventListener(MouseEvent.MOUSE_OVER, abouthover);
function abouthover(event:MouseEvent):void{
about.gotoAndPlay(2);
}

about.addEventListener(MouseEvent.MOUSE_OUT, aboutout);
function aboutout(event:MouseEvent):void{
about.gotoAndStop(1);
}

contact.addEventListener(MouseEvent.MOUSE_UP, contactclick);
function contactclick(event:MouseEvent):void{
var request = new URLRequest("http://www.toonani.webs.com/contact.htm");
    navigateToURL(request,"_self");
}

contact.addEventListener(MouseEvent.MOUSE_OVER, contacthover);
function contacthover(event:MouseEvent):void{
contact.gotoAndPlay(2);
}

contact.addEventListener(MouseEvent.MOUSE_OUT, contactout);
function contactout(event:MouseEvent):void{
contact.gotoAndStop(1);
}

works.addEventListener(MouseEvent.MOUSE_UP, worksclick)
function worksclick(event:MouseEvent):void{
var request = new URLRequest("http://www.toonani.webs.com/works.htm");
    navigateToURL(request,"_self");
}

works.addEventListener(MouseEvent.MOUSE_OVER, workshover);
function workshover(event:MouseEvent):void{
works.gotoAndPlay(2);
}

works.addEventListener(MouseEvent.MOUSE_OUT, worksout);
function worksout(event:MouseEvent):void{
works.gotoAndStop(1);
}

Logged

The novelty of my own mortality has yet to be torn,
While the vulgarity of my existence has made its welcome worn.
Jaehl
Mobal Gloderator
Global Moderator
Veteran
***
Offline Offline

Gender: Male
Posts: 1418


/* No comment */


WWW
« Reply #29 on: October 14, 2009, 04:34:55 AM »

It might make things easier if you put the "hover" and "out" functions into one function each. Like so:
Code:
home.addEventListener(MouseEvent.MOUSE_OVER, hover);
about.addEventListener(MouseEvent.MOUSE_OVER, hover);
contact.addEventListener(MouseEvent.MOUSE_OVER, hover);
works.addEventListener(MouseEvent.MOUSE_OVER, hover);
function hover(event:MouseEvent):void{
event.target.gotoAndPlay(2);
}

home.addEventListener(MouseEvent.MOUSE_OUT, out);
about.addEventListener(MouseEvent.MOUSE_OUT, out);
contact.addEventListener(MouseEvent.MOUSE_OUT, out);
works.addEventListener(MouseEvent.MOUSE_OUT, out);
function out(event:MouseEvent):void{
event.target.gotoAndStop(1);
}
Logged


<a href="http://i17.photobucket.com/albums/b90/Jaehll/Actionscript_Banner.swf" target="_blank">http://i17.photobucket.com/albums/b90/Jaehll/Actionscript_Banner.swf</a><a href="http://img.photobucket.com/albums/v661/Vector88/motm.swf?vTitle=oct%2Fnov%2007.swf" target="_blank">http://img.photobucket.com/albums/v661/Vector88/motm.swf?vTitle=oct%2Fnov%2007.swf</a>
Sarus translator:
<a href="http://www.jaehl.com/files/progress.swf" target="_blank">http://www.jaehl.com/files/progress.swf</a>
Brackenwood
   

 Logged
Pages: 1 [2] 3   Go Up
Print
Jump to:  

Theme by Pieter, based on Black Rain by Crip Powered by SMF 1.1.16 | SMF © 2011, Simple Machines XHTML | CSS

Page created in 0.113 seconds with 25 queries.