Problem accessing function within my Document Class
Hi there,
I have a Document Class which dynamically adds a MovieClip to
my FLA. The MovieClip is in the FLA library and has "Export for
ActionScript" setup for it and this is how I'm accessing the
MovieClip from my Document Class.
The problem is that when the MovieClip is finished (it has a
timeline animation and a stop() method applied to the last frame of
the animation) I want it to call a function that is placed within
my Document Class, but simply calling the function (e.g.
displayEnterButton();) is displaying an error of....
1180: Call to a possibly undefined method
displayEnterButton.
Can anyone help here, I'm sure it's a simple issue to
resolve.
Many thanks!
Kind regards,
M.
Hi,
I've managed a work around to this.
Basically, in my Document Class after the code that adds the
MovieClip to the Display List, I then setup a Timer that called a
function every 100 milliseconds. This function would then check the
current frame of the loaded MovieClip. If the current frame of the
MovieClip was equal to the last frame of the MovieClip then I would
know the animation had finished and would call the next function I
needed.
I've pasted the code below in case anyone was interested....
Similar Messages
-
How do you access data within a public class?
Hi,
This is my problem. I have a class which is used to take in user input. All methods and variables are public becuase I want to replicate this class over and over. (like a word processor that can have many open documents).
What I want to be able to do is when I click on a saveAll toolBar icon not in the class but separate, I want to be able to tell each class that I have instanced to save it's data. Is this possible when I'm using public methods and variables? I don't think getting each class to listen for the mouse click on the saveAll icon is the way to go, for I will have all classes trying to save at the same time.
Any suggestions greatly welcomed as I can't figure this out.
AdrianWell, under special circumstances, you might consider having a desktop (the contentpane of your frame should be a desktop), and your input classes (which are like documents in the word processor) should be internal frames. The menu belongs to the frame. Now when the user selects a menu item, you may use the getAllFrames[] method of the desktop pane to retrieve all of your internal frames.
Then it needs no extra efforts on your part to keep track your document classes; instead, you have to add or remove your documents to/from the desktop. That is, when a document is closing, it must remove itself from the desktop. -
Problems accessing child swf from parent class
First off: Hi. I'm new - to the forum and to Flash.
I'm currently writing a flash app that requests a XML feed
from a Java controller and loads child swfs into various parts of
the stage based on the settings/URL details received from the XML
feed.
Its nearly there and I've got my head round a couple of weird
things, but theres one thing left that I've found impossible to
solve. Once the loader class has loaded the swf, it can't access
its methods or set its variables and the child can't access the
parent either (or access the parent's variables full stop). From
what I've read this should be possible. Heres some of my code plus
pseudo code:
Note the Panel class is not linked to a symbol and uses
composition to act like a movie clip, rather than inheritance.
quote:
class Panel{
function Panel(owner:MovieClip, insName:String,
depth:Number){
initiates properties etc....
panelMovie = owner.createEmptyMovieClip(insName,depth);
listener.onLoadComplete = mx.utils.Delegate.create(this,
scheduleModule);
loader.addListener(listener);
loader.loadClip(moduleX.url, panelMovie);
function scheduleModule(){
trace(panelMovie.key);
trace(panelMove.keyTest());
panelMovie.key = "dave";
trace(panelMovie.key);
Child swf:
quote:
var key:String = "test";
As you can see I create an empty movieclip which I store a
reference to in this class under the field "panelMovie". I then use
this (instead of target_mc like you might do with an event handler)
to try to access the child swf. The output is:
trace(panelMovie.key); = "test" (Works fine)
trace(panelMove.keyTest()); = (Nothing returned)
panelMovie.key = "dave";
trace(panelMovie.key); = "test" (Previous line = no effect)
Is this something related to using a class? Really would be
preferentially to keep all code outside of the fla.
I've also tried a lot of different combinations of _root,
_parent and _levelx. None of which I truly understand.
Any help would be much appreciated! Plus any good tutorial
links on timeline and referring to objects in it!
(Couldn't find the code tag/button...)>>trace(panelMove.keyTest()); = (Nothing returned)
You have panelMove here instead of panelMovie
Dave -
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/ -
Problems accessing parameters within repeating frames.
I hope this is a more readable version of the problem I just submitted.
This is the overall layout of a report I am currently working on
and having problems with, using Oracle Reports 6i.
Departments Commitments Obligations
Dept 1 - Dept 1 Title
RCC 1 - RCC Title
RIC
Non-pay by RIC 308 1 1
Non-pay by RIC 438 1 1
Non-pay by RIC 514 1 1
Subtotal 3 3
Pay by RIC 514 2 2
Total RCC 1 5 5
RCC 2 - RCC Title
RIC
Non-pay by RIC 308 1 1
Non-pay by RIC 438 1 1
Non-pay by RIC 514 1 1
Subtotal 3 3
Pay by RIC 514 1 1
Total RCC 2 5 5
Dept n
Total Dept 1
Non-pay by RIC 308 2 2
Non-pay by RIC 438 2 2
Non-pay by RIC 514 2 2
Subtotal 6 6
Pay RIC 514 4 4
Total Dept1 10 10
I use a format trigger to calculate the data for
Non-pay by RIC 308 (the most inner frame).
If (:RIC = '308') then
Return (True);
Else
Return (False);
End if;
And I do something equivalent for the other two RICs, RIC = 438,
and RIC = 514.
With this approach, I am able to calculate subtotals and totals
for all the RCCs for each Dept.
I work one frame at a time, from the inner frame to the outer
frame.
My problem is to get the Total Dept section at the end of each
Department.
Total Dept 1
Non-pay by RIC 308 2 2
Non-pay by RIC 438 2 2
Non-pay by RIC 514 2 2
Subtotal 6 6
Pay RIC 514 4 4
Total Dept1 10 10
I get a frame error when I try this code in a format trigger
If (:RIC = '308') then
Return (True);
Else
Return (False);
End if;
I know this trigger fails because I am trying to reference the ":RIC"
parameter that is in a different repeating frame.
How can I check for the RIC at this level?
Is there a better way to tackle this problem? Any suggestions?
Thanks,
CarlosSounds like the source data for the Graph is the wrong Group.
Dave -
Accessing document class function within timeline
Hi have a very simple question,
(Bear with me I'm still quite new to as3 and some of my terminology may not be solid)
I want to access a function that is within my document class when a movie clip on the timeline has played to a specific point (being the end).
I have already been able to call another function from the document class at the top/root level (it is called to initialize all clips and buttons when you click on the "enter" button on the splash screen.
Problem is that I cannot call another function (in the document class) from a movie clip within a movie clip on the timeline. Is there an easy way to do this? I have considered writing a separate class for the movie clip and then adding it onto the movie clip (using the property panel). I don't really want to do it this way because I am already using a base class on that movie clip and 3 others that use a set of generic functions.>>I want to access a function that is within my document class when a movie clip on the timeline has played to a specific point (being the end).
Your document class should add a listener to the clip and the clip should dispatch an event when it's complete. You could dispatch your own event or use one of Flash's like Event.COMPLETE. Something like:
in clip
dispatchEvent(new Event(Event.COMPLETE));
and in your doc class
clipOnTimeline.addEventListener(Event.COMPLETE, classMethod);
>>I have already been able to call another function from the document class at the top/root level (it is called to initialize all clips and buttons when you click on the "enter" button on the splash screen.
You really should avoid mixing timeline and document class code. Better would be for your doc class to add a listener to the button and call a method within the class when it's clicked. -
NEED TO KNOW HOW CONVERT GIF FILE TO SYMBOL FROM DOCUMENT CLASS
ROBERT LEAHONG
COMPUTER PROGRAMMER / ASP Web Devloper
Hello,
I need to convert a GIF file (PICTURE) to a symbol (Button) From within The Document Class using ActionScript 3.0 .
Thanks in advance for your help.So you imported a .gif into the library and need to get to it from the document class? If that's the case you need to right-click the image in the library, select properties, select the ActionScript tab and then set it to export for ActionScript. Give it a class name - I'll use myGif for example. You'll see it will have a base class of BitmapData...
Then in your document class you can just instantiate it like:
var myImageData:BitmapData = new myGif();
You can turn it into a useable image that you can place on stage by putting it into a Bitmap object:
var myImage:Bitmap = new Bitmap(myImageData);
If you want to make a button out of it, ie make it clickable - stick it into a Sprite:
var mySprite:Sprite = new Sprite():
mySprite.addChild(myImage);
addChild(mySprite);
mySprite.addEventListener(MouseEvent.CLICK, clicked);
function clicked(e:MouseEvent):void
trace("clicked");
HTH -
Cannot import SWF with document class (AS3)
When I try to import a SWF-file (published from a FLA-file with a as3 document class) via the mx:SWFLoader into Flash Builder, the imported SWF is not showing up (as3 build a cube from papervision3d). Which way do you have to import such a SWF-file?
Regards, SjoerdShitf+Ctrl+Enter:
Attempting to launch and connect to Player using URL preloader.swf
[SWF] preloader.swf - 9591 bytes after decompression
[SWF] big.swf - 1785015 bytes after decompression
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at DocumentlClass()
Cannot display source code at this location.
My document class (simplyfied):
package {
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import fl.transitions.easing.*;
import flash.events.ProgressEvent;
public class CarouselClass extends MovieClip {
private vars...
public function CarouselClass() {
trace("document class triggered");
this.addEventListener(Event.ADDED_TO_STAGE,init);
private function init(evt:Event):void{
texts = new Texts();
carouselSprite = new Sprite();
addChild(carouselSprite);
topContainer = new Sprite();
carouselSprite.addChild(topContainer);
hitBar = new HitBar();
hitBar.x = stage.stageWidth / 2 - hitBar.width /2;
hitBar.y = 245;
addChild(hitBar);
downContent = new DownContent();
addChild(downContent);
downContent.y = 325;
downContent.title_txt.text = "Learning Carousel";
downContent.description_txt.text = "Click on one of images above to view further details";
createSections();
} ... (more functions) -
Refer to the document class from another class?
There is a function in my document class that I need to call from inside another class. How can I call myFunction from inside OtherClass? Or refer to myVariable from inside OtherClass?
package {
import flash.display.Sprite;
public class DocumentClass extends Sprite {
public function DocumentClass():void {
_init();
private function _init():void {
var myVariable:int = 0;
function myFunction():void {
//The function I need to access
var myClass = new OtherClass();There's many ways to do it. On a case by case basis a strategy has to be chosen.
In your case, is there literally just one child class that's trying to ask the root class to run the function? Are a bunch of other classes also trying to get at this same function? Flesh out a really good description of what you want to do for a few suggestions.
For fun I'm going to assume other classes may want to call this function and at the same time be really simplistic in the approach by assuming the project is simple and bubbled events won't hurt performance. It doesn't sound like this is a particle situation.. In that case I'd send a simple bubbled event Main can read.
e.g.:
Main:
package
import flash.display.Sprite;
import flash.events.Event;
public class Main extends Sprite
private var _a:Sprite;
public function Main():void
addEventListener(Event.ENTER_FRAME, onEF);
// Called from BClass after added to stage (for event to propagate)
public function SomeFunction():void
// now that this is called, do what you want..
// I'm just going to remove _a (for no special reason)
trace("Main.SomeFunction() - called, removing _a (_b will GC eventually as well)");
removeChild(_a);
_a.removeEventListener("OMGEvent", _handleOMGF);
_a = null;
private function onEF(e:Event):void
removeEventListener(Event.ENTER_FRAME, onEF);
trace("Main.onEF() - Instantiating AClass");
// instantiate a new child, which also will load a child
_a = new AClass();
// listen for events bubbling
_a.addEventListener("OMGEvent", _handleOMGF);
// add to stage
addChild(_a);
// listen to _a to invoke function
private function _handleOMGF(e:Event):void
trace("Main._handleOMGF() - child sent OMG to Main, running Main.SomeFunction()");
SomeFunction();
AClass:
package
import flash.display.Sprite;
import flash.events.Event;
public class AClass extends Sprite
private var _b:BClass;
public function AClass():void
addEventListener(Event.ADDED_TO_STAGE, _onAddedF);
addEventListener(Event.REMOVED_FROM_STAGE, _onRemovedF);
private function _onAddedF(e:Event):void
removeEventListener(Event.ADDED_TO_STAGE, _onAddedF);
trace("AClass._onAddedF() - Instantiating BClass");
// first child on stage, load second child, which
// after it hits the stage will dispatch an event
_b = new BClass();
// we'll listen here for the event just for fun
_b.addEventListener("OMGEvent", _handleOMGF);
// trigger the ADDED_TO_STAGE
addChild(_b);
// listen to _b just for fun
private function _handleOMGF(e:Event):void
trace("AClass._handleOMGF() - Just heard OMG!");
// clean up
private function _onRemovedF(e:Event):void
removeEventListener(Event.REMOVED_FROM_STAGE, _onRemovedF);
removeChild(_b);
_b.removeEventListener("OMGEvent", _handleOMGF);
_b = null;
trace("AClass._onRemovedF() - I cleaned up");
BClass:
package
import flash.display.Sprite;
import flash.events.Event;
public class BClass extends Sprite
public function BClass():void
addEventListener(Event.ADDED_TO_STAGE, _onAddedF);
private function _onAddedF(e:Event):void
removeEventListener(Event.ADDED_TO_STAGE, _onAddedF);
trace("BClass._onAddedF() - Created, dispatching 'OMGEvent' with bubbles");
// dispatch (I extend Sprite, it supports events)
// Note: I set bubbles to true to bubble back to Main (default is false)
dispatchEvent(new Event("OMGEvent", true));
For ease, Example Source (saved down to CS5).
All parents of that child will receive the dispatched event. To use that tactic you'd need to be sure your event is unique (hence using 'OMGEvent') and not have a fiercly complex display list because all those parents of this child will receive this event as well. I find in 99% of the non-particle usage of this, it really just doesn't matter. It's quick and simple.
If you wanted to really direct it rather than bubble, you'd just remove the 'true' parameter from the dispatchEvent() and then each parent of that child would need to be told to listen for the event so it can keep relaying it up the display chain.
I do the latter quite often when a child affects the display of each parent in some way all the way up the display list, capturing custom events at each level, doing what's necessary.
Trace:
Main.onEF() - Instantiating AClass
AClass._onAddedF() - Instantiating BClass
BClass._onAddedF() - Created, dispatching 'OMGEvent' with bubbles
AClass._handleOMGF() - Just heard OMG!
Main._handleOMGF() - child sent OMG to Main, running Main.SomeFunction()
Main.SomeFunction() - called, removing _a (which marks _b for cleanup as well)
AClass._onRemovedF() - I cleaned up
Man, Adobe really needs to get a <pre lang="as3"> with some color coding/formatting. -
Document class Error #2136
Hi, in Flash CS3 I've this DocumentClass:
package {
import flash.display.MovieClip;
public class DocumentClass extends MovieClip {
public function DocumentClass() {
trace("document class created");
This actually works, but I want to have the possibility to re-instance the DocumentClass (because I want to restart a game and the Main class is the DocumentClass).
In the first frame I have:
import flash.events.MouseEvent;
btn.addEventListener(MouseEvent.MOUSE_DOWN, restart);
function restart(evt:MouseEvent){
var d = new DocumentClass();
But this code (I simplified my situation, but the result is the same) throws an error:
Error: Error #2136: The SWF file file:///E|/Documents%20and%20Settings/Pepper/My%20Documents/FlashDevelopment/PepperGame.s wf contains invalid data at DocumentClass/restart()/frame1()
What can I do to restart my game by calling the DocumentClass point of entry? Is this possibile?
Regards and thanks to everybody.When you apply a DocumentClass to an FLA, the code becomes a part of that document (just like putting the code on the first frame of the timeline). You aren't able to say "new DocumentClass()" in your code because it's essentially telling your application to create itself. Instead, you have two options. Firstly, add a function in your DocumentClass called "reset". Add in this function all the things that need to be reset (score, lives, position of objects). When you want to start the game over, you can just call the reset() function.
If you really want to "refresh" the whole SWF, you'll want to build a second SWF (a "shell") that acts as a container for your game. It would basically just load in the game SWF (and maybe save any global information). When you want to restart the game, just reload the SWF. -
Accessing object of the main class from the thread
Hi, I'm having problem accessing object of the main class from the thread. I have only one Thread and I'm calling log.append() from the Thread. Object log is defined and inicialized in the main class like this:
public Text log; // Text is SWT component
log = new Text(...);Here is a Thread code:
...while((line = br.readLine())!=null) {
try {
log.append(line + "\r\n");
} catch (SWTException swte) {
ErrorMsg("SWT error: "+swte.getMessage());
}Error is: org.eclipse.swt.SWTException: Invalid thread access
When I replace log.append(...) with System.out.println(..) it works just fine, so my question is do the log.append(..) the right way.This is NOT a Java problem but a SWT specific issue.
It is listed on the SWT FAQ page http://www.eclipse.org/swt/faq.php#uithread
For more help with this you need to ask your question on a SWT specific forum, there is not a thing in these forums. This advice isn't just about SWT by the way but for all specific API exceptions/problems. You should take those questions to the forum or mailing list for that API. This forum is for general problems and exceptions arising from using the "core" Java libraries. -
Starting a stream from document class
I've successfully made a client that can stream and receive video using the flash main timeline...but when i try to make it within a document class the client doesn't receive the webcams stream but I can play a .flv flawlessly......flash media admin console shows both streams but if I try to play the stream from the console it says It can't make a debug connection I have application.allowDebug=true......what is it about the document class that won't let me send and receive a stream ?
--calmchessI would like to know what will be the output of above
pasted code.Run it and see for yourself.
Any explanation of what is happening here will be
great.. i am getting started with threadsWhat don't you understand?
Have you read and practiced with static initializers to where you think you understand them?
Have you read and practiced with threads to where you think you understand them?
The explanations are in the various tutorials, the JLS, etc. If you're still not understanding something, you need to be specific about what you're seeing, what you expected instead, and why. -
Hello there!
I'm starting to work a lot with Classes, but I'm still reletively new to them. I wrote a "creature" class (which extends Sprite), and I have everything working nicely... except for when it comes to displaying the image of the creature.
In previous programs, I've been able to load external Bitmaps using the Loader class. However, this can only be done from the main timeline in Flash, right? Such as this:
var imgLoader:Loader = new Loader();
imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
imgLoader.load(new URLRequest("001.png"));
function done(evt:Event):void {
addChild(Bitmap(imgLoader.content));
Ideally, what I'd like to do is just have a function within my class. The function would contain the addChild statement, so I could simply do:
var MyCreature:creature = new creature();
MyCreature.loadImage();
However, I would be equally as happy if I could just load the Bitmap and return it from the class. Then I could addChild myself in the main timeline:
var MyCreature:creature = new creature();
addChild(MyCreature.getBitmap());
I've tried putting the Loader code in a function within the creature class, however it isn't working. It didn't return any errors, but it also didn't display anything, despite it containing the addChild statement. Using the trace command, it looks like its getting inside the function, however addChild doesn't do anything. Am I missing something? Is there a better way?
Here's the function in my creature class:
public function loadImage(){
var imgLoader:Loader = new Loader();
imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
imgLoader.load(new URLRequest("001.png"));
function done(evt:Event):void {
trace("It gets to this point just fine");
addChild(Bitmap(imgLoader.content));
Thank you!Sorry! Sure enough, I browse the web for hours, unable to find a solution, post a forum post, and then I find a solution.
http://stackoverflow.com/questions/5036650/as3-addchild-in-a-class
I simply forgot to add the addChild(MyCreature) in the main timeline. Duh. <3 -
Dear All,
is there any way that i can access function or member variable of aggregate class.
i am working in Visual Studio 2010
and making win32 dll with mfc Support. i am new in dll system. just learning and doing.
previously all in exe and i am working this like
CTestDoc*pDoc = (CTestDoc*)GetTestDocument();
somevar = pDoc->xDoc.mVar.GetValue ();
now i am trying to put all in dll. so getting problem
will i get help on this. thanks in advance.
below code is just an example.
for example
// dll 1
class aaa : public BaseClass
public:
int Index;
char *cName;
void doSometing()
if (GetCurBColor() == 125) // how to access GetCurBColor function of the
color = GetCurBColor();
long color;
// dll 2
class bbb :public BaseClass
public:
int Index;
long lSize;
long color;
void doSometing();
// dll 3
class DDD
public:
vector <aaa> va;
vector <bbb> vb;
int cura;
int curb;
long GetCurBColor ()
return vb[curb].color;
};// MFC doc/view support
/// in exe in document
class inExe
public:
DDD d;
void addB()
{ bbb bb;
bb.color = 152;
d.vb.push_back(bb);
bb.color = 122;
d.vb.push_back(bb);
bb.color = 1232;
d.vb.push_back(bb);
d.curb = 1;
void addA()
{ aaa aa;
aa.color = 152;
d.va.push_back(aa);
aa.color = 1232;
d.va.push_back(aa);
aa.color = 1542;
d.va.push_back(aa);
aa.color = 15;
d.va.push_back(aa);
d.cura = 2;
d.va [1].doSometing ();Dear All,
is there any way that i can access function or member variable of aggregate class.
i am working in Visual Studio 2010
and making win32 dll with mfc Support. i am new in dll system. just learning and doing.
previously all in exe and i am working this like
CTestDoc*pDoc = (CTestDoc*)GetTestDocument();
somevar = pDoc->xDoc.mVar.GetValue ();
now i am trying to put all in dll. so getting problem
What problem?
The rules of C++ do not change because some of the code ins in a DLL. But the classes in a DLL need to be exported. See for example
https://msdn.microsoft.com/en-us/library/81h27t8c.aspx
You should also supply a macro so that the class header can be used in both the DLL and the client. See for example
http://stackoverflow.com/questions/14980649/macro-for-dllexport-dllimport-switch
If you exchange memory between the DLL and the client (as your example will do, because of the std::vector content), you should also be sure to use the same version of the compiler for each module, and to dynamically link to the CRT.
I would also advise you to start with a less complicated scenario, with just one DLL.
David Wilkinson | Visual C++ MVP -
Hang Calling function after Document Class' Event.ADDED
I was trying to load an external SWF (that contains the below code in its document class) with the Loader class but i keep on receiving Error #1009: Cannot access a property or method of a null object reference. So i tried to use the event listener Event.ADDED in MyDocumentClass constructor of the external SWF to let the document class be part of the display list before i invoke createRandomGraph. But when i place createRandomGraph( ) inside onStageReady, The compilation process hangs. When i leave the createRandomGraph( ) inside the constructor, it works perfectly as stand alone but will produce Error 1009 if loaded within the loader SWF. Any ideas?
public function MyDocumentClass( )
this.addEventListener(Event.ADDED, onStageReady);
createRandomGraph( )
private function onStageReady(oEvent:Event):void
this.removeEventListener(Event.ADDED, onStageReady);
private function createRandomGraph( ):void
var cRandomGraph:RandomGraph = new RandomGraph();
cRandomGraph.x = 10;
cRandomGraph.y = stage.stageHeight - nH - 25;
cRandomGraph.setDimensions(nW,nH);
cRandomGraph.createGraphBackground();
this.addChild(cRandomGraph);use:
public function MyDocumentClass( )
this.addEventListener(Event.ADDED_TO_STAGE, onStageReady);
private function onStageReady(oEvent:Event):void
this.removeEventListener(Event.ADDED, onStageReady);
createRandomGraph();
private function createRandomGraph( ):void
var cRandomGraph:RandomGraph = new RandomGraph();
cRandomGraph.x = 10;
cRandomGraph.y = stage.stageHeight - nH - 25;
cRandomGraph.setDimensions(nW,nH);
cRandomGraph.createGraphBackground();
this.addChild(cRandomGraph); -
Accessing value in document class
hello i am trying to acces a value in the document class. but i can't get it to work.
what i have is:
can someone tell me how i should access the myArray value?
bomberman.as:
package {
import flash.display.MovieClip;
public class bomberman extends MovieClip {
public var myArray:Array=[]; //trying to access this value
public function bomberman() {
init();
//trace(document.docClass);
private function init() {
var square:Array=[];
for (var i:Number=0;i<11;i++) {
for (var j:Number=0;j<11;j++) {
var temp:grassSquare;
if (i==0||i==10) {
temp=new grassSquare(i*50,j*40);
addChild(temp);
square.push(temp);
} else if (i%2!=0) {
if (j==0||j==10) {
temp=new grassSquare(i*50,j*40);
addChild(temp);
square.push(temp);
myArray.push(false);
} else {
myArray.push(true);
} else {
if (j%2==0) {
temp=new grassSquare(i*50,j*40);
addChild(temp);
square.push(temp);
myArray.push(false);
} else {
myArray.push(true);
bomberman.fla:
import flash.events.KeyboardEvent
var User1:Player1=new Player1;
stage.addEventListener(KeyboardEvent.KEY_DOWN, User1.fl_SetKeyPressed);
User1.x=75;
User1.y=60;
addChild(User1);
Player1.as:
package {
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.KeyboardEvent
import flash.ui.Keyboard
public class Player1 extends MovieClip {
private var upPressed:Boolean = false;
private var downPressed:Boolean = false;
private var leftPressed:Boolean = false;
private var rightPressed:Boolean = false;
private var currentSquare:uint=12;
public function Player1() {
this.addEventListener(Event.ENTER_FRAME, fl_MoveInDirectionOfKey);
//stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_SetKeyPressed);
public function fl_MoveInDirectionOfKey(event:Event)
if (upPressed && this.y>=100 /*&&document.myArray[currentSquare-1]*/)
this.y -= 40;
upPressed = false;
currentSquare-=1;
if (downPressed && this.y<=340 /*&& this.myArray[currentSquare+1]*/)
this.y += 40;
downPressed = false;
currentSquare+=1;
if (leftPressed && this.x>=125 /*&& /*this.myArray[currentSquare-11]*/)
this.x -= 50;
leftPressed = false;
currentSquare-=11;
if (rightPressed && this.x<=425 /* && /*this.myArray[currentSquare+11]*/)
this.x += 50;
rightPressed = false;
currentSquare+=11;
trace(currentSquare);
public function fl_SetKeyPressed(event:KeyboardEvent):void
switch (event.keyCode)
case Keyboard.UP:
upPressed = true;
break;
case Keyboard.DOWN:
downPressed = true;
break;
case Keyboard.LEFT:
leftPressed = true;
break;
case Keyboard.RIGHT:
rightPressed = true;
break;i have this code now and it gives me a bunch of errors. could someone tell me what's going wrong ?
errors are in the red code.
C:\Users\Jannes\Desktop\dev\Player1.as, Line 25
1093: Syntax error.
C:\Users\Jannes\Desktop\dev\Player1.as, Line 27
1084: Syntax error: expecting identifier before this.
C:\Users\Jannes\Desktop\dev\Player1.as, Line 27
1084: Syntax error: expecting colon before minusassign.
C:\Users\Jannes\Desktop\dev\Player1.as, Line 28
1084: Syntax error: expecting rightbrace before semicolon.
C:\Users\Jannes\Desktop\dev\Player1.as, Line 31
1084: Syntax error: expecting rightparen before if.
C:\Users\Jannes\Desktop\dev\Player1.as, Line 31
1084: Syntax error: expecting identifier before dot.
C:\Users\Jannes\Desktop\dev\Player1.as, Line 31
1093: Syntax error.
C:\Users\Jannes\Desktop\dev\Player1.as, Line 33
1084: Syntax error: expecting identifier before this.
C:\Users\Jannes\Desktop\dev\Player1.as, Line 33
1084: Syntax error: expecting colon before plusassign.
C:\Users\Jannes\Desktop\dev\Player1.as, Line 34
1084: Syntax error: expecting rightbrace before semicolon.
C:\Users\Jannes\Desktop\dev\Player1.as, Line 37
1093: Syntax error.
C:\Users\Jannes\Desktop\dev\Player1.as, Line 39
1084: Syntax error: expecting identifier before this.
C:\Users\Jannes\Desktop\dev\Player1.as, Line 39
1084: Syntax error: expecting colon before minusassign.
C:\Users\Jannes\Desktop\dev\Player1.as, Line 40
1084: Syntax error: expecting rightbrace before semicolon.
C:\Users\Jannes\Desktop\dev\Player1.as, Line 43
1084: Syntax error: expecting rightparen before if.
C:\Users\Jannes\Desktop\dev\Player1.as, Line 43
1084: Syntax error: expecting identifier before dot.
C:\Users\Jannes\Desktop\dev\Player1.as, Line 43
1093: Syntax error.
C:\Users\Jannes\Desktop\dev\Player1.as, Line 45
1084: Syntax error: expecting identifier before this.
C:\Users\Jannes\Desktop\dev\Player1.as, Line 45
1084: Syntax error: expecting colon before plusassign.
C:\Users\Jannes\Desktop\dev\Player1.as, Line 46
1084: Syntax error: expecting rightbrace before semicolon.
package {
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.KeyboardEvent
import flash.ui.Keyboard
public class Player1 extends MovieClip {
private var upPressed:Boolean = false;
private var downPressed:Boolean = false;
private var leftPressed:Boolean = false;
private var rightPressed:Boolean = false;
private var currentSquare:uint=12;
public function Player1() {
this.addEventListener(Event.ENTER_FRAME, fl_MoveInDirectionOfKey);
//stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_SetKeyPressed);
public function fl_MoveInDirectionOfKey(event:Event)
if (upPressed && this.y>=100 && MovieClip(root).myArray[currentSquare-1]*/)
this.y -= 40;
upPressed = false;
currentSquare-=1;
if (downPressed && this.y<=340 && MovieClip(root).myArray[currentSquare+1]*/)
this.y += 40;
downPressed = false;
currentSquare+=1;
if (leftPressed && this.x>=125 && MovieClip(root).myArray[currentSquare-11]*/)
this.x -= 50;
leftPressed = false;
currentSquare-=11;
if (rightPressed && this.x<=425 && MovieClip(root).myArray[currentSquare+11]*/)
this.x += 50;
rightPressed = false;
currentSquare+=11;
trace(currentSquare);
public function fl_SetKeyPressed(event:KeyboardEvent):void
switch (event.keyCode)
case Keyboard.UP:
upPressed = true;
break;
case Keyboard.DOWN:
downPressed = true;
break;
case Keyboard.LEFT:
leftPressed = true;
break;
case Keyboard.RIGHT:
rightPressed = true;
break;
Maybe you are looking for
-
Blank page after posting a reply?
I'm getting a blank page after I post a reply. I have to go back to my bookmark for the whole forum manually. Is this a feature or a bug? (Im using Safari)
-
Permissions / Uninstall Snafu on MacOS 10.9
Preferences won't save claiming a permissions error. Disk Utility found no problem. Uninstall claimed need for Application Manager. Application Manager installation failed, directed to download Application Support Advisor. Application Support Adv
-
I wish iphone will have an app who can have a private messaging just like in Go Sms :(
its hard for me to hide my messages . I want my mesages to be in private. I wish there'll be an app for that :(
-
Templates properties grayed out
Hi, Not quite sure if this is the proper newsgroup for this question, but I'm sure you'll tell me ;). Today I upgraded to Contribute CS3 because a website i'm working on now will be maintained with it. In this website (which is currently only running
-
Writing Datalog Files with record length
How do I write a Datalog File with a record length of 128 int16s?