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.
Similar Messages
-
I am working with Windows Vista Business if that makes a
difference in this question.
I am testing a class file for NoScale called NoScale.as
I have created the class file attached.
I have saved the class file in the same location as the fla
file.
I put in the document.class box: NoScale
Whenever I publish, I receive the following error:
5008: The name of definition 'Main' does not reflect the
location of this file. Please change the definition's name inside
this file, or rename the file.
C:\Users\%UserName%\Desktop\Website\Reference Flas\NoScale.as
(Note: I have replaced my username with %UserName%)
I have attempted to put
C:\Users\%UserName%\Desktop\Website\Reference Flas\NoScale.as into
the document class box and I receive an error telling me that the
\'s are incorrect and are not allowed.I know that the classes are code that is prewritten so you
can use the functions within.
The answer to your question is No, I don't know what the
classes are doing because I am just beginning with AS3 and Flash 9.
However, my question is Why does my code work with no
problems without importing any of those classes into the code when
I don't put anything into the Document class: [ box ].
As soon as I wanted to give my flash header the ability to
resize itself, I found out that I had to create a .as or class file
with the above code in it to give it that capability. Once I did
that I found out that I had to use the document class box in order
to link that class file to the SWF. Once I created a proper .as
file named NoScale and typed NoScale into the document class box,
all of a sudden a ton of errors happen wanting me to include the
flash.blah.blah files. If I remove the NoScale from the document
class box and do nothing else, the project works just fine.
That is what I don't understand.
Wayne
Adding the following did fix the errors. Thanks.
import flash.display.LoaderInfo;
import flash.display.InterpolationMethod; -
Several Errors thrown when updating document class: 1046 3594 3590
1046: Type was not found or was not a compile-time constant: FullScreenEvent.
Warning: 3594: getStackTrace is not a recognized method of the dynamic class Error.
Warning: 3590: void used where a Boolean value was expected. The expression will be type coerced to Boolean.
Does anyone have any experience with these errors being thrown?
package {
import flash.display.*;
import FluidLayout.*;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import gs.*;
import gs.easing.*;
import fl.motion.easing.*;
import com.greensock.*;
import flash.events.MouseEvent;
public class Website extends MovieClip {
public function Website() {
/* Set the Scale Mode of the Stage */
stage.scaleMode=StageScaleMode.NO_SCALE;
stage.align=StageAlign.TOP_LEFT;
/* Add the symbols to stage
var bg = new Background();
addChild(bg);
var top = new top();
addChild(top);
var toprightoption = new toprightoption();
addChild(toprightoption);
//var middle = new Middle();
//addChild(middle);
var btmrightfooter = new btmrightfooter();
addChild(btmrightfooter);
/* Apply the alignment to the background
var bgParam = {
x:0,
y:0,
offsetX: 0,
offsetY: 0
new FluidObject(bg,bgParam);
/* Apply the alignment to the top */
var topParam = {
x:0,
y:0,
offsetX:0,
offsetY:0
new FluidObject(top,topParam);
/* Apply the alignment to the toprightoption */
var toprightoptionParam = {
x:1,
y:0,
offsetX: -toprightoption.width - 20,
offsetY: 20
new FluidObject(toprightoption,toprightoptionParam);
/* Apply the alignment to the content
var middleParam = {
x:0.5,
y:0.5,
offsetX: -middle.width/2,
offsetY: -middle.height/2
new FluidObject(middle,middleParam);
/* Apply the alignment to the btmrightfooter */
var btmrightfooterParam = {
x:1,
y:1,
offsetX: -btmrightfooter.width - 10,
offsetY: -btmrightfooter.height -10
new FluidObject(btmrightfooter,btmrightfooterParam);
private var currentlyShowing:MovieClip=null;
public function showModalContent(clip:MovieClip):void {
if (currentlyShowing!=null) {
removeChild(currentlyShowing);
currentlyShowing=clip;
addChild(currentlyShowing);
public function removeModalContent():void {
if (currentlyShowing!=null) {
removeChild(currentlyShowing);
currentlyShowing=null;1. import the fullscreenevent.
2. click file/publish settings/flash and tick "permit debugging" to see which lines are generating the other two errors. -
Error #2136: The SWF file
I am trying to learn how to use classes.The book i am using gave me this example.
In Vechile.as
package{
import flash.display.MovieClip;
import flash.events.Event;
public class Vehicle extends MovieClip{
public var _gasMileage:Number;
public var _fuelAvailable:Number;
public var _milesTraveled:Number =0;
public var _go:Boolean;
public function Vehicle(mpg:Number=21, fuel:Number=18.5){
_gasMileage=mpg;
_fuelAvailable = fuel;
this.addEventListener(Event.ENTER_FRAME, onLoop, false,
0, true);
public function onLoop (evt:Event):void{
if (_go){
_fuelAvailable--;
_milesTraveled+=_gasMileage;
if (_fuelAvailable < 1){
this.removeEventListener(Event.ENTER_FRAME,
onLoop);
trace(this, _milesTraveled,_fuelAvailable);
this.x=_milesTraveled;
public function go():void{
_go = true;
In the main.fla
In frame 1
var vehicle:Vehicle = new Vehicle(21,18.5);
addChild(vehicle);
vehicle.go();
when I compile it gives an output error.
Error #2136: The SWF file file:///C|/Users/Ravenwind/Documents/Main.swf contains invalid data.
at Vehicle/frame1()
I am stumped" I then assign Vehicle to document class box in the property box" Do not assign the Vehicle as the document class... remove it from there.
In the main file, if you didn't already create one, create a movieclip symbol (just draw a shape in it for now). Right click the symbol in the library and select the Linkage option. In the interface that appears, select the option to Export for Actionscript, and assign it the Class name "Vehicle" in the field labeled "Class"
Make sure you save the Vehicle.as file after you put the code into it and have that file in the same folder as your Main.fla file.
If you do the things I just described you should see an instance of the movieclip moving across the stage when you run the file. -
Document Class not work when I shift my MovieClip to 2nd Frame.
Hello,
All my content is at 1st frame of my FLA file...and I'm using Document Class... When I try to shift my content to 2nd frame, so I can use 1st frame for preloader.. but its not working...
This is my document class... Basically at 1st frame I'm loading external jpg image to a MovieClip..
Is it possible, I can **** my MovieClip and other content to 2nd frame of the timeline... ??? and Document Class work???
Thanks...
package com.ahmad.bg
//import all classes
import caurina.transitions.Tweener;
import flash.display.Loader;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageDisplayState;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.net.URLRequest;
public class MainClass extends MovieClip
//create variables
private var loader:Loader;
private static const IMAGE_PATH:String = "bgs/bg.jpg";
public function MainClass() {
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.addEventListener(Event.RESIZE, stageResize);
//load external image
loader = new Loader();
loader.load(new URLRequest(IMAGE_PATH));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, showImage);
pic.addChild(loader);
private function showImage(e:Event):void
try {
e.target.content.alpha = 1;
Tweener.addTween(e.target.content, { alpha:1, time:1, transition:"easeOutSine" } );
e.target.content.smoothing = true;
} catch (e:Error) { };
stageResize();
private function stageResize(e:Event=null):void
pic.x = 0;
pic.y = 0;
pic.scaleX = pic.scaleY = 1;
if ((stage.stageHeight / stage.stageWidth) < pic.height / pic.width) {
pic.width = stage.stageWidth;
pic.scaleY = pic.scaleX;
} else {
pic.height = stage.stageHeight;
pic.scaleX = pic.scaleY;
pic.x = stage.stageWidth / 2 - pic.width / 2;
pic.y = stage.stageHeight / 2 - pic.height / 2;
bottomNav.x = Math.floor(stage.stageWidth / 2 - bottomNav.width / 2);
bottomNav.y = Math.floor(stage.stageHeight - bottomNav.height - 0);If you have code in your main class that references specific movieclips on the stage, they have to be on every frame you plan on using.
If you have a movieclip named "pic" on frame 2, but you are referencing it right away in the main class, which starts on frame 1, then it is looking for a movieclip that does not exist until you move it to frame 2 -
TREX does not index all documents fro document class SOLARGNSRC
Hi all,
I've setup a connection between a TREX server (which is also used by a portal system) and Solution Manager. I've gone through the settings in SAP Note 750623 and I was able to create a index, the queue and even bypass the basic authentication in the preprocessing for document class SOLARGNSRC
According to everything I've read, this should be enough to be able to index all documents in Solution Manager and find them with Full Tex Search. But this doesn't work. From the 50.000 documents in de class (35.000 English and 15.000 German) only 6300 documents are passed to TREX. Most of them are German HTML links to help.sap.com. I can see in the trace files that the URL's to some documents in the content server are passed to TREX. I can open dthe document using the links but I cannot find the documents using the full text search which I think means that nothing was really indexed.
Questions:
1. Has anyone been able to succesfully index Solution Manager documents for full text search purposes?
2. Why are only 10% of the documents passed to TREX? Is there a specific setting for this?
3. Why does TREX use the Content Server HTTP links to index the documents and not the RFC connection?
Cheers
Marcel RabeYep, all lights green
SSR maintained. DRFUZZY as Search Engine (I have not tried Verity)
Return Code? Interesting, I don't get an return code when I trigger the Index/Deindex. I just see the hourglass for about 5 minutes (when I run it in the foreground) and after that its back to the way it was. No messages. Nothing appears in the application logs as far as I can see.
The program RSTIRIDX is scheduled in the background and runs every hour minutes for about 10 seconds without an error.
TREX Version 7.00.39.00
Five languages actived, including German and English. In SKPR07 under Indexed documents I can see that 300 German and 6000 English documents have status indexed.
No proxy server. Systems sit within the same network segment
Thnx for your help. I posted a message with SAP as well as this seems strange to me.
Marcel -
Document Class vs Timeline code differences...
I'm trying to hunt down some kind of class conflict I seem to be having when using TweeLite easing and found out the same code that errors in a document class works fine if I place it in the timeline.
Example - this works in frame one of the timeline:
import com.greensock.TweenLite;
import com.greensock.easing.*;
TweenLite.to(obj, 1, { x:200, ease:Bounce.easeOut } );
If however I make a very simple document class like so:
package
import com.greensock.TweenLite;
import com.greensock.easing.*;
import flash.display.MovieClip;
public class Main extends MovieClip
public function Main()
TweenLite.to(obj, 1, { x:200, ease:Bounce.easeOut } );
I get an error when compiling:
1119: Access of possibly undefined property easeOut through a reference with static type Class.
So what's the differences between using a document class and timeline code?Odd... seems to have been a caching issue. I renamed the class, rebooted, and deleted ASO files and now it's working. Funny thing is that I never need to delete ASO files before... any thoughts on why this would stay cached?
And, after rebooting I can make changes and don't need to delete ASO files either.
Thanks! -
Preloader in Document Class Help.
Hello,
I want to know that how can I add a Preloader to my existing document class. In my FLA all content is on 1st Frame. I'm loading an external image to a MovieClip which is on 1st frame and on stage. My document class is working fine but when i try to add any preloading script, its not working...
Can any one please help me in this regard..
A Garden of Thanks.
My Document Class is here... (This was also a tutorial which I'm using..)
package com.ahmad.bg
//import all classes
import caurina.transitions.Tweener;
import flash.display.Loader;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageDisplayState;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.net.URLRequest;
public class MainClass extends MovieClip
//create variables
private var loader:Loader;
private static const IMAGE_PATH:String = "bgs/bg.jpg";
public function MainClass() {
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.addEventListener(Event.RESIZE, stageResize);
//load external image
loader = new Loader();
loader.load(new URLRequest(IMAGE_PATH));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, showImage);
pic.addChild(loader);
private function showImage(e:Event):void
try {
e.target.content.alpha = 0;
Tweener.addTween(e.target.content, { alpha:1, time:1, transition:"easeOutSine" } );
e.target.content.smoothing = true;
} catch (e:Error) { };
stageResize();
private function stageResize(e:Event=null):void
pic.x = 0;
pic.y = 0;
pic.scaleX = pic.scaleY = 1;
if ((stage.stageHeight / stage.stageWidth) < pic.height / pic.width) {
pic.width = stage.stageWidth;
pic.scaleY = pic.scaleX;
} else {
pic.height = stage.stageHeight;
pic.scaleX = pic.scaleY;
pic.x = stage.stageWidth / 2 - pic.width / 2;
pic.y = stage.stageHeight / 2 - pic.height / 2;
//my bottom navigation
bottomNav.x = Math.floor(stage.stageWidth / 2 - bottomNav.width / 2);
bottomNav.y = Math.floor(stage.stageHeight - bottomNav.height - 0);package com.ahmad.bg
//import all classes
import caurina.transitions.Tweener;
import flash.display.Loader;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageDisplayState;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.events.ProgressEvent;
public class MainClass extends MovieClip
//create variables
private var loader:Loader;
private static const IMAGE_PATH:String = "bgs/bg.jpg";
public function MainClass() {
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.addEventListener(Event.RESIZE, stageResize);
//load external image
loader = new Loader();
loader.load(new URLRequest(IMAGE_PATH));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, showImage);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, preload_image, false, 0, true);
private function preload_image(event:ProgressEvent):void
var per = int((event.bytesLoaded / event.bytesTotal) * 100);
pic.addChild(loader);
//make a textfield or preloader animation and assign this per to it.
private function showImage(e:Event):void
try {
e.target.content.alpha = 0;
Tweener.addTween(e.target.content, { alpha:1, time:1, transition:"easeOutSine" } );
e.target.content.smoothing = true;
} catch (e:Error) { };
stageResize();
private function stageResize(e:Event=null):void
pic.x = 0;
pic.y = 0;
pic.scaleX = pic.scaleY = 1;
if ((stage.stageHeight / stage.stageWidth) < pic.height / pic.width) {
pic.width = stage.stageWidth;
pic.scaleY = pic.scaleX;
} else {
pic.height = stage.stageHeight;
pic.scaleX = pic.scaleY;
pic.x = stage.stageWidth / 2 - pic.width / 2;
pic.y = stage.stageHeight / 2 - pic.height / 2;
//my bottom navigation
bottomNav.x = Math.floor(stage.stageWidth / 2 - bottomNav.width / 2);
bottomNav.y = Math.floor(stage.stageHeight - bottomNav.height - 0);
Oh.. Thanks.. its working now... Thanks aloooooooooooooot.....
Any other tip if you have a time to give me will be a greatful to you...
Thanks again for your precious time.. I've seen your Awesome Portfolio at your website.... -
Changing a document class to an imported class
Hello everybody!
My following document class is working fine. But, when I want to import it instead of using as a document class, it reports an error "1067: Implicit coercion of a value of type Class to an unrelated type flash.display:DisplayObject.". My class code is here:
package
import flash.display.Sprite;
import flash.display.Shape;
import flash.text.TextField;
import flash.events.MouseEvent;
public class Shapes extends Sprite
var square: Sprite = new Sprite();
var txt: TextField = new TextField();
public function Shapes()
square.graphics.lineStyle(4, 0xFF66CC);
square.graphics.beginFill(0x990066);
square.graphics.drawRect(250, 35, 175, 175);
square.graphics.endFill();
square.buttonMode = true;
addChild(square);
square.addEventListener(MouseEvent.CLICK, clickHandler);
txt.text = "A Child of the Square";
square.addChild(txt);
function clickHandler(ev: MouseEvent): void
if (square.numChildren > 0)
square.removeChild(txt);
My FLA file script is as below:
import Shapes;
addChild(Shapes);
Seeking help, please!You need to create an instance of the class Shapes and tha add this isntance
i.e. something like this
var shapes: Shapes = new Shapes();
addChild( shapes ); -
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; -
Access a mc or textfeild from a non document class.
Hey all.
This use to be simple in as2, but seems to allude me from as3. It used to be simple to access an object you put on the stage like a mc or dynamic text field by simply using _root.instanceName ect. Now I see references to making references to the Stage and such like:
private var stage:Stage;
stage = stageRef;
and I am still confused.
What I have going on is, I have placed a movieclip on the stage in Flash and gave it an instance name of Cell_mc.
I have a cusom class that extends MovieClip with the following imports
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.utils.Timer;
This Class is tied to a set of MovieClips in my Library.
I have a listener: this.addEventListener(MouseEvent.MOUSE_DOWN,pickUp);
And a function:
private function pickUp(event:MouseEvent):void
this.startDrag();
_interval = new Timer(100);
_interval.addEventListener(TimerEvent.TIMER,onInterval);
_interval.start();
And
private function onInterval(event:TimerEvent):void
//Set up hit test
this.hitArea(Cell_mc)
trace("hit");
I get the following error whenever I try to access an object I placed on the stage from anywhere other than the document class:
1120: Access of undefined property Cell_mc.
How do I access the cell_mc that is already on the stage from this non-document class?
Thanks guys.try:
private var stage:Stage;
stage = stageRef;
and I am still confused.
What I have going on is, I have placed a movieclip on the stage in Flash and gave it an instance name of Cell_mc.
I have a cusom class that extends MovieClip with the following imports
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.utils.Timer;
This Class is tied to a set of MovieClips in my Library.
I have a listener: this.addEventListener(MouseEvent.MOUSE_DOWN,pickUp);
And a function:
private function pickUp(event:MouseEvent):void
this.startDrag();
_interval = new Timer(100);
_interval.addEventListener(TimerEvent.TIMER,onInterval);
_interval.start();
And
private function onInterval(event:TimerEvent):void
//Set up hit test
this.hitArea(MovieClip(root).Cell_mc)
trace("hit");
I get the following error whenever I try to access an object I placed on the stage from anywhere other than the document class:
1120: Access of undefined property Cell_mc.
How do I access the cell_mc that is already on the stage from this non-document class?
Thanks guys. -
This might be tough for me to explain but here it goes:
I have a textField in Frame 1 of a swf. that swf has a
document class. When I compile that swf i can change the text in
the textField easily with textField.appendText(text);
However, when I compile a second swf which references that
document class that textField gives me an error on compile because
it does not exist in the document class of the swf it is referring
to. How do I solve that? When I compile I get an 1120:Access Denied
undefined property error. If I try to define the textField in my
document class like private var textField; I get a confilct with
namespace internal ....
SWF 2 has no idea SWF 1 has no idea SWF 1 has a textField in
its timeline when it is compiling.
Is there a way around this or do I have to create the
textField in my document class? There has to be a way to mix
sprites in a timeline and sprites in the document class.You need to do two things to get it to compile.
1. In Publish Settings -> ActionScript Settings UNCHECK
the Automatically declare stage instances box.
2. Declare your text field as public: public var
textField:TextField; -
Cannot debug after set a document class
Hi,
I have my flash project working without problems, I reach a
point that i must add a document class, but when i do that i got
the following error:
"You cannot debug this SWF because it does not contain
ActionScript"
The document class is in the same folder where the .fla file
is located.
Code compile without any error.
If I remove the document class my project work likes before.
For testing pourpouses the document class just do a
trace(....)
Is a bug in flash? Anyone face this problem before?
Im using flash CS3 on windows Vista.
ThanksHi,
Here is the code, hope this helps.
Thanks -
Document Class / Action Script Help
Dear all,
From a tutorial page, i manage to built this flash page with
xml capabilities. but when i add more scene to the flash page, i
have errors like this.
TypeError: Error #1009: Cannot access a property or method of
a null object reference.
at MyContent/init()
at MyContent()
TypeError: Error #1009: Cannot access a property or method of
a null object reference.
at MyContent/onComplete()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
How do i edit the "MyContent.as" file so that i can add more
scene to the flash.
I understand that, once i put the "MyContent.as" in the
document class, it will load immediately, is there any way to tell
it to load only in scene 2 (which is where the xml is needed).
Thanks. Any help will be very grateful.
Attach is the actionscriptother then defining the document class, can i "call up" the
MyContent.as (external script) when needed?
If this can be done, what must i do to add into the .fla file
and the .as file..
Sorry, i'm very new to AS3.
Thanks!!! -
Flash breaks randomly, won't compile, ignores document class?
I have run into a strange and annoying problem since updating to Flash Professional CS5.5 on my work computer.
Sometimes, seemingly randomly, Flash stops compiling things correctly. I Test Movie by hitting Cmd+Return and it just displays what's on the stage, frame 1. The document class is never initialized, no errors at all, no trace statements print out; it acts as if there is no code at all. After this happens once, it will continue to do this until I restart Flash, which fixes the problem. However, restarting Flash every 10 - 15 minutes is very annoying.
It seems to happen regardless of what project I'm working on or what state the project is in (i.e. if the code contains errors or not). All of our projects use external AS3 classes (no code on the timeline).
Has anyone else encountered this problem?
I'm using an iMac running OSX 10.6.8.I haven't run into this with CS5.5 yet, but it used to happen to me all the time in CS4. Simply moving the .fla to a different folder (and make sure it publishes to a new folder) solved the problem every time. In CS5.5, prior to the recent update to CS5.5.1, I would also sometimes have my exported swf not reflect changes I made. I fixed that by first saving as xfl, then resaving as fla.
Maybe you are looking for
-
How to invoke XML publisher report from APPS 11i forms
I have a requirement in oracle application forms menu where I need to call the XML publisher report when user clicks the menu item. I am using following two API's fnd_request.add_layout fnd_request.submit_request But I am getting the error message ja
-
Where can i find documentation on Forte 3.0?
Hi Folks! i'm lookin' for all the documentation about Forte for Java 3.0, CE about all the features, old and new can anybody tell me the right url to find it? thanks all
-
Print dialog box appears unasked when user opens Firefox and starts browsing. Occasionally comes back on but usually stays away after it's been closed a few times.
-
I forgot my answers of my security questions
hello i have a problem, i forgot the answer of my security questions, also there is no any link to use it to be able to reset them
-
hi ok this is my 2nd last resort to try and get this to work.... i burnt a dvd this morning and i forgot to remove it before i went to work. now i can't get it to eject...... i have tried turning it off and on, restarting, holding down eject buttons