Pass Instance Of Whole Class / Just Specific Values?

Jul 12, 2011

I am wondering if it's better to pass an instance of a whole class to another class or just specific properties of that class. For example if I want the height property of class A in class B do I pass just the height value into class B or the whole instance of the class and use classA.height in class B?

View 3 Replies


Similar Posts:


ActionScript 3.0 :: Access Values Held By A Class Instance From Another Class Instance?

Oct 14, 2009

I have to admit I pretty much ran away from Flash when AS2 came along and only used it for animation purposes over the last 5 years.So I'm having a major crash course in AS3 in Flash CS3 and I'm not enjoying it one bit. I'm getting maybe 10mins of finished work per hour as I try to figure out the limits and rules of AS3. Quite often it seems that AS3 simply can't do what I want it to. Anyway: Characterchecks.as is the main class and it loads a bunch of XML into four arrays. The file starts like this:[code]If I trace the value of, say, cc._Categories from the main FLA, it's empty. I'm guessing that the next line of AS in the main FLA doesn't wait for the previously called function to complete? (This may tie in to my next problem)My next step is that I want to display various things based on the data in the array. I have another class, Display.as which will hold all the functions to create the items on display. I thought it would be best for these to be a separate object. I wonder if I'm right?

So I declare an instance of Characterchecks in the main FLA and call it cc, and then run the functions to populate the arrays... Now I create an instance of Display and call it cd. How can I get functions in cd to see the values of the variables in cc? And if the main timeline can't tell that the functions aren't finished filling the arrays, how is cd supposed to know?I might be asking dumb questions, or maybe I'm doing things ***-backwards, I don't know. I'd appreciate any help, I really would. This whole thing has me at the end of my tether... being the most technically advanced person in my circle of co-workers and web design friends means I have no-one to explain why things need to be done a certain way or what the best way is.

View 3 Replies

ActionScript 3.0 :: Pass Main Class Instance?

Nov 27, 2009

I have a main swf that loads different swfs files, one of this swf files is the homepage with navigation items, how can I pass a reference to the loaded home.swf of the main.swf which contains the load methods?

I try creating a var in the home.swf class with the main.swf class type, but the home.swf give me errors that cant find other objects contains in the main.swf

View 6 Replies

ActionScript 2.0 :: Pass Parameters To An Instance Of A Class?

Feb 16, 2006

how i can pass parameters to an instance of a class using the Object.registerClass method. It seems i can only put the name of the class but no extra parameters.

View 3 Replies

ActionScript 3.0 :: Properties Of Instance Of Specific Class

Jan 29, 2009

I'm having a little trouble with the properties of an instance of a specific class. Here's and example of the code I am using:

