Forum Topic: need as help

(145 views • 18 replies)

This topic is 1 page long.

<< < > >>
Questioning

starownage3

Reply To Post Reply & Quote

Posted at: 10/27/09 07:26 PM

starownage3 EVIL LEVEL 16

Sign-Up: 04/22/08

Posts: 461

im using as2. im getting ready for the shift to as3. im trying to learn to script on the frame instead of the symbols. here are the things i need help on:
how do i make a onClipEvent (enterFrame) { type of thing that makes the script run every frame.
how to apply movie controls to a symbol. make it play, stop on a frame etc.
buttons. i don't think i need to explain that one.

My friend's sister plays wizard 101....
she's 17.....
wtf?


None

Xeptic

Reply To Post Reply & Quote

Posted at: 10/27/09 07:34 PM

Xeptic LIGHT LEVEL 30

Sign-Up: 05/12/05

Posts: 2,192

At 10/27/09 07:26 PM, starownage3 wrote: im using as2. im getting ready for the shift to as3. im trying to learn to script on the frame instead of the symbols. here are the things i need help on:
how do i make a onClipEvent (enterFrame) { type of thing that makes the script run every frame.
addEventListener(Event.ENTER_FRAME, functionName);

function functionName(event:Event):void {
   actions
}
how to apply movie controls to a symbol. make it play, stop on a frame etc.
mc.stop();
mc.play();
mc.gotoAndStop(x);
mc.gotoAndPlay(x);
etc.
buttons. i don't think i need to explain that one.
BBS Signature

None

starownage3

Reply To Post Reply & Quote

Posted at: 10/27/09 07:38 PM

starownage3 EVIL LEVEL 16

Sign-Up: 04/22/08

Posts: 461

heres what it kinda looks like:
onClipEvent (load) {
_root.Time = 3600;
_root.Time_sec = 120;
_root.Att = 30;
}
onClipEvent (enterFrame) {
_root.Time -= 1;
_root.Time_sec = Math.round(_root.Time/30);
_root.Time_bar._width = _root.Time/6;
_root.Att -= 1/30;
if (_root.Att<0) {
Att == 0;
}
if (_root.Att>100) {
Att == 100;
}
_root.Att_bar._width = _root.Att*5;
}
i need to put this on a frame instead of a symbol
let me try to explain a bit.
fps is 30
Time = time left in frames
Time._sec = time left in seconds
this is being displayed.
you win when the police comes
Att = attention = used for summoning people to help you.
it fades over time. its set to 30 because i was testing it out. i only scripted the bars so far.

My friend's sister plays wizard 101....
she's 17.....
wtf?


Elated

starownage3

Reply To Post Reply & Quote

Posted at: 10/27/09 07:39 PM

starownage3 EVIL LEVEL 16

Sign-Up: 04/22/08

Posts: 461

THANKS SO MUCH >.<
btw. how do you get the script to look like that?

My friend's sister plays wizard 101....
she's 17.....
wtf?


None

Fion

Reply To Post Reply & Quote

Posted at: 10/27/09 07:43 PM

Fion LIGHT LEVEL 34

Sign-Up: 08/21/05

Posts: 2,375

At 10/27/09 07:39 PM, starownage3 wrote: THANKS SO MUCH >.<
btw. how do you get the script to look like that?

Using code tags, simply put the word code between <> and then to close the tag, /code between <>.

You should understand that whilst AS3 is written on the timeline and in separate as files exclusively changing from writing AS2 on symbols to on the timeline isn't the halfway point between the languages. I myself find that it was much easier to just jump right into AS3 rather than trying to ease into it. Take it like it's a new language all together and when you start seeing similarities between the two, like some syntax, well that will just help you along the way. But that's just my opinion. Good luck with your endeavors.


Misunderstood

starownage3

Reply To Post Reply & Quote

Posted at: 10/27/09 07:51 PM

starownage3 EVIL LEVEL 16

Sign-Up: 04/22/08

Posts: 461

At 10/27/09 07:43 PM, Fion wrote:
At 10/27/09 07:39 PM, starownage3 wrote: THANKS SO MUCH >.<
btw. how do you get the script to look like that?
Using code tags, simply put the word code between <> and then to close the tag, /code between <>.

You should understand that whilst AS3 is written on the timeline and in separate as files exclusively changing from writing AS2 on symbols to on the timeline isn't the halfway point between the languages. I myself find that it was much easier to just jump right into AS3 rather than trying to ease into it. Take it like it's a new language all together and when you start seeing similarities between the two, like some syntax, well that will just help you along the way. But that's just my opinion. Good luck with your endeavors.

its just that i have no experience at all when it comes to putting scripts unto the frames. i just thought i should get the basics of it. plus i don't have as3 yet. I'm getting it soon but not yet. nobody solved my button problem yet :/

My friend's sister plays wizard 101....
she's 17.....
wtf?


Resigned

starownage3

Reply To Post Reply & Quote

Posted at: 10/27/09 08:15 PM

starownage3 EVIL LEVEL 16

Sign-Up: 04/22/08

Posts: 461

addEventListener(Event.ENTER_FRAME, functionName);

function functionName(event:Event):void {
actions
}

im doing something wrong. can someone explain how this works. i understand a bit of it but i dont get the whole thing.

My friend's sister plays wizard 101....
she's 17.....
wtf?


None

starownage3

Reply To Post Reply & Quote

Posted at: 10/27/09 08:35 PM

starownage3 EVIL LEVEL 16

Sign-Up: 04/22/08

Posts: 461

At 10/27/09 08:15 PM, starownage3 wrote:
addEventListener(Event.ENTER_FRAME, functionName);

function functionName(event:Event):void {
actions
}
im doing something wrong. can someone explain how this works. i understand a bit of it but i dont get the whole thing.

heres what appeared in the output screen:
**Error** Scene=Scene 1, layer=Layer 8, frame=1:Line 5: The class or interface 'Event' could not be loaded.
function frame(event:Event):void {

Total ActionScript Errors: 1 Reported Errors: 1

My friend's sister plays wizard 101....
she's 17.....
wtf?


None

Version2

Reply To Post Reply & Quote

Posted at: 10/27/09 09:18 PM

Version2 EVIL LEVEL 11

Sign-Up: 09/24/03

Posts: 613

At 10/27/09 08:15 PM, starownage3 wrote:
addEventListener(Event.ENTER_FRAME, functionName);

function functionName(event:Event):void {
actions
}
im doing something wrong. can someone explain how this works. i understand a bit of it but i dont get the whole thing.

Well, first off, that was an example, that code won't actually "do" anything other than call functionName() every frame. But functionName() in this example doesn't do anything.

You said you don't have AS3 yet, if you have anything older than flash 9, you can't just use AS3, the AVM will only accept AS1 and AS2. If plan on getting a newer version of flash, go pick up a book or read some tutorials on AS3 basics. Then when you get AS3 you will have a better understanding of everything.

If you don't plan on upgrading, you probably should just stick to learning as2.


Misunderstood

starownage3

Reply To Post Reply & Quote

Posted at: 10/28/09 05:56 AM

starownage3 EVIL LEVEL 16

Sign-Up: 04/22/08

Posts: 461

At 10/27/09 09:18 PM, Version2 wrote:
At 10/27/09 08:15 PM, starownage3 wrote:
addEventListener(Event.ENTER_FRAME, functionName);

function functionName(event:Event):void {
actions
}
im doing something wrong. can someone explain how this works. i understand a bit of it but i dont get the whole thing.
Well, first off, that was an example, that code won't actually "do" anything other than call functionName() every frame. But functionName() in this example doesn't do anything.

i got that part but i don't understand what void does. this is the script i came up with.

addEventListener(Event.ENTER_FRAME, Enter_frame);
function Enter_frame(event:Event):void
{
	Time -= 1;
	Time_sec = Math.round(Time/30);
	Time_bar._width = Time/6;
	Att -= 1/30;
	if (Att<0) {
		Att == 0;
	}
	if (Att>100) {
		Att == 100;
	}
	Att_bar._width = Att*5;
}

heres what pops up:
**Error** Scene=Scene 1, layer=Layer 8, frame=1:Line 5: The class or interface 'Event' could not be loaded.
function Enter_frame(event:Event):void

Total ActionScript Errors: 1 Reported Errors: 1

My friend's sister plays wizard 101....
she's 17.....
wtf?


None

Version2

Reply To Post Reply & Quote

Posted at: 10/28/09 06:11 AM

Version2 EVIL LEVEL 11

Sign-Up: 09/24/03

Posts: 613

Do you use imports when coding in frames? I've been doing everything dynamically from custom classes. Try putting

import flash.events.Event;

At the top.


Sad

starownage3

Reply To Post Reply & Quote

Posted at: 10/28/09 06:22 AM

starownage3 EVIL LEVEL 16

Sign-Up: 04/22/08

Posts: 461

At 10/28/09 06:11 AM, Version2 wrote: Do you use imports when coding in frames? I've been doing everything dynamically from custom classes. Try putting

import flash.events.Event;

At the top.

**Error** Scene=Scene 1, layer=Layer 8, frame=1:Line 4: The class or interface 'flash.events.Event' could not be loaded.
import flash.events.Event;

**Error** Scene=Scene 1, layer=Layer 8, frame=1:Line 6: The class or interface 'Event' could not be loaded.
function Enter_frame(event:Event):void

Total ActionScript Errors: 2 Reported Errors: 2

My friend's sister plays wizard 101....
she's 17.....
wtf?


None

hdxmike

Reply To Post Reply & Quote

Posted at: 10/28/09 06:40 AM

hdxmike LIGHT LEVEL 09

Sign-Up: 09/11/09

Posts: 1,843

You dont have AS3 so the compiler doesnt recognize your code ergo the errors, its like trying to make a html site run some C++

OOP AS3 || Flash 8,CS3,CS4 || *sigh* || The new forum on the block : FLASH SEED !

BBS Signature

None

Version2

Reply To Post Reply & Quote

Posted at: 10/28/09 09:04 AM

Version2 EVIL LEVEL 11

Sign-Up: 09/24/03

Posts: 613

At 10/27/09 09:18 PM, Version2 wrote: you can't just use AS3

Just to, you know, point out the important words in my earlier post.


None

hdxmike

Reply To Post Reply & Quote

Posted at: 10/28/09 09:36 AM

hdxmike LIGHT LEVEL 09

Sign-Up: 09/11/09

Posts: 1,843

At 10/28/09 09:04 AM, Version2 wrote:
At 10/27/09 09:18 PM, Version2 wrote: you can't just use AS3
Just to, you know, point out the important words in my earlier post.

So why did you keep trying to help him ?

OOP AS3 || Flash 8,CS3,CS4 || *sigh* || The new forum on the block : FLASH SEED !

BBS Signature

None

Saza

Reply To Post Reply & Quote

Posted at: 10/28/09 09:48 AM

Saza LIGHT LEVEL 15

Sign-Up: 10/01/05

Posts: 1,945

Is he trying to code in AS3 in an AS2 document?

Oh lord.

Misunderstood

starownage3

Reply To Post Reply & Quote

Posted at: 10/28/09 04:27 PM

starownage3 EVIL LEVEL 16

Sign-Up: 04/22/08

Posts: 461

At 10/28/09 06:40 AM, hdxmike wrote: You dont have AS3 so the compiler doesnt recognize your code ergo the errors, its like trying to make a html site run some C++

wow. he gave me as3 script. anyone know any as2 script that makes things run everyframe. i asked for as2 he gave me as3. how was i suppose to know. (sigh)

My friend's sister plays wizard 101....
she's 17.....
wtf?


None

grafik2d

Reply To Post Reply & Quote

Posted at: 10/29/09 08:08 AM

grafik2d NEUTRAL LEVEL 10

Sign-Up: 06/29/04

Posts: 185

So you are talking about learning AS3, but you want AS2? You should be more specific. The code goes like this.

onEnterFrame=function()
{
actions like
*myGravityEngine(_root.myHero)
*myGravityEngine(_root.myEnnemy1)

*myWindEngine(_root.myHero)
*myWindEngine(_root.myEnnemy1)

// The following code is somewhat more advance so don't feel bad if don't understand right away,
// take it one step at the time
// you can also use a for loop to go throught an array of every objects is affected by physic
// var arrObjects:Array=Array(_root.myHero,_roo t.myEnnemy1)
// add as many ennemy or other object as you like
// for(i=0;iAS2
AS3

Hope this help.


None

grafik2d

Reply To Post Reply & Quote

Posted at: 10/29/09 08:11 AM

grafik2d NEUTRAL LEVEL 10

Sign-Up: 06/29/04

Posts: 185

for some reason a part of my first post is missing, I'll try to repost it

So you are talking about learning AS3, but you want AS2? You should be more specific. The code goes like this.

onEnterFrame=function(){
actions like
*myGravityEngine(_root.myHero)
*myGravityEngine(_root.myEnnemy1)

*myWindEngine(_root.myHero)
*myWindEngine(_root.myEnnemy1)

// The following code is somewhat more advance so don't feel bad if don't understand right away,
// take it one step at the time
// you can also use a for loop to go throught an array of every objects is affected by physic
// var arrObjects:Array=Array(_root.myHero,_roo t.myEnnemy1)
// add as many ennemy or other object as you like
// for(i=0;i<arrObjects._lenght+1;i++){
// a for loop is like an if statment that run multiple in one frame time until the condition returns false
// in our case until we run all the objects in the array.
// myGravityEngine(arrObject[i])
// myWindEngine(arrObject[i])
//}

}

*here are a couple of other things you might want to know

How to have your code seperated in reusable functions (one function can be apply to many objects), arg1 stand for argument you can have as much as you want you just need to specify th type (mine is MovieClip). When naming a function be concise and wright it in one word using capital letters instead of spaces, my gravity engine becomes myGravityEngine

function myGravityEngine(arg1:MovieClip){
if(!_root.ground.hitTest(arg1)){arg1._y+
+}
}

var wind:Boolean=true; // this is how you declare variable by the way, usually at the top of your script
var windSpeed:Number=3;

function myWindEngine(arg1:MovieClip){
if(wind){arg1._x-=windSpeed}
// notice here that if(wind==true) can be reduce to if(wind) to check for false you use if(!wind)
}

this is how you use mc's as buttons

_root.myMC.onRollOver=function{action} // when mouse is over myMC but not clicking
_root.myMC.onRollOut=function{action} //when mouse is no longer over myMC
_root.myMC.onPress=function{action}// when you click on it
_root.myMC.onRelease=function{action}// when you release your click over myMC
_root.myMC.onReleaseOutside=function{act ion} // when you release your click outside myMC

onClipEvent(onLoad){action}
is
onLoad=function(){action}

Hope this help.


All times are Eastern Standard Time (GMT -5) | Current Time: 04:30 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!