The Enchanted Cave 2
Delve into a strange cave with a seemingly endless supply of treasure, strategically choos
4.39 / 5.00 38,635 ViewsGhostbusters B.I.P.
COMPLETE edition of the interactive "choose next panel" comic
4.09 / 5.00 15,161 Viewswell, for the "zoom in" you can download a v-cam(just google as2 or as3 v-cam) its a virtual camera that you can move around the screen, change its size and it will show what is inside of it</bad description>
variable++ is the same as variable+=1 which also is the same as variable=variable+1
Then how would I do this in as3 then?
for (a=1; a<=slimit; a++) {
var ["subbox"+a]:Sprite=new Sprite();
["subbox"+a].graphics.lineStyle(2,0x000000);
["subbox"+a].graphics.beginFill(0x999999);
["subbox"+a].graphics.drawRect((a-1)*(25+sdist),87.5,25,25);
["subbox"+a].graphics.endFill();
}
Please help me! :(
but That isn't what I wanted, I need to have 5 varaibles(its going to be 20 sprites later) so that really won't work, sorry!
var a:int
for(a=1;a<6;a++){
var["variable"+a]:Number=a
}
this code give this error:
1084: Syntax error: expecting identifier before leftbracket.
What am I doing wrong?
Thanks for any help
this should help you a bit
http://www.newgrounds.com/bbs/topic/3406 03
http://www.newgrounds.com/bbs/topic/3406 03 for the bullets, and http://www.newgrounds.com/bbs/topic/2936 60 for you to get an idea how to hittest
pm me for more help if you need it! :)
here is your code cleaned up, johnfn:
addEventListener(Event.ENTER_FRAME,box2enterframe);
function box2enterframe(event:Event) {
if (box2.hitTestPoint(mouseX,mouseY)) {
trace(Math.PI)
}
}
here, i made it myself: http://spamtheweb.com/ul/upload/190709/6 4177_heart_example.fla I did the math and for 20 hearts and 100 health, each heart has 5 frames of disentegrading(fyi). Give me some feed back if you like it ;)
function box2enterframe(event:Event) {
if (box2rolled) {
trace(Math.PI);
}
}
I had the change the first line, but it works!!!!
I didn't think of if that way, I'll use an AS3 version of that script:
var box2rolled:Boolean=false;
box2.addEventListener(MouseEvent.MOUSE_OVER,box2rollover);
box2.addEventListener(MouseEvent.MOUSE_OUT,box2rollout);
box2.addEventListener(Event.ENTER_FRAME,box2enterframe);
function box2rollover(event:MouseEvent) {
box2rolled=true;
}
function box2rollout(event:MouseEvent) {
box2rolled=false;
}
function box2enterframe(event:MouseEvent) {
if (box2rolled) {
trace(Math.PI);
}
}
so I have this code, but it only traces PI every time I roll over the object. I need it to keep on tracing PI as long as the mouse is over the box. Is there a seperate event for this, or do I need to combine a few?
box2.addEventListener(MouseEvent.MOUSE_OVER,box2rollover)
function box2rollover(event:MouseEvent){
trace(Math.PI)
}
genius!! I didn't know you had to save the as file before testing the document!
this code assumes that the names are VaultDweller and Enclave. make sure the registration point for the mc's are exactly in the middle in order to have this work well.
disx = _root.VaultDweller._x-_root.Enclave._x;
disy = _root.VaultDweller._y-_root.Enclave._y;
if ((disx>=0) && (disy>=0)) {
angle = 180-(180/Math.PI)*Math.atan(disx/disy);
} else if ((disx<=0) && (disy>=0)) {
angle = 270-(180/Math.PI)*Math.atan(disy/Math.abs(disx));
} else if ((disx>=0) && (disy<=0)) {
angle = (180/Math.PI)*Math.atan(disx/Math.abs(disy));
} else if ((disx<=0) && (disy<=0)) {
angle = 360-(180/Math.PI)*Math.atan(Math.abs(disx)/Math.abs(disy));
}
_root.VaultDweller._rotation = angle;
pm me is you have any more questions, i am pretty awsome in as2 ;)
so now i have a problem, my as file is only 9 lines long and an error says that on line 19(non existent): 1042: The this keyword can not be used in static methods. It can only be used in instance methods, function closures, and global code.
What should I do?(I did change the code to what you wrote.)
Thanks for all the help so far!!! :)
Thanks, dELtaluca. One more question. If I wanted to have the circle being drawn, would I put the script in the class, or the document. If it should be in the class, can I use this script?
package {
import flash.display.*;
import flash.display.Sprite;
public class Circle extends Sprite {
private var radius:Number;
private var fullname:String;
public function Circle(rad:Number,nam:String) {
radius=rad;
fullname=nam;
}
var mc:Sprite=new Sprite();
mc.name=fullname;
mc.graphics.lineStyle(1);
mc.graphics.beginFill(0xff0000);
mc.graphics.drawCircle(200,200,radius);
mc.graphics.endFill();
this.addChild(mc);
}
}
import Circle
var dot:Circle=new Circle(5,"dot")
so i have this script in an as file:(it's not done yet)
package {
import flash.display.Sprite;
public class Circle extends Sprite {
public function circle(rad:Number):void {
const radius:Number=rad;
}
public var c:Sprite = new sprite();
}
}
and I have these two lines of code in an seperate as3 document
import circle.as
var dot:Sprite=new circle(5)
Flash gives me this error:
1084: Syntax error: expecting identifier before as.
How would I be able to include the as file on compile so that I can use the circle class that I made?
Also, is everything in the document and as file correct?
Thanks for any help.
using a tablet, they usually redraw it from scratch every frame. You can can use the union skinning tool to have a shadow of the previous frame so that you can see how to change the re-draw so it looks animated nicely.
Hope this helps (and im not even an animator!!!).
ok, upload it to spamtheweb.com and I will export it, then submit it to spamtheweb so you can download the file.
let me know the address of the upload
if your doing as2:
stopAllSounds()
if your doing as3:
import flash.media.SoundMixer;SoundMixer.stopAll();
that would stop all the music, etc. happening. if you need only the music to be stopped then do this:
as2:
yoursound.stop()
as3:
// make sure you have these imported.
import flash.media.Sound;
import flash.media.SoundChannel;
// create your variables for your sound instance and one for a sound channel
var mySnd:YourSoundClassName;
var sndChannel:SoundChannel;
// create an instance for your sound
mySnd = new YourSoundClassName;
// then attach your sound to the sound channel like this
sndChannel = mySnd.play(); //
// then to stop your sound all you have to do is this.
sndChannel.stop();
thanks for the help, I have one last question:
What is the benefit of the class having all of the properties, etc. of a movieclip or sprite and can those properties be used within the class only if there is an extension?
no one is able to understand your code, even thought you put in an occasional comment. either comment more or completely explain what does what. :P
So, I have a few questions on what this script does(internally).
package {
import flash.display.Sprite;
public class FirstCircle extends Sprite {
public function FirstCircle( ) {
}
}
}
So according to my knowledge once the package is initialized, the sprite object is imported(along with all the properties, methods, and events that it is made of). What I don't understand is why the script says public class FirstCircle extends Sprite{.
Does it give the sprite's properties, methods, etc. to the class?
Also, what does the constructor do?
Is it a place to store all of the eventlisteners?
If so, what else can be stored there?
Finally, where do variables need to be initialized?
Thanks for previous help, everyone!
I'm trying to tackle the beast that is a class.
fine, i'll just figure it out myself!
I'm kind of new to as3 but...
is it ok to have an event function inside a while function?
i never tried it before in as2 or as3, but it seems kind of unnecessary to put it in there anyway.
so, a while ago I recently bought cs4, and, while looking for as3 tutorials, i am confused on how I should organize my flash projects now. here is how i designed them before:(with flash 8)
With movieclips, graphics, and buttons
actions on frames
not using classes
not using AS files(.as)
How should i try to organize my projects now? Here is what I heard:(for cs4)
dont put actions on frames
use classes
use AS files where the actions of frames used to be
use sprites for moveclips with only one frame
avoid using moveiclips all together
Could somebody help me straighten out all these things I have heard?
Thanks
as2 or as3? oh, and verson of flash do you have?
im interested, pm me if you need my help!
here is all the code:
const dots:Number=4;
const space:Number=40;
var a:int;
var b:int;
for (a=1; a<=dots; a++) {
for (b=1; b<=dots; b++) {
var mcd:MovieClip = new dot();
addChild(mcd);
mcd.x=b*space;
mcd.y=a*space;
mcd.name="dot"+((a-1)*dots+b);
}
}
for (a=1; a<=dots-1; a++) {
for (b=1; b<=dots-1; b++) {
var mcs:MovieClip= new square();
addChild(mcs);
mcs.gotoAndStop(1);
mcs.x=a*space+.5*space;
mcs.y=b*space+.5*space;
mcs.name= "square"+((a-1)*(dots-1)+b);
}
}
var lines:int = dots*((dots-1)*2);
var lineHolder:Array = new Array();
var layout:Array = new Array();
var counter:int=1;
var each:int=0;
for (a=0; a<lines; a++) {
lineHolder[a]=0;
layout[a]=0;
if (counter%2==0) {
if (each==dots) {
each=0;
counter++;
layout[a]=counter;
} else {
each++;
layout[a]=counter;
}
}
if (counter%2==1) {
if (each==dots-1) {
each=1;
counter++;
layout[a]=counter;
} else {
each++;
layout[a]=counter;
}
}
}
var column:int;
var row:int;
var amount:int;
for (a=1; a<=Math.pow(dots,2); a++) {
column=a%dots;
row=Math.floor((a-1)/dots)+1;
amount=(row-1)*(2*dots-1)+(column-1);
var mcl:MovieClip=new line();
addChild(mcl);
mcl.name="line"+amount;
trace("dotx: "+root["dot"+a].x);//here is the problem(the trace)
mcl.x=root["dot_"+a].x-space/2;//here is the original script
}
thanks for all the help so far, i just need a little bit more help to end this>:)
At 7/8/09 05:00 PM, doctormario wrote: Just curious...
what's with the underscore after dot? Could that be the dealbreaker?
tried the program without the underscore, still had the same error