ActionScript 2.0 :: Accessing Elements On The Stage From A Linked Class

Nov 28, 2007

I'm trying to link a clip to a class, and it goes well until I try to access MovieClips or TextFields placed on the stage within that clip from code in the class. My code is below; there is a TextField called output_txt on the stage within this clip.

class Main extends MovieClip{
public function Main() {
//trace("123"); <--if I replace the line below with this, it traces nicely
output_txt.text = "123";
stop();
}
}

View 3 Replies


Similar Posts:


ActionScript 3.0 :: Flash Accessing Stage Instances From .as File Linked To A Movieclip

Aug 28, 2010

i've been all afternoon trying to figure out a solution to my problem, and I can't seem to find it, or cannot implement it. Let me lay it out for you: I have an actionscript file linked to a movieclip. (movieclip:skate class linked: generic_skate).I have it set up that way so I can create an array of skates easily (i'm using a for loop to create them), and each skate has its own attributes (name, description, price and the image that is supposed to go on the deck)In the stage, i have three text boxes, one for the price, other for the name, and another one for the description.In the generic_skate class, I'm handling all the mouse events (in this case mouseOver and mouseOut.

What i want to accomplish is: when the user hovers over a skate, the info shows up in the text fields and when he hovers out, the info goes away. My problem: Since I'm doing all the mouse interaction in the class file, my guess is that I have to access the stage to get to the text boxes that are placed there to change its info or somehow create a "middle" man to do all the handling.

View 5 Replies

ActionScript 3.0 :: Accessing Stage Elements From Within Nested MC?

Apr 3, 2011

After quite some time I finally decided to pick up Flash again, this time taking the OOP route. I'm a bit rusty though, so I'm stuck on something pretty basic.Here's my Layout of relevant objects and scripts:

Stage > gunAmmo (TextField)
Stage > player (MC) > pistol (MC)
........ > player.as > pistol.as

As you might've guessed, what I'm trying to do is set the gunAmmo.text property from within my pistol class. I've tried using MovieClip(root).gunAmmo, stage, etc., but neither seems to be working. I sort of get why, but I don't know what the correct syntax is. (And yes, the TF's instance name has been set correctly.

View 2 Replies

Actionscript 3 :: Accessing GUI-created Elements In A Class Definition File?

Mar 18, 2010

I've used the GUI to create a rectangle that I turned into a button symbol (SimpleButton). I then edited the button so that it had 4 different button states and a text layer on top. I then created a class definition file for this object so that I could dynamically change the label text (the text layer) when adding instances of this button to the stage.

I was able to create and link a class file (DynamicButton.as) just fine, but when I try to access the text field that I created on the button, I get the error:

"Access of possibly undefined property btnLabel through a reference with static type com.examples:DynamicButton."

when i couldn't get that to work, I decided I'd try adding the TextField directly within the class definition file, using the following code:

package com.examples
{
import flash.display.Sprite;
import flash.display.SimpleButton;

[Code].....

The problem is that I can't seem to add the TextField to the SimpleButton, as it's not a display object. So, I tried adding it to the parent of the simple button (and I figured, I'd just place it exactly above the button). But then I get a "null object reference." error.

is there a way to access GUI-created elements from w/i a class definition file? How would I add the TextField to the button using only AS3 inside of a my class definition file?

View 1 Replies

ActionScript 3.0 :: Accessing An Object Drawn On The Stage In One Class From Another Class

Jan 6, 2011

I have created a class, call it Class1, that has various objects drawn on the stage (drawn in the IDE). It also has a function, called setColour, for changing the colour of those objects. The function works fine if I call it from within Class1.

Now I have another class, call it testClass1, that imports Class1 and calls the setColour function. First of all, none of the stage objects from Class1 are visible. Secondly, when setColour tries to modify the colour of an object, I get the error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.

This is the code for testClass1:

ActionScript Code:
package
{
import flash.display.*;

[Code].....

So, what is the problem? Is it possible to change objects that are drawn on the stage of an imported class?

View 3 Replies

ActionScript 3.0 :: Accessing The Stage From A Class Which Isn't The Document Class?

Jul 3, 2009

I'm being really dumb today and I know this should be simple.....How do i access the stage from a class which isn't the Document Class? For instance, I want to create a tween which takes in the parameters of the stage's width? So I've written.....

ActionScript Code:
var myTweenX:Tween = new Tween(this, "x", Regular.easeOut, this.x, stage.stageWidth, 60, true);

[code].....

View 4 Replies

Html :: Clickable SIFR Inside Linked Elements

Dec 28, 2009

My site in progress has some large graphical buttons that uses sIFR to display their headings. The structure looks like this:

[Code]...

I'm replacing the <h2> element with sIFR 3, revision 436. Everything works great until I activate sIFR. The font is replaced just fine, but the heading can no longer be clicked even though the rest of the button can. I tried to add another <a> inside the <h2> heading but that broke the whole layout since multiple <a> tags can't be nested. Is there a "correct" way to fix this or should I work around it with something ugly like a z-indexed clickable blank.gif on top of the whole thing? Or is there something else wrong that I've missed?

View 2 Replies

Accessing Stage From A Class Which Isn't The Document Class?

Jul 3, 2009

How do i access the stage from a class which isn't the Document Class? For instance, I want to create a tween which takes in the parameters of the stage's width?[code]

View 8 Replies

ActionScript 3.0 :: Accessing MC On Stage From A Class?

Apr 8, 2009

I seem to have a problem with accessing MC on stage. For example, if in my class I try to do something like this:
 
back_next_nav.alpha = .3;
 
I get the error: 1120: Access of undefined property back_next_nav.

View 1 Replies

Accessing A Stage Instance From A Class Other The Document?

Dec 19, 2010

I have a main document class with another class instanciated (mouse follower.as) within it. I want the mouse follower class to access a stage instance. How is this done?

View 1 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

Flash :: Accessing Buttons On Stage From Class?

Feb 7, 2012

I need to set properties of buttons on the main stage from the current class. How would I do this?

I have multiple buttons on my stage. Each representing a chapter in a movie (from frame x to frame y of the movie).

When I push one of them, the movie plays. When it gets to the end, it should continue to the next segment/chapter. This works, but now I need to highlight the current button, not let the button I pressed be highlighted forever..

View 1 Replies

ActionScript 3.0 :: Accessing An Instance On Stage From Within Another Class?

Jun 14, 2007

access one instance of a MovieClip on the stage (blue_mc) from within the class file of another MovieClip (red_mc).e.g. One instance of "Blue" on the stage called "blue_mc", and one instance of "Red" on the stage called "red_mc". Both symbols are linked to class files (Blue.as and Red.as).In Red.as, I set up a function to listen for a mouse down event. When this is triggered, I want to move the instance blue_mc. At the moment, though, I can't seem to get a reference to blue_mc.I've looked into the new stage and root properties, but even though blue_mc is on the stage, it cannot be accessed using stage.getChildByName( "blue_mc" ) either.

Code for Red.as:

Code:
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;

[code]....

View 6 Replies

ActionScript 3.0 :: Accessing Properties Of The Stage From A Class?

Aug 29, 2009

I am trying to access the x and y properties of the stage so I can set an objects' x and y properties to place it on the center of the stage:

this.x=stage.stageWidth/2;
this.y=stage.stageHeight/2;
The call to instantiate the object(*.fla):

[code]......

View 4 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 :: Accessing Properties From Stage In A Class?

Feb 28, 2012

I am trying to access a property that belongs to the stage, from a class. For example, let's say I add a textfield with an instance name of "magic_txt" on the stage. In the Document Class, I am able to access magic_txt and update the field like so:

magic_txt.text = "Magic Text"

However, since I would like to work in classes, I am having a difficult time figuring out how to access the property "magic_txt.text" from a class. I know I need a reference, but I am unsure how to set this reference.

I am coming from a strong background in Visual Basic, and in Visual Basic, the way to access a form property is to call the form name (dot) object. In actionscript, it doesn't seem to be as simple.

View 9 Replies

ActionScript 3.0 :: Accessing A Stage Resize Within A Class

Mar 3, 2009

I have a class and the class must adapt itself whenever the stage resizes.

Now something could look like this, but it won't work:

Code:
package {
import flash.events.Event;
public class ResizeClass {

[Code]....

View 3 Replies

ActionScript 3.0 :: Accessing MovieClip On Stage From Class

Apr 11, 2009

1.I have a MovieClip in the Library. There is a named and dynamic text box in the MovieClip. In Frame 1 of the .fla, I construct the MovieClip from the class StatusBoard and add it to the stage. There is one setStatus method in the class to set the text. This works fine.[code]

2.I have a bunch of buttons that I created from a class called LinkButton.as (they are MovieClips, not _btn buttons). FWIW, they are attached to other MovieClips, but they work fine. The trace output is fine. What I am trying to do is have the rollover change the text in the billboard.[code]

3. In lay terms, I used addChild to add a MovieClip with a dynamic TextField to the stagw and I want MovieClip buttons created from an .as class to be able to change the text on a rollover.What I can't seem to do is actually reference the billboard that I added using addChild from the .fla.The buttons work and trace the desired text, I can't seem to send that text to the billboard.

View 2 Replies

ActionScript 3.0 :: Accessing Stage Objects With In A Class

Aug 20, 2009

I am trying to learn how classes can interact with each other and I came across a problem I can't solve. On my stage I have a MovieClip called "myMovieClip".

[Code]...

View 14 Replies

ActionScript 3.0 :: Accessing A Checkbox On Stage From A Class

Apr 30, 2010

I have drawn a box on stage and turned it into a movieclip called sidePanel, within it I place a checkbox. My document class 'Main.as', ie the class called upon by the flash file, creates a class of name Class1. So we have .FLA (The Stage) -> Main.as -> Class1.as Now from the Class1.as How to get the checkbox status, ie checked or not, from within my class1.as ?

View 3 Replies

ActionScript 3.0 :: Accessing Movie Clip In Stage From Class

Nov 14, 2010

I have a movieclip in stage with instance name 'ts'.

I have a class Test.as

How should i refer to MovieClip 'ts' in stage from my Test class. Say for example I want 'ts' to gotoandstop at frame2.I tried root.ts but received a error.

View 4 Replies

ActionScript 3.0 :: Accessing MovieClip From Flash Stage In Class

Jan 10, 2011

What is the best way to accessing movieClip from a flash stage in AS3 Class? And what if the as3 class it's in a package, outside the Document Class?

View 4 Replies

ActionScript 3.0 :: Accessing Display Object On Stage From Another Class

Jun 8, 2011

I've googled this to no avail, I've only found how to manipulate the stage itself and not a display object on it,I have a movie clip on the main timeline with instance name displayName. I created a button that should change what frame displayName goes to (in order to...did you guess it?! diplay the Name of the button.So I am trying to write the code in a reusable fashion and have the buttons all linked to a class called GeoPuzzle. Inside GeoPuzzle I instantiate a touch event and run the code. However, the function has to be able to change displayName in the main part of the timeline and, of course, the compiler says displayName doesn't exist because I'm in a class and I'm talking about the stage.[code]How can I tell displayName to change it's current frame from within display object class?

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 :: Accessing Movie Clip In Stage From Class?

Nov 14, 2010

Iam new to actionscript 3.0. I have a movieclip in stage with instance name 'ts'.

I have a class Test.as How should i refer to MovieClip 'ts' in stage from my Test class. Say for example I want 'ts' to gotoandstop at frame2.I tried root.ts but received a error.

View 1 Replies

ActionScript 3.0 :: Accessing Stage From Function In Document Class

Dec 10, 2010

How do you access the stage from a function in a document class file? I tried a fairly simple:
ActionScript Code:
var main:MovieClip = new MovieClip();
addChild(main)
var _stage:Stage = main.stage;
trace(_stage);
The result was null.

View 5 Replies

ActionScript 3.0 :: Accessing A Movie Clip On Stage From Class

Feb 19, 2009

I have a Flash file with Movice Clips that are placed on the stage at author time. Let's say one of the clips is called "stageClipMC".[code]Tracing "stageClipMC" return "undefined". From this class, how would I access the clip on the stage? I have tried different variations on "MovieClip(root)" and "MovieClip(stage)" to no avail.

View 2 Replies

ActionScript 3.0 :: Accessing Stage Property From Document Class

Jun 11, 2010

I have a document class that is connected to a swf but for some reason I can't access the stage/root property. I can access all instance names that are on stage but trying to access stage will return "null". What's up?

View 5 Replies

ActionScript 3.0 :: Accessing Stage Variables From Class Object

Oct 11, 2010

I was wondering if there is a simple way to access variables from a class object, where the variables are not actually a part of that class. So if you had an array defined on the first frame of the stage, and added some elements to it, you could use the methods of the custom class to manipulate the array's data.

Stage Frame 1
Code:
var myArray:Array = new Array( "apple", "banana", "pear" );
var myClass:someFunctions = new someFunctions();
myClass.addValue( "orange" );
myClass.sortValues();
[Code] .....

It might not seem logical as to why you would ever want to do that, but it's a very simple example, and it's the means I'm after, not the result. I'm creating a list of functions available to execute by a user via an input field. To keep things simple I made them the methods of a class. The issue, however, is that these methods need to manipulate objects which are on the stage, added and removed by a separate controller class. Passing the objects by reference to the class as a parameter would not be viable with what I'm trying to do either.

View 4 Replies

ActionScript 3.0 :: Accessing Objects With Linked Classes?

Sep 15, 2010

So I have a menu built inside of Flash CS4 that has a graphic for a background and five text fields that sit on it for menu options. The whole thing is saved as a movie clip in the library. The text fields all have instance names like infoBtn and mapBtn etc. and the menu is already on the stage and linked to it's own class in the library. My problem is accessing those text fields on the menu from the class. I keep getting "Error #1009: Cannot access a property or method of a null object reference." and the menu doesn't work. But if I trace the infoBtn.text in the class it outputs the text that is in the text field. So the code is accessing it but it's still not working?

Code:
package classes
{
import flash.display.*;
import flash.events.*;

[cODE].....

View 0 Replies







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