ActionScript 3.0 :: Passing Stage To Another Class?

Apr 4, 2010

I have my FLA with a Document Class. I also have one other class, that doesn't extend anything. am trying to pass the stage from the FLA on to my non-Document class. Obviously, the Document Class can see the main stage no problem, but having trouble passing that stage to an external class.I tried to pass it from Frame 1 in my FLA. I also tried to pass it from my Document Class to my external class, but not working like it should.Code:var passStage:TitleClass = new TitleClass(stage)Now, on to my TitleClass (non-Document class / external class)

Code:
package {
import flash.display.*;

[code].....

View 3 Replies


Similar Posts:


ActionScript 3.0 :: Passing The Stage Through Than One Class?

Mar 6, 2010

In my document class "Engine" I need to make my "Game Handler" class which is done in the constructor by using:

Code:
var Game:GameHandler = new GameHandler(stage);
As you can see, im passing the stage into it.. now in my GameHandler class

[code].....

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

ActionScript 3.0 :: Passing Variable From Document Class To Movie Clip Class?

Oct 12, 2010

i have a movie clip which is exported for ActionScript , i want to get a variable from the document class into the movie clip class i tried this but there was an error !!

ActionScript Code:
var main:Main=new Main();
main.txtScore.text="hello";

View 1 Replies

ActionScript 3.0 :: Passing Data From Document Class To Base Class?

Mar 1, 2011

I created a movieclip with a star. Then, I creates a document class and I named it as Main.as.

In that document class I wrote:
package
{
import flash.display.*;
public class Main extends MovieClip

[Code]....

I´m not posting here all the code, but you can easily see that I´m using x_origin and y_origin variables to keep the original position of the movie clip. I will use them to move the star back to the original position.
 
The problem is that instead of being 20 and 30 respectively, tracing them I see that they are both ZERO. So when I drop the star, instead of going to x=20,y=30 it moves back to x=0 and y=0. I´ve to get the star position relative to stage, but I can´t find anyway!

View 4 Replies

ActionScript 3.0 :: Passing A Variable From The Document Class Into A Custom Class?

Dec 28, 2009

I'm trying to create a class which will create a tween for several different instances of an object. I am creating the instances in the Document Class. The trick is, I would like to specify how long each tween will take.

Here's what I have so far:

DOCUMENT CLASS

ActionScript Code:
package {
import flash.display.MovieClip;
import mcCloud;

[Code].....

As you can see, I have a variable "myTime" which syncs the timer and the tween. This causes to tween to repeat and the clouds to continually scroll across the stage. How can I determine the var myTime at the time I create each instance of the Movie Clip mcCloud?

View 6 Replies

Passing Name Of Video To Be Loaded From Document Class To Another Class?

Aug 6, 2009

I've got a document class (EgoGame.as) and another class (Ball.as) which has been duplicated to deal with several different video pieces. Inside the document class is a list of 'if' statements which decide which video should be played. At the moment I'm doing it the old fashioned way whereby if the condition is true....it tells the relevant Ball class to gotoAndPlay a certain frame within the linked movieclip...

[Code]...

View 1 Replies

ActionScript 3.0 :: Passing Stage As A Parameter?

Nov 12, 2010

So I have a linked external class that has my actual code. On frame one of the flv I have the code:

ActionScript Code:
new main(this.Stage);
The actual main.as contains:

[code].....

View 2 Replies

ActionScript 3.0 :: Passing Variables To A Child After It Is On The Stage?

Sep 30, 2009

I am not sure if I'm being completely stupid here, so my apologies in advance. If I have an object on the stage for example:

ball:Ball = new Ball();
addChild(ball);

it already has .x and .y values as it is placed on the stage.Then I have some value inputs, such as force, angle etc.Now when I click an event listener I want it to activate a function in Ball that will move it from the values I have just set.My question is how do I carry those values across after the ball has already been place on the stage?

View 4 Replies

ActionScript 3.0 :: Passing Objects On Stage To Super()?

May 27, 2010

When invoking super() in my subclass, I can pass uints and strings as params to super, but passing a TextField instance that is on the stage of the library instance of the subclass fails. Why? Is there a workaround?

View 2 Replies

ActionScript 3.0 :: Passing Objects To The Main Stage?

Mar 15, 2011

I'm trying to pass the stage display container too my Engine class but I'm getting the error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.olly::Engine()
at com.olly::MainControl()

Here's the code:

I'm creating the the Engine in the main document class here:

Code:
public var MainGame:Engine;
public function MainControl() : void
{
MainGame = new Engine(stage);

[Code].....

View 1 Replies

Professional :: Passing URL From FLA To Class

Jul 24, 2010

I have a class that works with an external swf with play, pause and slider. Now that I have all that working, I'd like to be able to pass the URL of the external SWF to the class from the main fla AS. I managed to use a 'set' inside the class to retrieve the name, but it apparently doesn't trigger until after the external SWF gets loaded.

Code snippets follow:
CntlClass:
public var loader:Loader;
private var _urlName:String;
public function CntlClass() {
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, movieLoaded);
loader.load(new URLRequest(_urlName));
public function set urlName(value:String):void {
_urlName = value;
}

Main FLA file - other than a controller (cntl_mc) containing a play button, a pause button, and a slider, the only thing in the FLA file is this code in the first frame:
cntl_mc.urlName = "extswf.swf";

View 5 Replies

ActionScript 3.0 :: Passing Class To Xml?

Oct 24, 2009

I am making a game project using tiles. I want to ask bout the xml.

I know how to load an xml data into the stage by using one class from library

However, rite now, I have 3 customer_mc with class for each: char1,char2,char3

And i have this xml data called customer_xml that contents the customer name,order and payment. So far i know how to call one class and do a for loop but i cant find a way to call three classes and put it into the for loop.

function init(xmlString:String):void {
customer_xml = new XML(xmlString);
for (var i:uint = 0; i<customer_xml.customer.length(); i++) {
var customer_mc:char1= new char1();

[Code].....

how can i put three customer mc into the for loop? Do I put it in an array?

Second, I don't want it to be put randomly on the stage but only on the right corner of the stage. Is that mean, I put a precise coordinate for the customers mc?

View 0 Replies

ActionScript 3.0 :: Passing Value To Different Class

Nov 23, 2009

I have those 2 function inside a class named MenuScreen.as, What I want to do is send a value true or false to another class named Game.as.If the user clicked mouse icon the value must be true and if user clicked keyboard icon it must be false.[code]

View 11 Replies

Flash :: Get Stage.stageHeight Or Stage.stageWidth From Imported Class?

Jul 1, 2010

can you tell me a simple and clean way to pass the dimension of the stage to another class, imported in my documentclass?

View 2 Replies

Actionscript 3 :: Passing Custom Class As Parameter To Custom Class Where Parameter Class Not Constructed?

Jun 16, 2011

I have a custom class being constructed from my main class. In the custom class it has another custom class that is passed in as a parameter. I would like to strictly type the parameter variable but when I do, 'the type is not a compile type constant etc'.This, I understand, is because the custom class used as a parameter has not yet been constructed.It all works when I use the variable type ( * ) to type the parameter.I suspect this is a design flaw, in that I am using an incorrect design pattern.It is actually hand-me-down code, having received a large project from someone else who is not entirely familiar with oop concepts and design patterns.

I have considered using a dummy constructor for the parametered class in my main class but the passed in class also takes a custom class (itself with a parametered constructor). I am considering using ... (rest) so that the custom classes' parameters are optional.Is there any other way to control the order of construction of classes? Would the rest variables work?edit)in main.as within the constructor or another function

var parameter1:customclass2;
customclass1(parameter1);
in customclass1 constructor:

[code].....

View 1 Replies

ActionScript 1/2 :: Passing Coordinates Relative To Stage Into A Nested MC?

Jul 8, 2009

I am building a project where I have 15 'islands' inside one big 'ocean' movie clip. I created navigation buttons so you can explore the Ocean movie clip and look around the islands. my problem comes when i want to 'zoom into an island'
  
So basically on the stage i have a movie clip called- Ocean_mc, and inside it are 15 movie clips, one of them (for this example) is a movie clip called GreenIsland_mc.
 
when a user clicks the GreenIsland_mc it needs to expand and place itself centre stage, then when clicked again in needs to colaps back to where it came from. The problem is that when GreenIsland_mc expands it needs to expand to coordinates relative to the stage, but when I shrink it back again it need to find the original coordinates relative to its place inside the Ocean_mc movie clip.

[Code]...

View 1 Replies

ActionScript 2.0 :: Passing A Variable From The Stage To A Movie Clip?

Sep 13, 2011

I have a big bit of action script that I want to reuse on various frames. Rather than write it out on each frame I want to embed the script within a movie clip and embed that movie clip on each frame that it is required to be used on.

In order to do that I need to pass a different value into the movie clip.

Basically the script creates 20 pages on one frame, 40 pages on another frame and 60 on the last page.

This is the bit of code that needs to have the number fed to it:

ActionScript Code:
var myArray:Array = newArray(20);

The number 20 is currently set manually. I ideally want to write this within the movie clip:

ActionScript Code:
var myArray:Array = newArray(frameVal);

and on the stage I want to set the variable like this:

Frame 1:

ActionScript Code:
var frameVal:Number = 20;

Frame 2:

ActionScript Code:
var frameVal:Number = 40;

Frame 3:

ActionScript Code:
var frameVal:Number = 60;

The movie clip that contains my code has an instance name of "testStart"

how do I get it to pass the frameVal into the movie clip?

View 2 Replies

ActionScript 3.0 :: Passing Events Out Of A Class?

Apr 28, 2009

So I've created a custom class which makes use of a Sound object. The Sound object loads a sound from a URL, and I attach and event listener to it to see it when it finishes loading i.e. Event.Complete

MY question is this: how do I receive this event outside of the class? For instance, I want to be able to create an instance of my class somewhere else, load a sound and attach an event listener to my custom class that listens for the event thrown by the sound. Understandably, I don't want to make the sound object a public variable.

View 3 Replies

Actionscript 3 :: Passing A Font From One Class To Another?

Sep 16, 2010

I loaded a font.swf (in Flash CS5) and it works in the class I loaded the font into, but if I want to pass it to another class, how do I do that? I tried passing it as a TextFormat instance (with the format.font = my_loaded_font) but that doesn't appear to work...

View 2 Replies

ActionScript 3.0 :: Passing A Reference To Class

Nov 12, 2009

if i have multiple movieclips on the stage and i am writing a document class and in document class i import another class and i need to pass these movieclips to that class.

View 1 Replies

ActionScript 3.0 :: Passing Values To Another Class?

Feb 8, 2011

Passing Values From One Class To Another.

This this not seems a difficult tusk to understand.

I can able to connect classes to each other. But the thing is that, when I am going to construct some logic to load and hold xml data and only fetch the correct child object from it, I stumped.

Here is the starter:

I connect loadXML.as to Main.fla from Properties Panel.

loadXML.as
ActionScript Code:
package {
import flash.display.Sprite;

[Code].....

View 5 Replies

Actionscript 3.0 :: Video Class Passing Url Of Flv?

Feb 21, 2009

I have been trying to put the As3 video tutorial into a class which works fine if I keep the url of the file to play within the class. But I want to be able pass the url from the actual swf file... I have had limited success.

Here is the Document Class

Code: Select allpackage
{
import flash.display.MovieClip;
import flash.events.*;

[code]....

And in the swf I have this

Code: Select allvar v_url:VideoClass = new VideoClass("test.flv");

View 3 Replies

ActionScript 2.0 :: Passing Variable From One Class To Another?

Aug 30, 2007

well, i'm getting into flash classes, and i'm working on my first project using self written classes. but i got a question about variables.i've got a MC rad_container with the class Rad linked to it. By using class instances i can now send the variable from the MC to the class, and get it returned.but i want to use the same varhere's my class Rad

Code:
class Rad extends MovieClip {
public var ballKleur:String;

[code]....

View 4 Replies

ActionScript 3.0 :: Passing Url's For URLRequest() Class?

Aug 19, 2009

I am calling java servlets from flash using the following code[below is a sample Flash code for calling a java servlet in Flash which I am using]:

...bla ...bla
String url_String="http://localhost:8080/servlet/getViews";
var req:URLRequest = new URLRequest(url_String);

[code].....

View 6 Replies

ActionScript 3.0 :: Passing The Timeline To A Class?

Sep 16, 2009

I have the following class

Code:
package {
import flash.display.Stage;

[code]....

Which is not a document class. I wish to pass the stage of the main timeline into the class, say on frame 1

Code:
stop();
var c:CustomObject = new CustomObject(this.stage);

Is this the right way of passing the stage of the main timeline into another class?

View 1 Replies

ActionScript 3.0 :: Passing A Sting Into A Class?

Jan 12, 2010

I'm trying to pass a string from the main timeline into a variable within a class (public _myVar:String how i can acces the public variable within my class and populate it?

View 10 Replies

ActionScript 3.0 :: Var Not Passing From Custom Class

Jan 26, 2011

I have created a custom class. It seems to work (at least no errors), but when I create a button in the actual FLA that calls on the class, it doesn't change what I want it to change. Here is the class:

[Code]...

When I call for the class to make the button, it works. It also successfull calls the default.png from the class, but in the FLA the icon_retrofit.myIcon doesn't change the image to 'images/b.png'.

View 2 Replies

ActionScript 3.0 :: Flash Passing Var To The Other Class?

Apr 3, 2011

how to pass the value of a variable in class1 to class2?

View 1 Replies

IDE :: Acesssing Derived Class Children (stage Instances) From Base Class?

Jul 16, 2009

I'm slightly new to Flash CS3 + AS3 combo, so its more of a lack of practice question. My question stems from the problem described here http:[url].... . Note, its not the same problem, its a new one.The Problem ,So I have multiple library assets (which are on teh stage) and I want to assign similar functionality to all of them.

Attempt 1: So I create the n assets, create a custom class in AS3, link them to Flash CS3 and obviously enough it gives me the error that multiple assets can't be linked to the same class.Obvious enough to understand (well not completely, because from a programmers background it doesn't make sense).

Attempt 2: Same as attempt 1, but instead of linking all the assets to the same class I make the base class the same class, and let the derived class be dynamically created by Flash on compile time.So the linking works, but the problem is, in my base class I have a method which does something (say an tween) on a child of the library asset. So if the assets on the stage/library are called asset1, asset2, asset3 (same name for asset name, class name, id name), each of them has a sub-movieclip called ... say 'foo'. now if I manually wrote a class for each asset, I could do 'this.foo' to play with the sub-movieclip. However since this functionality is in the parent class, I'm unable to do it.

P.S. If you're form a programming/OOP background, its basically a abstract class problem. My Base class knows how to doSomething(), but it needs aSomething, which is defined in the Derived classes. However I found out that AS3 classes don't support virtual(C++ )/abstract (Java) in the true sense of the word (unless I missed some obvious documentation).

View 3 Replies







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