ActionScript 3.0 :: How To Access Instance Property Through Child In Main Class
Jan 23, 2011
I have make 3 classes objecthandler, box and nav. Nav is child class of objecthandler, I have make an instance of box into objecthandler and now I wanna access property of box through nav.
See the code:
Objecthandler class
package code{
import flash.display.MovieClip
import code.box
import code.nav
[Code] .....
View 1 Replies
Similar Posts:
Jan 15, 2010
I have a problem with the piece of code that's been annoying me for a week. It should be very simple but all my attempts at a solution somehow seem to get thwarted by an invisible hand that wants me to fail.Here is the scenario: I am trying to create an image strip consisting of image thumbnails. When one mousovers each image it should print its information (say a name) in a textfield.I created an image container class that loads the images through a url request, then an image strip class that receives an array with image names and urls and displays them in a row. So far so good.
However when it comes to showing the info I have no clue how to address which image is being pointed at. I put a variable called imageIndex inside my imageContainer object, then put all the created containers in imageStrip's for-loop inside an array called mgContainerArray. I created a for loop in my fla that goes through this array and assigns all those containers a mouseover event listener. What I'm stumped with is that there is no way I can access the imageIndex variable from my function to tell the code which image is currently being mouseovered. It keeps giving me an error.Here is the code:
Code:
for(var i:Number=0; i<myImageStrip.imgContainerArray.length;i++){
myImageStrip.imgContainerArray[i].addEventListener(MouseEvent.MOUSE_OVER,
[code].....
View 3 Replies
Jul 23, 2009
What should I do to make a non static variable accessible to only instances of the same class?
View 10 Replies
Aug 28, 2010
i have one main.fla, its document class is main.as. the code in main.as is package.[code]where val is the property of Loading class.so how can i access.
View 2 Replies
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
Aug 18, 2010
I have a movieClip with one frame on the timeline containing one child whose instance name is "myContent"I am using this function to swap "myContent" with any number of possible class instances.
Code:
function setContentAsClass(c:Class)
{
[code].....
View 2 Replies
May 4, 2009
I'm kind off oblivious as to what I'm doing wrong here... I have two classes: - Alley - AlleyCat
[Code]...
View 8 Replies
Jun 1, 2011
on my timeline i create a new instance of the class FirstClass with the following
code:
var firstObject:FirstClass = new FirstClass();
the class looks like this:
package {
public class FirstClass extends MovieClip {
public function FirstClass() {
[Code]....
On my timeline i would like to acces the x position of the object tempObject
View 1 Replies
Sep 5, 2010
I have a very serious issue and need to be fix ASAP. Kindly check [url]... it is a flash based website, there on main flash file which have all the navigations (menu tab), when user click on any tab its load a external swf according to that tab, that swf has flv player which take videos dynamically, If user click on the trailers tab its load trailers.swf which have the player and the playlist when the user click on the video of the play list its player that video but the problem is that if the video is still in loading process and the user click on another tab so the main.swf load the swf according to that tab but the audio of the previous video is running...
thats i m trying to make a function in the child.swf(trailers.swf) which will pause the video so i will call that function the other tabs, so if the trailers.swf is loading and user click on comedy so that function will pause the video of trailers.swf and play the comedy.swf, So kindly tell me how i will access the function of [url]...
View 5 Replies
Sep 14, 2009
I can't access the variables that I declare in the main timeline from a child.
I attach the child to the stage during runtime.
View 3 Replies
Jan 29, 2012
If I have three classes:
public class Example {
public function Example () {
}[code]............
You can see that the two last classes extend the first one, and both have the 'variable' property. In case that I have an instance of Example and I am sure it is also an ExtendedExample OR AnotherExtendedExample instance, is there some way to access the 'variable' property? Something like
function functionThatReceivesAnExtendedExample (ex:Example):void {
if(some condition that I may need) {
ex.func()
View 3 Replies
Nov 24, 2011
I have the following inheritance structure:
var environment:AvEnvironment = new AvEnvironment(...);
addChild(environment);
environment.addChild(new Terrain());
environment.addChild(new Player());
I am trying to access a public property from AvEniroments class through the Player class, however I'm getting an undefined property error (#119). I've tried the following:
this.x = AvEnvironment.xs // public property in this class
this.x = parent.xs
I've also tried something like this:
var ev:AvEnvironment = AvEnvironment(parent);
this.x = ev.xs
but I get a TypeError. Error #1009: Cannot access a property or method of a null object reference.
View 1 Replies
Aug 28, 2007
is there any way, within a class definition, to access the instance name of the class?as in, say you have a class "playerObject", and you instantiate an instance of it like usualplayer:playerObject = new playerObject();is there an inbuilt property or variable i can access within the playerObject class code to return "player"?if, in the constructor, i trace(this) it returns [object Object], i tried things like this.name, this._name etc, of course they didnt work...
View 4 Replies
Jul 2, 2009
I was wondering how do you access the stage property from a different class that's not the principal class tied to the fla? Essentially, I have main.as which calls another class menu.as, and I can't seem to be able to use the stage.stageWidth property from menu.as. What's the proper way to be able to use the stage property from any class? Do I have to import it separately each time?
View 2 Replies
Apr 8, 2010
I have a initApp.as which instantiates a class which needs to access the "currentState" property and the States array as well. However we cannot get this to work as we cannot see how we can access this information.
Within initApp.as currentState is accessed via "this.currentState". This does not work in the class which is instatiated within initApp.as. The following error is thrown:
"Access of undefined property currentState."
View 1 Replies
Jul 21, 2009
Say I have a variable that contains an instance of a class. Is there any way to return a "Class" object based on what type that variable is? I wish there was something like this:
[Code]...
I am able to extract the class name in text format, and even all items that it extends and interfaces, yet I cannot find any way to create a class based on I did find the function "getDefinitionByName()" and "getClassByAlias()", but if I understand correctly, you have to first register those definitions. Also, is it possible to extract usable Classes (not just display objects) out of externally loaded SWFs?
View 1 Replies
Feb 17, 2010
I am certain I am not getting some of the very basic principles of AS3.I have moved my game logic into the Mian class(as suggested by forum here).I am using eventDispatcher to announce that a pawn is clicked. However, when I try to get any information about "what" pawn was clicked, I keep getting the error: 1120: Access of undefined property event. (in Main.as).
[Code]...
View 3 Replies
Mar 3, 2011
My first experience is build an aquarium with a lot of fish swimming, and they can be clicked. When one of them is clicked we should receive a trace message saying ("I�m a Fish!"). To do this, I thought that the best way will be:
1- create a document class, named Main.as
2- create a base class, named Clicked.as
2- create a movie clip with a fish.
3- export the movieclip to actionscript. In the mc properties set Class as "fish" and Base Class as "Clicked".
View 6 Replies
Mar 1, 2010
i have a game that i want to put load screen on, which i created a separate class for. first the main class is initialized and in the constructor function, it does an addChild(loadScreen) which places an instance of the loadScreen MC on the stage. within the loadScreen is a "Play Button" that when a user presses this button i want it to continue startGame in the Main class. the way i tried it was Main.startGame from the loadScreen class, but that obviously does not work. is it possible to call a function from a different class.i have three files:
Main.fla
Main.as
loadScreen.as
the Main.as file:
Code:
package
{
import flash.text.*;
import flash.display.*;
[code]....
View 3 Replies
Sep 15, 2010
If an object, or say... a document class, creates an instance of a class (and stores it as a variable), and it doesn't pass any arguments to the constructor of the class, can that class object, by simply having a function of it called by the parent, tell who sent it that command/request?In other words, can a class object know who called it (such as it's parent) via a (seemingly) anonymous call?
View 1 Replies
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
Sep 15, 2010
If an object, or say... a document class, creates an instance of a class (and stores it as a variable), and it doesn't pass any arguments to the constructor of the class, can that class object, by simply having a function of it called by the parent, tell who sent it that command/request? In other words, can a class object know who called it (such as it's parent) via a (seemingly) anonymous call?
View 1 Replies
Jan 6, 2007
I spent my holyday in studing new Flash 9, very good, powerfull but I doesn't find anymore my root, in teory is transformed in stage.root but it doesn't work.I want to understand if I make a mistake in my code or in my approach.I make a simple example with a few object containers.In the firsts lines of the constructor of the mail class I create the style class named tf and then the interface class called interf.Here is my class
Code:
package test {
import flash.display.Sprite;
import test.tf;[code]....
how to get the tf1 Object that as to be in stage.root.mytf.tf1 as some documentation say? If you doesn't comment that line you have an error. Obviously you can carry with you the object because is a small object with a few nidification but It seems to me very very bad for performance and code.
View 2 Replies
Jun 15, 2011
I currently pass a reference to my model through the constructor to any class that needs it in my simple mvc pattern, this can get annoying at times when it starts to go deeper.
How do Classes such as LoadMax allow you from anywhere to simple import the class, and do something like addChild(LoaderMax.getContent("bg"));? Replicating this should surely be a good way to have my model work, without the complexity of big frameworks?
View 4 Replies
Dec 29, 2011
for my current project I am starting to work with AS3 and I have written a ClipManager class where I can define an MC like "mainView" during initialization like this:
clipManager:ClipManager = new ClipManager(mainView);
With my clipManager I can now easily load stuff into the mainView etc. The problem is that I want every button throughout the whole thing to access Class Methods of this instance to alter the mainView
View 1 Replies
Jul 29, 2009
I have a music.fla and i set document class its to com.music_ct in the music.fla, i have a movieclip with instance name :aaa.[code]
View 7 Replies
Apr 26, 2010
I have a movie clip with a dynamic text box with an instance name inside. The movie clip is linked to a class, but when I try to access that instance name through that class it just returrs null.
View 1 Replies
Oct 7, 2010
I have a child/ Background class there must call a metode in the main class.But this fail coms: BackGround.as, Line 35.1061: Call to a possibly undefined method resizeHandler through a reference with static type flash.displayisplayObjectContainer.[code]
View 3 Replies
Sep 17, 2010
I have one class which is assigned to dropBar MC:
ActionScript Code:
import src.DropDown;
var inheritanceDrop:DropDown = new DropDown(dropBar, 1);
[code].....
View 5 Replies
Oct 27, 2009
I have a class LoadXML which loads and extracts data from an XML file. I am using this data for my Main class by creating a new LoadXML class. I now want to use this data for my other classes but without having to create another new instance of LoadXML. Since global variables dont exist in A3, I tried creating get methods in LoadXML and then returning these values into variables in the desired classes.[code]
View 7 Replies