Professional :: Access Variables And Classes Declared In Child?
Apr 16, 2010
I have a menu movieclip that has several buttons, each with listeners writtin in the movieclip's actions layer in Frame1. The script goes something like this:
If we have declared some variables on a particular frame, say frame 20 in the actionscript coding window, can we use these variables defined on a frame in a class? Is there something like a global variable which must be declared to do this?The class extends to movieClip and it has been encapsulated by a movieClip which is then put on the stage to run it when the corresponding frame plays.
I have this function in the parent class: ActionScript Code: private m_colors:Array; protected function set colors(clrs:Array):void { m_colors = clrs; }
Then, in my child class I want to call this as: super.colors = [15, 255]; But it throws an error, it says: Ambiguous reference to colors. If I do the same with a common function, not a setter one, then just calling it with its name in my child class works fine.
What I am trying to do is pull data from an XML file so that I can store paramaters for my FLV player (i.e. flv link, dimensions, video name, etc) I can get the data from the XML file and story it in a dictionary but I am unable to access the data from my main class. I know it has to be something pretty simple but I think i have been looking at it to long to see it.
// Main.as package includes.action{ import fl.video.FLVPlayback; import flash.display.*; import flash.events.*; import flash.net.URLLoader; import flash.utils.Dictionary; import includes.action.XMLData; public class Main extends Sprite[code]..........
basically with all my traces this is what I get back...
// Trace dataVIDOEXML COUNT: undefinedELEMENTS: nullMAIN:LINK: nullWe are in LoadXMLname - no get: mortgagename - get: mortgage
The trace for Elements and Main:Link should give me back the name of the video but as of yet its either returning NULL or undefined.
I'm working on a game. Yep. I have the main class where I control all the stuff that's packed in external classes. My current issue is that I listen for a mouse event to happen, and when the left button is pressed, I add a child to the stage.[code]...
However, I want to set all the stats of the bullet in an external class called "Rock". In the main class I just attach a movieclip to the stage, and the behavior of this MC is supposed to be controlled by the Rock class. The problem is I dont know how to access the bullet variable from the Rock class.
The error is as follows:1119: Access of possibly undefined property shiftX through a reference with static type flash.displayisplayObject.shiftX is declared in the first line of the movie clipFirst i check to see if the child doesnt exist and if it does I access it like so:getChildByName("ball"+ccc2).shiftX)
The external swf is located at:[url]....In the parent.swf, I put System.security.allowDomain(url....)When you click a button on the child.swf it's suppose to trace data from the parent.swf, but it returns undefined.What am I doing wrong? I MUST access data from the parent.swf
From the two .as files below, I get the following error when I run: 1119: Access of possibly undefined property importantNumber through a reference with static type flash.display:Sprite.
it's just some little white 'snowflakes' that fall from the upper end of the screen)
ActionScript Code: var timer:Timer = new Timer(30); timer.start(); timer.addEventListener(TimerEvent.TIMER, onTimer);
[Code]....
Now, this of course gives a run time error (access of undefined property snowSpeedX) due to the fact that snowSpeedX is declared in the function onTimer. The reason it is declared their is because i want it to change everytime and so each snowflake that falls, moves in the x axis with a different speed. If i declared the snowSpeedX variable outside of the onTimer function, i wouldnt get a different value for every snowflake, i would just get one.
So, how do i get the snow flakes to have a varying range of speeds?
On the main timeline I've got a movieclip, inside this movieclip I have some elements. Can I manipulate those elements from the main timeline through AS3? How?
Can I call a variable declared in a SWF, and call the same variable into another SWF, when i am loading it using XML.I am declaring a variable in the "Child movie", and am loading this "Child movie" into a "Parent movie" using XML. Can I retrieve the variable declared in the "Child movie" in the "Parent movie".
I have a problem accessing a variable which is to store a frame label. Code has been shortened to relevant parts. The following is on the main timeline.
I have a movieclip called "sections" which loads different sections of the website.When the first section is clicked thencontainerCenter is true and the evt.target.name is loaded in to the nextSection variable.Now if a 2nd section is clicked then containerCenter is false. It plays the sections movieclip. Within that movieclip it will eventually play and come to the following script:
PHP Code:
gotoAndPlay(nextSection);
For some reason it won't pick up the variable "nextSection" within the movieclip. I'm getting the error message "Access of undefined property nextSection". It has no problem when it is in the main timeline.I know you can't access a variable declared inside a function, but I have it declared outside the function as you can see above. I've just amended the variable from within the function.
Imagine the following setup. The main swf loads a child swf.In AS2 i would simply use _parent or _root to call the desired function. How can that be done in AS3?Can this still be done? Can I call a function on the main swf from the loaded one? How about the other way around, this time, from main to loaded swf?
i have problem with swfLoader in flex, when i close following code in click method i can easly add many swf to main application
<mx:VBox id="content" width="100%" height="100%" ></mx:VBox> public function doIT():void {[code]....
when i close adding those swfs in loop i have the same error, it looks like child apps couldn't access certain objects that were instantiated by another child app, so what can i do?
I've seen some discussion on how to load a child swf using swfLoader and accessing it's variables but I am wondering if it is possible to do this without adding any code to the child swf.Either accessing public vars or listening for funciton calls would work fine
I have a mainSwf in which I load an external swf, which loads an external swf.( a child of a child). I am trying to set the framerate via AS3 for the childs child by using stage.frameRate= 15;
It doesnt work when the children are loaded into the mainSwf. how to access the stage of a child's child? I have tried root, Movieclip, this but can not get it to work
In my library I have:A Sprite named Emily of base-class "Character" with a sub-sprite labeled "head" of auto-generated Class "EmilyHead".A Sprite named Jess of base-class "Character" witha sub-sprite labeled "head" of auto-generated Class "JessHead".
Flash compiles with the following warning: Warning: All instances named 'head' will be automatically declared as JessHead in symbols that use Character as their base class. In symbols that are linked to user-defined base classes, instances with the same name must be of the same type. And then the runtime error:TypeError: Error #1034: Type Coercion failed: cannot convert EmilyHead@3a0d1e81 to JessHead. at flash.display::Sprite/constructChildren() at flash.display::Sprite()at Character() I can turn of auto-declare stage instances in the Actionscript 3 panel, but then I have to manually add a public var for all sub-child's, such as the head sprite. But then at least everything works as expected. This is more setup than I'd prefer to do, but everything else about this workflow is very fast & easy. What can I do to sidestep this error, while keeping the same workflow?
Basically, I have a menu system for a website that is built on a three tier hierarchy. onclick event handlers load movieclips which contain the next submenu in my menu system. Each menu and sub menu is a series of movieclips with roll over, roll out and click eventlisteners applied to them to give them button characteristics.
However, I have hit an unforseen problem. I need to be able to control all the onclick event handlers assigned to all my buttons from one place, not in lots of different movieClips. I want to be able to add and remove different website content pages in one display object or else I fear that pages will start to appear to overlap as they are added within their specific sub menu movieclips.
I guess what I am trying to say is, can I control movieClip instances that are contained within a child object from my main timeline?
So i have a situation where i want to pass a object of a class say 'MyBigAwesomeClass' from a child to a parent. I import the class definition into both the parent and child. Now, if i load the child swf from a location that is relative to the location of the parent , all is fine, however the moment i load it using a full absolute path, it treats the definitions for 'BigAwesomeClass' in parent and in child as different and does not allow an object of the type 'BigAwesomeClass' to be assigned to an object of the same in the parent class.I am totally stumped, and have banged my head over ApplicationDomains, including using this code
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,swfLoaded); var context:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain); loader.load(new URLRequest(_file.url),context);
`i'have a problem with listening events dispatching from their child classes. for example i have contentManager object which is controlling content at the top level of stage. it has a imageGallery object and in the imageGallery objectthere ise a collectionLoader object which is loading images.
now i want to add one preloader to contentManager which always listen for ProgressEvent. when the progressEvent dispatched i want to preloader going to active. becouse there is another objects that are loading images or other kind of files. i think it is a good apporach to solve preloader issue. so my problem is, when collectionLoader object loading images with using queLoader. my QueueProgress event dispatches ProgressEvent evey time, but my preloader object stand at the 2 classes up level, doesn't percive this event.
I have a project which has a main swf file that is compiled with a bunch of classes. The main swf also loads in other child swf objects, created in the flash IDE, that happen to reference some of the same classes.
It seems redundant to have the child swfs include the main swfs classes, especially if I update the classes which means I have to recompile all the child swfs, not just the main swf.
Im using FlashDevelop 4.0 RC3 with Flex 4.6/AIR 3.1 to code the main swf, and the child swfs are flas made in CS5.
I was thinking of using SWC's, but I'm not sure how to incorporate that into FlashDevelops workflow. I tried the SWC export plugin but that doesnt seem to work very well, it attempts to export everything in the project and doesnt seem to offer me an option to be specific...
Surely there is a way to compile flas from the IDE and allow for classes to be used for compile type checking etc, but not actually include them in the compiled swf? I know with the flex command line compiler you can generate a link-report xml from the main swf then use that xml file to exlude classes from the compile of the child swfs, but I cant see how to do something like that when exporting swfs from the flash IDE.