Code:
package {
import flash.display.MovieClip;
import flash.events.*;
public dynamic class Circle1 extends MovieClip {
private var _root:Object;
[Code] .....

This is in the class code for Circle1. Now here is the error that is being displayed int he Output Box when I try to run the file:
Code:
TypeError: Error #1010: A term is undefined and has no properties.
at Circle1/eFrame()

Here's the code that creates the two class instances as children on the Main Time Line:
Code:
if (spaceDown) {
var newCircle1:Circle1=new Circle1();
addChild(newCircle1);
} if (enterDown) {
var newCircle2:Circle2=new Circle2();
addChild(newCircle2);
}
EnterDown is a defined variable for the key press of Enter, and spaceDown is a defined variable for the key press of Space.

View 8 Replies

ActionScript 3.0 :: XML Loader Class Instance And Assigning Values

Oct 6, 2011

I have a small issue with instantiation of an xml loader class. I'm using a standard way of loading external data and assigning it to "myXML" variable. My class uses event.COMPLETE for loader to make sure that data is fully loaded. Everything works fine until I make an instance of this variable in to my Main() class. The trace of "myXML" gives me null. It's like it didn't assign data on time. Since the onComplete event handler should take care of any delays it is hard for me to figure this out.

View 4 Replies

ActionScript 2.0 :: Rename A Class-instance That Has Already Been Created With A Specific Name?

Dec 9, 2004

Is it possible to rename a class-instance that has already been created with a specific name?

For instance:

// Step 1) Create and name class-instance
var myClassInstance_1:myClass= new myClass();
// Step 2) Change name of myClassInstance_1
?????

View 3 Replies

ActionScript 2.0 :: Pass Constructor Arguments Into An Instance That Extends The MC Class?

Apr 17, 2007

For example, I have the class Bullet, with a constructor: Bullet(start:Point, target:Point)constructor

But, if this Bullet class extends the MovieClip class, how do I pass start and target into it? Right now I am using attachMovie to create instances of the class. (They behave correctly with the static properties set by the constructor, but to be useful it needs arguments.)

View 3 Replies

Flex :: Static Constants Return Instance Of Specific Class?

Apr 29, 2010

I have a class ErrorMessages which holds all my error messages as static constants. So I could access them like ErrorMessages.PASSWORD_INVALID or ErrorMessage.PASSWORD_TOO_SHORT. I want to know if it is possible to have separate classes that hold subset of these constants and access them like ErrorMessages.PASSWORD.INVALID or ErrorMessages.PASSWORD.TOO_SHORT, etc. This way I can more structured static structure and makes it much easier to use autocomplete. I tried few different ways and couldn't figure out if this was possible..

View 3 Replies

ActionScript 3.0 :: Flex - Construct A Derived Class Instance From An Existing Base Class Instance?

Jan 22, 2010

I have a base class which is being created via remote_object [RemoteClass alias] from the server.I have other specialized classes that are derived from this baseclass, but serialization with the server always happens with the base class.The base class has meta data that defines what the derived class is, for example

[RemoteClass (alias="com.myco...')]
public Class Base
{

[code]....

View 2 Replies

Flash :: Unable To Convert An Instance Of A Class To An Instance Of The Class's Subclass?

Sep 15, 2011

I'm using a library that has a function that returns an instance of some class Engine.

I'd like to tack on some interfaces to Engine, so I subclass it class InterfacedEngine extends Engine implements AwesomeInterface. but when I change the code that uses the classes from this:

var engine:Engine = generateEngine();

to this: var interfacedEngine:InterfacedEngine = generateEngine();

It gives me a runtime error (elision mine):

TypeError: Error #1034: Type Coercion failed: cannot convert ...::Engine@1bc2bf11 to ....InterfacedEngine.

What about AS3 classes am I misunderstanding?

View 2 Replies

ActionScript 3.0 :: Sending A Class Instance Reference To A Different Class Instance?

Apr 14, 2011

I'm creating a little game - The player controls a character that follows the mouse. Pigs run away from the player, and the player has to get them all into a pen. To make the game a little more difficult I'm trying to add an enemy - wolves, that attempt to perform a 'hunt' method every x seconds. This method sends a reference of the wolf instance to Main (my document class) and Main then loops through the pigs on stage to see if there's any nearby. Now as far as I know this works - my problem is I'm unsure how to send the pig instance reference back to the wolf that called the hunt method, so it can then 'target' the pig, and then attempt to pounce on it.

This is my Wolf class:

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

[Code].....

View 7 Replies

Actionscript 3 :: Reference A Class Instance From Another Class Instance?

Dec 10, 2010

Quick question. I have been Googling this all morning, but it's either not there, or else written in a way that doesn't register. I am inclined to believe the latter, as this seems like it should be something completely trivial to me. I made a small Flash file using AS 3.0, and this is the first time I've really been able to stick to the OOP way of doing things and not hack together a mix of stuff from the timeline to get around not having everything work in the classes.

So I'd like to keep it that way, but one thing is eluding me: I can't call a method of an instance of another class (than the one I'm calling from) without resorting to "DocumentClass(root).instanceName.method." Intuition tells me there has to be a better way of doing this (like, without having to reference the document class every time I call another class instance's function; and CERTAINLY without having to use the word "root" - that just seems so Flash 5 to me. Does anybody have a better way of doing this that they can share?

[Code]....

View 1 Replies

Flex :: Pass The Array Values (not The Array Collection Values) To The Bar Charts Or Column Charts?

Sep 7, 2010

Is there anyway where I can pass the Array values (not the array collection values) to the Bar charts or column charts using flex 3.5...

here is the thing i want:::

I have array values like this,,

array1 = [23, 49, 40, 239, 20, 80, 39,49,120, 24, 31,41];

and i want to show these values on the Yaxis and months on Xaxis....

I have two Qns,

1) how can I pass this array to Bar chart or column chart.

2) how do I need to show months on Xaxis. beacuse I'm asking this regarding, I have kept a filters that even if we want to see some months or a particular months or perticalar span of months... there on Xaxis it need to change the months dynamically depending on the filters..... (for ex, on Xaxis the values should be (Jan, Apr, Jun,Oct) if i select the 3 months period filter....)

I have written a logic to collect the values of those particular months into an array, but not understading how to pass this array to Bar chart,, beacuse there I don't know what Xfield and Yfield to be given....

View 1 Replies

ActionScript 1/2 :: Pass Values From One Function To Another?

Apr 25, 2011

I am a middle school teacher and a newbie in Flash Actionscript. I am trying to create a countdown timer for use in my class during tests. The start and pause functions work as required, but not the pause button. When I click on the pause button, the timer is reset to 0:00:00.[code]

View 1 Replies

Flash :: Receive And Pass Values With XML?

Mar 8, 2010

My example imports XML and has an object rotating on stage. The rotating object is called enemy corresponds to ENEMY in the XML. How do I set the rotation variable to receive values from XML?

REASON: It seems more difficult to set up variables using external data. I want to understand it better.

rotation.fla

//LOAD XML
var myXML:XML;
var myLoader:URLLoader = new URLLoader();[code]......

View 2 Replies

Xml :: Flash Pass Values To Timer

Mar 11, 2010

My timer has three variables that I can trace to the output window,but don't know how to pass them to the timer. How to I pass the XML values to my timer? I want to test with an XML document, before I try connecting it to an XML socket.[code]

View 1 Replies

Python :: Pass Values To Flex App?

Jan 29, 2011

I am calling Python script from flex using HTTP service. How can I send back some values from python to flex app?

View 3 Replies

Flash :: Pass Querystring Values To Swf?

Sep 29, 2011

This is driving me nuts... Based on my research I should be able to pass QueryString parameters directly to a swf object like so: [URL] In the mxml oncreationcomplete method I have tried the following:

[Code]....

View 2 Replies

ActionScript 3.0 :: Best Way To Pass Values Into Flash?

Aug 13, 2009

I need to ask your advice, I am developing a site where music is uploaded by unsigned bands.I would like the player to be developed in flash.I would want an area where you can search for music and also would like the user to be able to generate play lists when they are logged in.I was going to put the filenames into the database and use PHP to grab them and display them and then use JavaScript to pass the values into the flash player.But I think this will not work on the play list.So should I get the list of tracks using PHP and use Flash to display them?Or should I be using XML and not put the filenames in the database or even both.I have spent a bit of time Googling this and thinking about how I am going to attack this so my question to you guys is what would be the most efficient way of doing this.

View 2 Replies

ActionScript 2.0 :: Pass Values Between Timelines?

Dec 5, 2010

I have a game with 3 levels and a reward page. I want to display the number of tries on the reward page. The levels and reward page have their own label within the main timeline. How can I pass the info from a level, to the main timeline and how do I retrieve it on the reward screen?

View 7 Replies

ActionScript 3.0 :: Rotation Around Specific X And Y Values?

Sep 13, 2009

I was wondering if there's a way to rotate a movie clip around a specific x & y value? I've been looking through tutorials but they all seem to use maths to control the positioning, but I think it's probably unnecessarily complicated for what I want to do. I have a number of shapes which I want to rotate around a single point.

This is what I have so far:

Code:
triangle1_mc.addEventListener(Event.ENTER_FRAME, rotateMovieClip);
function rotateMovieClip(e:Event)
{

[Code]....

View 3 Replies

ActionScript 3.0 :: Instance Or No Instance - Call A Function From Another Class?

Jan 26, 2009

I have a general / somewhat newbie question. Is it better practice to call a function from another class like so:

[Code]...

Does one way free up more memory or enhance performance?

View 5 Replies

Professional :: Pass Values And Focus From One Movieclip To Another?

Nov 8, 2010

I've created some dynamic movieclips. When I click and hold on one of them, I'd like a different library linked MC to appear, and the new MC to be draggable.
 
I can make the new MC appear, and I can make it draggable.  However, I'm a little lost when it comes to telling Flash to forget about the old clip, and make the new one the 'live' one.
 
In other words - after a click-hold, I want the new movieclip to be movable without the user having to mouse up and then click again.

View 4 Replies

Php :: Pass Values By Reference Inside A For Each Construct?

Jan 12, 2011

How do I pass values by reference inside a for each construct in AS3? Basically, I want something equivalent to the following code in PHP:

foreach ($array as &$v) {
$v = $v + 1;
}

This would allow me to change all elements of the collection $array through a single loop.

View 3 Replies

ActionScript 2.0 :: Pass Values SWF To HTML Page?

Sep 10, 2009

How to pass the values SWF file to HTML Page?

forexample:

i type the user name and Password in Swf file. the username and Password is

shown in Html page. how to send the username and password in Html page?

View 1 Replies

ActionScript 3.0 :: Pass Values To ENTER_FRAME Events?

May 3, 2009

HOW can I have a value shared between multiple classes? For example.

Code:
public var test:int = 3;

This works fine for the "main" class, but in the "animal" class, it can't access this variable. So if I wanted to set a rate of movement for an object, say animal, and I want to change it later in a different function, well, how? Any good guides to passing variables between functions and classes that are easy to understand? HOW can I pass values to ENTER_FRAME events, err...any events really. Example.

Code:
public class animal extends MovieClip{
public function animal(){
trace('crazy stuff happening');[code]....

Lets say I wanted to pass the Y value from the main class and not from within the animal function.

View 1 Replies

ActionScript 3.0 :: Pass Variable Values Between Functions?

Oct 16, 2009

How do you pass variable values between functions where the addEventListener is in the first function? I am trying to get the color value passed into my event handler. [code]...

View 6 Replies

ActionScript 2.0 :: Randomize A Specific Set Of Values In Array?

Dec 29, 2009

How would you randomize a specific set of values in a array? For example:

Code:
testArray[A , B , C , D , E]

I would like to Flash to only randomize value B C D.

View 6 Replies

Pass Link URL Values Into A Flash Object As A Parameter?

Apr 28, 2009

I have created a small banner for the homepage of a website for a company. The problem is that when they load the banner to their website the link no longer works. I have tested it myself and it works fine on my website. have the banner be clicked and open up in the same browser to another page on this website."define a way to pass link URL values into a flash object as a parameter."

"We need the functionality ASAP so can you start by working on this and creating a sample. It shouldn�t be too difficult as it is a fairly common requirement. Can you put together a basic example (it doesn�t need good graphics) that shows this idea working over " [URL]

View 5 Replies







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