The Enchanted Cave 2
Delve into a strange cave with a seemingly endless supply of treasure, strategically choos
4.36 / 5.00 33,851 ViewsGhostbusters B.I.P.
COMPLETE edition of the interactive "choose next panel" comic
4.09 / 5.00 12,195 ViewsI dont understand whats wrong with it. Help please kind people as it to make correctly.
Main class
package{
import flash.display.*
import flash.text.*
import flash.events.*
import flash.net.URLRequest;
public class Os extends MovieClip{
static public var main;
public var poi:Sprite;
public function Os(){
main = this;
}
}
}
Object Class:
package{
import flash.display.*
import flash.events.*
import flash.ui.*
import flash.filters.*
import flash.utils.Timer;
import flash.events.TimerEvent;
public class Poi extends MovieClip{
static public var main;
public var up:Boolean = false;
public var v:Number = 5;
public function Poi(){
main = this;
Os.main.stage.addEventListener(KeyboardEvent.KEY_DOWN,keyP);
Os.main.stage.addEventListener(KeyboardEvent.KEY_UP,keyR);
addEventListener(Event.ENTER_FRAME,enterF);
}
function enterF(e:Event):void{
if(up){
this.x += v;
}
}
function keyP(e:KeyboardEvent):void{
if ( e.keyCode == Keyboard.UP )
{
up = true;
}
}
function keyR(e:KeyboardEvent):void{
if ( e.keyCode == Keyboard.UP )
{
up = false;
}
}
}
} At 9/30/09 10:37 AM, SpeedUP wrote: I dont understand whats wrong with it. Help please kind people as it to make correctly.
Main class
package{
import flash.display.*
import flash.text.*
import flash.events.*
import flash.net.URLRequest;
public class Os extends MovieClip{
static public var main;
public var poi:Sprite;
public function Os(){
main = this;
}
}
}
Object Class:
package{
import flash.display.*
import flash.events.*
import flash.ui.*
import flash.filters.*
import flash.utils.Timer;
import flash.events.TimerEvent;
public class Poi extends MovieClip{
static public var main;
public var up:Boolean = false;
public var v:Number = 5;
public function Poi(){
main = this;
Os.main.stage.addEventListener(KeyboardE vent.KEY_DOWN,keyP);
Os.main.stage.addEventListener(KeyboardE vent.KEY_UP,keyR);
addEventListener(Event.ENTER_FRAME,enter F);
}
function enterF(e:Event):void{
if(up){
this.x += v;
}
}
function keyP(e:KeyboardEvent):void{
if ( e.keyCode == Keyboard.UP )
{
up = true;
}
}
function keyR(e:KeyboardEvent):void{
if ( e.keyCode == Keyboard.UP )
{
up = false;
}
}
}
}
I dont understand what the fuck OS is supposed to be doing. Thus I don't know what your trying to accomplish. It's strange coding, that's for sure.
public var stageReference:Stage;
public function CONSTRUCTOR(stageReference:Stage) : void
{
stageReference.addEventListener(KeyboardEvent.KEY_DOWN,keyP);
stageReference.addEventListener(KeyboardEvent.KEY_UP,keyR);
addEventListener(Event.ENTER_FRAME,enterF);
}
All I did was make a reference to the stage and passed it into the function. Using a document class you wouldn't need to do such but I'm assuming this is any class. All the event listeners are added to the stage and the enter frame the object itself. Trash that first class, it's useless to you.
Also and I mean this with no disrespect: Please stop taking shortcuts and making your code impossible to read. This means don't import every goddamn class and write out keyboardPressed not keyP. Illegibility is fine if you don't make mistakes...
Feel free to write again if this wasn't fixed or you have other problems.