ActionScript 3.0 :: Referencing Stage From External Class

Feb 14, 2009

I'm having problems referencing the stage from an external class. I've tried :
Code:
stage.addEventListener(MouseEvent.MOUSE_UP, onUp, false,0,true);
And also
Code:
MovieClip(parent).addEventListener(MouseEvent.MOUSE_DOWN, onDown, false,0,true);
But no luck. Can I not do this? I'm making a pencil class that I want to be able to reuse. I also tried "this" and while it didn't throw and error, it didn't work either.

View 9 Replies


Similar Posts:


ActionScript 3.0 :: Referencing Object On Stage From An External Class?

Sep 6, 2011

I have a media player that I am codging together, one that will play either videos or MP3s depending on the variables it is passed. The video player part works fine. The MP3 player controls are all actual physical MCs on the stage; each one has its own AS class file as part of the package, but there is also a lot of AS that is happening in the main FLA as well. Messy, I know, but it mostly works great.

The MC on the stage in the main FLA is properly linked to the class file via Actionscript linkage, and the control itself works. However, I am trying to make some aspects of the control respond to variables that are set within the AS on the timeline of the main FLA, and I cannot seem to pass values to the control no matter what I do.

[Code]....

View 2 Replies

ActionScript 3.0 :: Flash Referencing Object On Stage From An External Class?

Sep 6, 2011

I have a media player that I am codging together, one that will play either videos or MP3s depending on the variables it is passed. The video player part works fine. The MP3 player controls are all actual physical MCs on the stage; each one has its own AS class file as part of the package, but there is also a lot of AS that is happening in the main FLA as well. Messy, I know, but it mostly works great.The MC on the stage in the main FLA is properly linked to the class file via Actionscript linkage, and the control itself worksHowever, I am trying to make some aspects of the control respond to variables that are set within the AS on the timeline of the main FLA, and I cannot seem to pass values to the control no matter what I do.The following variable is set in the main AS:Code:var notPlayedYet:Boolean = true;I also have some flashVars being passed in from the html, and these I can reference with no trouble from the main AS - the relevant one is:

View 1 Replies

ActionScript 3.0 :: Referencing Stage Objects From Within Class

Sep 3, 2009

How to access stage elements from within a class.
buttonControls.as

Code:
package {
import flash.display.Sprite;
public class buttonControls extends Sprite {
// Navigation Hover Color
var hover = "0xF1E960";
var normal = "0xFFFFFF";
public function changeColor(object, color){
[Code] .....

View 2 Replies

ActionScript 3.0 :: Referencing Stage.stageWidth From A Class

Jan 7, 2009

I created a custom class in a .as file. I then linked this custom class with a symbol from the library in my .fla file. However, I can't reference stage.stageWidth in my custom class file. I get a null object error.

I think this happens because the custom class file is associated with a symbol on the stage and not the stage itself. For example, if I set the fla file's Document Class to the name of my custom class I can reference stage.stageWidth in the custom class. But I don't do this because I am creating multiple instances of the symbol on the stage. In order to do that properly i found I have to set the class in the properties panel of the symbol to the underlying class which then defines how each symbol behaves.

Under this type of linkage, is there a way to reference the stage width from the class? I've tried root.stage.stageWidth and parent.stage.stageWidth to no avail. I also made sure to import flash.display.* in my custom class. Below is the code for my .fla file and my .as file. In the .as file you'll see the line "x = Math.random() * stage.stageWidth;". This is the line giving me problems. I could hard code it, as I do for the y variable on the next line, but I'd prefer not to in order to keep the code flexible.

[Code]....

View 3 Replies

ActionScript 3.0 :: Referencing Stage From Within MovieClip Or Class

Dec 9, 2009

I'd like to know how I can reference root stage values from within a movieclip, or even worse, from a class. For example, I have a class called Bground.as. It does stuff, according to current stage size - so if someone were to resize the window/browser, Background updates in real time and does something fancy while it's at it. To do this "fancyness", I need stageheight and stagewidth. However, simply pointing to them does not work.

Here's the simplified ActionScript Code:
package klaseFP{
// imports
import flash.events.*;
import flash.display.*;
public class Bground extends MovieClip{
[Code] .....

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at klaseFP::Bground()
at FullScreen_03_fla::MainTimeline/frame1()

Background works as a document class, works perfectly in fact. However, if I use it as the class of a library object, error 1009 shows up. Same thing happens if I simply put the code into the timeline of the library object - stage referencing simply causes it to break. So, how do I dynamically change the values of variables in Background, according to values in the main movie/app?

View 2 Replies

ActionScript 3.0 :: Flash Button Class Referencing/controlling External MC?

Feb 2, 2011

I have this following class attached to some of my buttons to simply control the roll over and out states, as well as the click event. But i want to use the same class on my buttons but would like to control a movieclip outside of the button somewhere else on the stage etc.

put simply: Clicking my button 'moveLeft' will move a movieclip left let say:

[Code]...

View 2 Replies

ActionScript 3.0 :: Referencing Stage Within Custom "Global" Class

Jan 25, 2010

I haven't gotten a handle on coding classes and the appropriate syntax with all the "public" "private" "static" keywords, etc. Anyway, one thing I miss in AS3.0 is having "out-of-the-box" global variables and functions. I've read a lot of forums and articles about making a simple "MyGlobal" class that could hold variables and functions which could be called from the timeline as "MyGlobal.doSomething()" However, I seem to be running into a problem trying to reference "stage" from within one of the global functions... I imagine this is because "stage" is an instance property. I'm basically trying to add/remove an event listener to the stage whenever the global function "MyFunction" is called.

MyGlobal.as:

[Code].....

View 7 Replies

ActionScript 3.0 :: Referencing A Textfield Inside A Movieclip Class From Document Class

Feb 3, 2009

Ok, this is one of those walls that I know once I can jump over it, I will be a much happier developer again.

I've done tons of reading, and think I have a firm understanding that the general consensus is that if you want to reference something, it needs to be added to the display list, using addChild().

I hate to be defiant, but what if I don't want to?

Or at the very least, what if I want to add a movieclip class to the stage using addChild, and then reference objects inside it?

It is much easier this way than what most people recommend - adding 15 objects via addChild, then setting the x and y for the, etc.

That said, I'm all about using classes and using as3 the way it was meant to be used. So what this is, is a best practices question I guess.

HERE ARE THE STEPS I'M TRYING:

- Create new flash document

- Draw graphic symbol bg, with text field over it, select them, convert to movieclip symbol, and export class name "box", then delete it from stage

- Add document class .as file, which simply adds that class "box" from the library, to the display list using a simple addChild()

- Set a name for that box using box.name = "test" let's say

- Do a simple trace like the following - "getChildByName('test').textFieldName" - it shows up great

- So then, I'll now try to set the text by doing this - getChildByName('test').textFieldName.text = "yo";

That last line above, is what doesn't work. I know I'm referencing wrong, but how would a pro as3 developer, reference something on the stage within a movieclip class, from the document class?

View 1 Replies

Actionscript 3 :: Referencing Variable In Document Class From Another Class?

Mar 11, 2011

I need to increment an integer variable in a function within the document class upon transpiring event in another class. I can't seem to figure out how to call the function and reference the variable.

View 2 Replies

ActionScript 3.0 :: Accessing A Stage MC From An External Class?

Aug 3, 2009

im still trying to get into the whole oop thing but I still have some things that i dont understand.I have a movieclip on stage that i want to access using an external class that lives in a different folder.Is there a way to access movieclips on stage from external classes or that i have to create a connection between the document class and then send the movieclip instance using a class method ?

View 1 Replies

AS3:: Change Textfields On Stage From An External Class

Apr 29, 2011

I tried to change the textfield on the stage from an external class but it doesn't work.Thats the code how I tried it:[code]On my stage I got a textfield wich is dynamically with the instancename: "abc".But everytime I start the program flash tells me stage.getChildByName("abc") would be a null-object.

View 2 Replies

ActionScript 3.0 :: Accessing Stage From External Class

Feb 5, 2010

When I debug this, it gives me an error saying that it cannot access the stage because it's a null property.

ActionScript Code:
package {
import flash.display.MovieClip;
import flash.display.Stage;
import flash.text.TextField;
import flash.events.Event;
[Code] .....

View 2 Replies

ActionScript 3.0 :: Have An External Class Called Webcam.as On The Stage?

Oct 27, 2010

i have an external class called webcam.as on the stage I have two buttons. One called capture_mc and save_mc. I am new to working with external actionscript class. If someone could explain to me whatsI am getting lot of errors!!!!

Code:
1172: Definition flash.utils:byteArray could not be found.
1046: Type was not found or was not a compile-time constant: ByteArray.

[code].....

View 3 Replies

ActionScript 3.0 :: Adding MC From Library To Stage From External Class

Oct 14, 2009

I'm trying to create an application with an extensive user interface. I've come pretty far and decided I wanted to really take advantage of the object oriented features that AS3 has to offer.

I've started off by created a few classes: User, Background and Main. Main is the document class of course. In the document class I have a function "resetStage" that clears the display list of all children. This is because I have many layers of images making up the UI and they all show up at startup unless I remove them. Besides I want to see where the stuff is positioned in the Authoring tool so I don't want to just create movieclips and then delete them.

My issue is with my Background class. Basically what I want to do is create a new DisplayObjectConatiner called bgContainer or something and then put all the background stuff in it. (The main background image and a status bar image). Then add the bgContainer and its children to the stage. This should all happen when the object is constructed.
 
Main .as
---------------------
package
{
public class Main extends MovieClip
{

[Code].....

View 4 Replies

Flash :: Loading External SWF W/ Stage Reference In Class

Nov 17, 2011

I'm unable to load forces.swf (assume I can't edit it, as I don't have the source code) through an external swf, due to Stage reference in the base class how would I go about loading it (and any other possible SWF) without errors being thrown?

Here is a link to the problem I am trying to fix:[URL]..

View 1 Replies

ActionScript 3.0 :: Access Clip On Stage From External Class?

Feb 13, 2009

I've got a textfield on the main Fla called 'debug'i've created a Class which refers to the textfield, but when i launch my fla, it says:1120: Access of undefined property debug.

ActionScript Code:
package {
.....

[code]....

View 9 Replies

ActionScript 3.0 :: Accessing Property Placed On Stage Using External Class?

Apr 23, 2010

How can I access objects and modify their property that is ALREADY placed on the stage using external classes (AS file)? I 'm a newbie of AS3 and followed some tutorials about AS3 not long ago. For I learned scripting in AS3 can be done using AS file rather than script on Timeline. But I have a question. How can I "find" and "modify"the objects on the stage, or inside a MovieClip , in AS3?

For example, I have a file call Stage004.fla which have no document class linkage. I place the MovieClip "StageMain" which links the Stage004.as on the stage. StageMain has a textfield in it named "textFieldStage001". The Stage004.as is ran using "Event.ADDED_TO_STAGE" since StageMain is on the stage. I create another AS file WindowRename , to test can I modify the text in "textFieldStage001".

Then the famous error #1109 occurred.
"1119: Access of possibly undefined property textFieldStage001 through a reference with static type Class."

ActionScript Code:
package {
import flash.display.Stage;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.MovieClip;
public class Stage004 extends MovieClip{
[Code] .....

View 9 Replies

Actionscript 3.0 :: Modify Stage And Movieclips From External Class?

Jan 13, 2009

Still trying to wrap my brain about using classes in as3. I have my document class that calls another class that sets up buttons. I have the buttons working but I want them to play a movieclip on the stage when they are clicked. In AS2 I could just reference _root.mymc.play(); I am also having trouble setting up global variables which I think will have a similar solution. I think I read somewhere that I need to make a 'Globals' class inside my document class. Is this correct? I have tried doing that a few times but keep getting errors.

View 4 Replies

ActionScript 3.0 :: Loading External SWF With Stage Reference In Class?

Nov 17, 2011

I'm unable to load forces.swf (assume I can't edit it, as I don't have the source code) through an external swf, due to Stage reference in the base class.

How would I go about loading it (and any other possible SWF) without errors being thrown?

Here is a link to the problem I am trying to fix:

[URL]

View 14 Replies

ActionScript 3.0 :: Referencing Class Objects From Class?

Jun 19, 2010

I have an enemy on the stage that reads whether it's being hit by a bullet by a hittest. There's a for loop inside the enemy's class that looks for all the bullets and names the bullet that's hitting it "hitBullet". What I'd like to do have an easy way of seeing what type of bullet is hitting the enemy. I'm basically looking for something like

if (hitBullet == RegBullet) {
//do regular bullet dying
}else if (hitBullet == ClusterBullet) {
//do clusterbullet dying
}

, where RegBullet and ClusterBullet are classes. But I have no idea what hitBullet is equal to when a ClusterBullet or RegBullet hits it. I traced hitBullet to see what it would return and got "[object ClusterBullet]", but I'm not sure what that would be in the actual code.

View 2 Replies

ActionScript 3.0 :: Detect Keyboard Presses From An External Class On Stage?

May 29, 2009

I am working on a small section of my game and am attempting to detect key presses from an external class but I cannot get it to work. This code worked just fine when within the document class but now it's unresponsive. I'm not getting any errors, simply no activity whatsoever.[code]...

View 4 Replies

ActionScript 3.0 :: Link An Object On The Stage To An External Class File?

Jan 8, 2009

I have a dynamic textfield called neighName on my Flash stage. I also have a movieclip that I call a region on my stage. When I mouseover the region, I want a word to display in a little popup *and* I want some text to display in my textfield. I have an external .as file for handling the region. I can make the code "see" my region, but I can't seem to make it see my textfield, although no errors are being thrown.

View 1 Replies

ActionScript 3.0 :: Detecting Keyboard Presses On The Stage From An External Class?

May 29, 2009

I am working on a small section of my game and am attempting to detect key presses from an external class but I cannot get it to work. This code worked just fine when within the document class but now it's unresponsive. I'm not getting any errors, simply no activity whatsoever.Here's the applicable code:

My document class:

Code:
package
{
import flash.display.MovieClip;
public class Engine extends MovieClip

[code]....

View 4 Replies

Actionscript 3 :: Load An External Swf To Main Stage From Instanced Child Class?

Apr 15, 2010

I am trying to get an instance of a class to the load an external swf and show it.So far I have the following:

1) I wrote a class that uses the Loader class to load an external swf "loadExtSWF".
2) I have a fla named "MainSWF.fla" that uses a document class "MainSWF.as".
3) I have the MainSWF.as file that instances "loadExtSWF" and calls loadExtSWF.startLoad to load the swf.

This almost works. The instance of loadExtSWF loads the external swf, but the swf is not displayed.If I replace the fla's document class with loadExtSWF (this has an empty constructor) instead of MainSWF, and run loadExtSWF.startLoad, then the external swf is loaded and displayed.[code]

View 1 Replies

Actionscript 3 :: Loader Class: Resize External Swf To It's Original Stage Size?

May 12, 2010

Here is my problem (unfortunatelly didn't find solution @google):I'm loading external swf[AS2] into main swf[AS3] using Loader class. The main swf is 800 x 600 and the external swf is 300 x 200.After adding the external swf to the main swf the external swf expands it's size from 300 x 200 to the main swf's size: 800 x 600.

View 1 Replies

ActionScript 3.0 :: Reference Movieclip Instance On Stage From External Class File?

Nov 21, 2010

I've been searching around all afternoon, and am pulling my hair out. 1) I have a movieclip instance on stage (simple graphical element that represents platforms for a hero to run and jump along). I have placed it on the stage with an external class engine.as and in this class it is called myPlatform and is an object of Platforms.as. The movieClip is called platforms and from a trace(myPlatform.name) the instance name is instance3.

2) I am attempting to access the properties of myPlatform in an Enterframe event loop in my character control and collision class (called hero.as)

Basically here is the bit of code I am trying implement within Hero.as :

[Code]...

This all worked when I was writing actionscipt within the FLA file, on the timeline frame 1. I simply don't know how to access myPlatform from within the external Hero.as class! Do I need to create a variable? Is there a really easy way to do this with some syntax/command that I have not learned yet?

View 3 Replies

ActionScript 3.0 :: How To Referencing The Stage

Feb 2, 2011

I'm trying to reference the stage from my view class(AsteroidSuppyView). The view is a child of the document class. I'm tryng diffferent ways to do this but i'm getting the error:Code:1152: A conflict exists with inherited definition flash.display:DisplayObject.stage in namespace public.my view class is:

Code:
package
{

[code].....

View 2 Replies

ActionScript 3.0 :: Referencing To A Class From Another Class?

Sep 27, 2009

I have a class called Circle and a class called ShapeFade, both with their own .as files. How do I add an instance of ShapeFade to Circle inside the Circle constructor? Like in the Circle file:

PHP Code:

public function Circle () {
this.addChild (ShapeFade);
}

Also, can I override a class function from the code window in the stage?

View 6 Replies

ActionScript 3.0 :: Class Can Add The Rectangle To The Root Stage Without Requireing The Instantiated Class To Be Added To The Stage?

May 3, 2010

I have a class called shapeC that only creates a rectangle and then addChild(rectangle);.  That class is instantiated on the main timeline.  Currently, the only way you can see that rectangle is to add the instantiated class to the stage via addChild(shapeC);.  My question is, is there a way that the shapeC class can add the rectangle to the root stage without requireing the instantiated class to be added to the stage?

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved