Actionscript 3 - Unable To Get Proper Class From Flash IDE
Aug 11, 2011
I'm trying to replace instances created by dragging and dropping into a MovieClip through Flash's IDE with actual classes so I can add them to a game loop and have them as actual entities. In other words, I'm trying to create a streamlined way to allow developers to visually add their entities to a platforming engine I'm working on.
This is my third attempt at it and I'm completely stuck.The code below loops through a movieclip that contains an exported symbol with a class linked to it named MyEntity. However, it loses its extension to BaseClass and thus doesn't move when compiled.
It inherits: MovieClip > BaseClass > MyEntity. However when compiled with the IDE it ignores BaseClass and just does MovieClip > MyEntity.
My code is designed to find and store the position of MyEntity, remove it from the container movieclip, add a brand new instance of it (with the base being proper) then set that new instance to the same position of the original.
for ( var i:int = 0; i < LayerInIDE.numChildren; i++ )
{
// first we want to get all the display objects in the layer
// these are objects that were placed from within the Flash IDE (ie. dragged and dropped into the MovieClip
var original:DisplayObject = LayerInIDE.getChildAt( i );
[code]....
This does not work.
It outputs Game.entities::MyEntity [class MyEntity] false. MyEntity is a proper class and DOES extend from BaseClass. However, the issue is the IDE weirdly removes the reference to the base class - as if MyEntity never had a base class. I cannot seem to recreate it as getting the reference to the class also returns that MyEntity never had a BaseClass. However, if I type in var newEnt = MyEntity(); instead of getting the class name through getDefinitionByName it works normally and extends from BaseClass.I need it to extend from BaseClass as that is the main class all entities in my game engine require to use.
View 2 Replies
Similar Posts:
Jun 22, 2010
I am writing an ActionScript class and I don't know where the standard place to put it is.In other words, where should I put the package in regards to the hierarchy? In flash.myname.mypackage? What is the standard naming convention? As you can probably tell, I haven't had a lot of experience writing ActionScript classes :)
View 2 Replies
Jul 15, 2010
I have a mediator that I've registered for a navigation page:
facade.registerMediator(new NavPageMediator(viewComponent));
I'm trying to retrieve that mediator on another page like so:
var navPageMediator:NavPageMediator = facade.retrieveMediator(NavPageMediator.NAME) as NavPageMediator;
However, that statement returns null. If I try to cast it using the NavPageMediator(facade.retrieveMediator(NavPageMediator.NAME)) syntax instead, I get a TypeError: Error #1034: Type Coercion failed: cannot convert com.website.mvc.view.page::NavPageMediator@237560a1 to com.website.mvc.view.page.NavPageMediator.`
I can't, for the life of me, understand why NavPageMediator@237560a1 would be unable to convert to NavPageMediator, nor what happened in between registering the mediator and retrieving it that caused this. Especially since trace(new NavPageMediator() as NavPageMediator); returns [object NavPageMediator].
Incidentally, and this may be part of my problem, I don't understand what the @hash at the end of the object is (@237560a1). Is it simply an internal identifier for that class instance?
Edit:Left a bit of important info: The SWF in which I instantiate and register the mediator is separate from the SWF in which I try to retrieve it.
View 1 Replies
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
Jun 28, 2010
C:alexflashportfolioimagesDualGallery.as, Line 15001: The name of package 'portfolio.images' does not reflect the location of this file. Please change the package definition's name inside this file, or move the file. C:alexflashportfolioimagesDualGallery.as
My class file is located here: C:alexflashportfolioimagesDualGallery.as
My class file is defined as:
package portfolio.images
{.....
My FLA is importing it as :
import portfolio.images.DualGallery;
Normally I use portfolio.classes and I have no trouble. My AS3 prefs are set to the alexflash folder.
View 1 Replies
Jul 13, 2010
I have a App.fla file on a path and a App.as file on the same path. On the Class field I put "App" and on the ActionScript Settings Source path there is "." which means the same path of the .fla file, right? I open the App.fla file and click on the little "pencil" icon in order to edit App.as but then Flash whether tells me there's no class file associated or it opens a new ActionScript file.
So I can't do nothing , I even copied all code into the App.as , and pasted into the new ActionScript file it generates when I click the little pencil button. It still cannot find the god damned class. A little detail, I'm using Mac OS X 10.6.2. I've been working full time with flash on a Windows and that never happened to me before. That hasn't happend to me on Mac either (though I have hardly used it to do FLASH/AS).
View 3 Replies
Mar 14, 2012
i am using xmllistcollection for displaying data in list. whenever i run my application data is display in list control, but this warning has displayed in console. How can i remove this warning warning: unable to bind to property 'xmlnode' on class 'XML' (class is not an IEventDispatcher)
View 1 Replies
Aug 24, 2011
I am developing a Jigsaw puzzle in Flash. I am developing a class for puzzle piece. The code of the PuzzlePiece class in given as follows.
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;[code]....
I will be choosing which mask to use based on users selection of puzzle piece.When I try to use traingular mask by adding puzzle.gotoAndStop(2) the swf just flickers. Thought the holder_mc and mask_mc are exactly of same dimension one comes below lower than other though I have not altered the position of the clips within a puzzle piece.If you want to take a look at my fla here it is https:[url]....How to go to a specific frame 2. Why is position of two clips inside the piece changing
View 1 Replies
Jan 29, 2010
I finally tried validating my website at W3C, and naturally I got 300 or so errors
As I'm knocking them out, I noticed a lot of these are from the flash embeds. Currently I'm using the traditional method[code]...
Turns out even though it still works, the <embed> tags are no longer necessary and consequently will not validate.
Tried searching around but all I could find were some pretty vague tutorials and looking at sources is nothing short of Greek at this point.
Can I get an example or two of how to properly "embed" an swf?
View 1 Replies
Apr 7, 2012
I'm wondering if there is a proper way to upgrade from Flash CS4 to CS5. What I did was just open existing CS4 project in CS5 and saved it as CS5. It seems to work but I'm wondering: did I miss something in the transition? Do I need to make additional modifications for project to work better in CS5?
View 1 Replies
Sep 22, 2006
I didn't see anything posted on this, hopefully these questions aren't repeats. So, in the tutorial, it shows how to define globals, import XML, import CSS, and load some external files into movieclips. My questions are:
1. How do you control the play order of the imported .swfs? For example, if I load my movie border/bg and it has action, then the menu with action then the main image which also has an action, how do I set up the movie clips to play in order?
2. When I import my bg swf, how do I scale it to 100% but leave the rest of the items unscaled?
3. Can certain parameters of the DropShadowFilter that gets assigned to "filtersArray" be accessed to alter the distance (as an example) so specific params can be altered for different movie clips?
I will probably add to this. The tutorial was so useful that I am trying to relearn my methodology, but there are some gaps.
View 3 Replies
Jun 23, 2010
Is it "better" to initialize AS3 class variables in the class constructor? Or can I just initialize them to their default value when I declare them at the top of my class? I ask because when there's a lot of class variables, it appears inefficient to declare them in one place and then initialize them in another when I could easily do both in the same place. It one option is better than the other,
[Code]...
View 2 Replies
Feb 21, 2011
I'm trying to figure out what's wrong with this code:
[Code]....
I have a sample XML file with two images. If I remove either of the items from the XML, it everything displays fine, but with 2 items in the XML, the first item doesn't show an image, but the second does (maybe the first is being attached in a position behind the second?)
View 2 Replies
Dec 9, 2005
I almost feel dumb posting this, but I am develpoing a project and seem unable to trace from within a class. It definatley helps to have this ability and I have yet to find a suitable work around.
View 9 Replies
Aug 20, 2011
I ran into some trouble trying to load a new image from the class other than the "document" class. Attach is a sample of what I'm dealing with. Loader.as is the document class. I can create an image fine from there but not from GamePanel.as.
View 2 Replies
Sep 13, 2011
I am trying to use "maxPauseBufferTime" property in NetStream class.I am using Adobe Flash Pro CS3. I have defined an object by the name nsStream of NetStream class. When I write nsStream and put a dot next to nsStream it shows me a drop down list of the properties of NetStream. However it doesn't show me maxPauseBufferTime property. I also tried the same with Adobe Flash Pro CS5. Even there the drop down list for nsStream doesnt show me the maxPauseBufferTime property.The adobe help page (first link that shows up when I google for as3 NetStream. Forum rules doesn't allow me to post the link here) indicates that this property is part of NetStream class.
View 3 Replies
Aug 9, 2004
I'm looking at the XML class. I would like to be able to access elements by name and the order they came in.
For example, if an xml document is structured like this:
<a>
<b>info</b>
<d>something</d>
<b>more info</b>
</a>
[Code]...
xml_object.childNodes.length will return the number of childnodes there are. But I don't see a way to get at the number of childnodes of a particular type. This will not tell me, for example, how many childnodes of type "b" that "a" has. I can't see Flash XML support being this sparse. Is there a built-in way of accessing the nth child of a node of a particular element name or am I stuck with accessing it only by number.
View 4 Replies
Aug 19, 2009
When using the class listed below, I am unable to add a CLICK function that will not break the piece. I want to add another tween on CLICK that clears all mcs off of the stage except the e.target, which will have a zoom applied to it... I get my trace fine, but then I am unable to CLICK again on that particular mc, and the proximity begins to break.
Code:
package {
// Import Flash classes
[code]........
View 1 Replies
Jul 12, 2010
I have a class called BgItem that I want many other classes to extend. But I also want to be able to use instances the BgItem class itself. Within the BgItem class file, I want to be able to detect whether the specific instance is of the BgItem class or an extension of it. I know I can detect if a class is in an object's chain of inheritance using the "is" operator, but how do I detect if a class is at the end of the chain?
View 5 Replies
Apr 7, 2011
I am getting the error: warning: unable to bind to property 'Description' on class 'Object' (class is not an IEventDispatcher)
this is only when the data is bound to a List as an ArrayList, though. I had it in a Datagrid before (just as an Array) and it did not cause any issue. I'm not expecting to be able to bind any data back to the class 'object' not even sure which object exactly it's referring to.
My list data-provider is an ArrayList.. populated by a result event from an SQL query contained in another class:
private function loadDayComplete():void
{
var Meals:Array = _day.MealResults;
[Code].....
The day class I have is a data holder to get all the data (from several tables) for a 24 hour span.. I have classes for each individual datatype for editing them. But I'm not sure do I even need to worry about the warning if I don't plan on editing the values? it completely spams the console though whenever I touch anything, so I really would like to get rid of it. I tried an object proxy as I saw described elsewhere but nothing changed. The text is in label fields right now anyway, which can't even be edited.
View 2 Replies
Oct 3, 2009
I have a Flash file that calls com.plaidfox.MainClass as it's document class (com/plaidfox/MainClass.as). This class has the following code:
ActionScript Code:
package com.plaidfox {
import flash.display.MovieClip;
[Code].....
This code works perfectly the way I want it to. However, I am having a very difficult time splitting this code up. What I want to do is take the function PlantGrass and place it in another action script file [URL] to help organize my functions and classes. I tried putting the PlantGrass function in the second file, but I can never get it to work.
View 6 Replies
Aug 21, 2007
I am unable to access variables written in a class file.
This is the class file:
class readXML {
public var modArray:Array;
public function setModule() {
[Code]....
When I access the getModule method from flash (on click of a button), I get modArray as undefined.
how I could get the data of modArray?
View 2 Replies
Dec 5, 2008
i have created a character.as class that links to an object sitting on the stage.
This class i have initialize var name;
i have created a button that uses on(release){}
the problem im having is, my button does not change the value inside the object.
for example:
my object has a variable called 'name' that holds the value "ayumilove"
and the button on the stage (once click and release) would change that name to "123"
i did 2 traces, before and after. the before trace is "ayumilove", and after trace is "123" However, after i click again (the 2nd time) , it still shows "ayumilove" then "123" shouldn't it be "123" and then "123" ? This shows that the name is not renamed, but overwrite back by the default value in the object.
View 1 Replies
Feb 16, 2009
i know its easy to override a function of a parent class, but I need to be able to override a function for a class on movieclip.. see highlighted code.
[Code]...
View 2 Replies
Sep 1, 2009
I've been trying to switch from AS2 to AS3 by forcing myself to use AS3 on every project and never revert to AS2 no matter what the problem may be. Doing this, I've learned a lot so far, and it has shown me that AS3 has the potential to be much more logical and easier to manage, but every once in a while I run into a problem in which research doesn't prevail.
At the moment I'm working on a project that uses the Union Platform. My goal is to make all control over User1's "Reactor" API managed by a single class.
Anyways, I've ran into a very limiting problem that I can't seem to get by. I can't figure out a way to call the root object and be able to call it's functions from a class!
Here's one of the methods that I've tried (No errors were reported, but it did not work) -
main.as:
Code:
package {
import flash.display.MovieClip;
import net.user1.reactor.Reactor;
[Code]...
As you can see, I tried to pass "this" as a MovieClip in hopes that I would be able to use the MovieClip's class functions. (Which is most likely very nooby and completely wrong since it's probably not considered a MovieClip reference, but what do I know?) Everything is fine, except the swf does not go to frame 2 when readyListener() is called. No errors are outputted either.
View 4 Replies
Sep 19, 2011
So I am trying to access a variable that is defined within my parent code from a class which has been called from my parent code. I am using this:Code:TileCode(parent).game_quests.add_quest(0);to try to access the game_quests variable (which is defined within TileCode). However, for some reason it is not picking that up. It is working for other variables which I have called and ran in a similar fashion
View 7 Replies
Feb 16, 2011
I am building an AIR application where I receive UDP messages from Max/MSP using the Socket class. When testing in an internal loopback environment ( messages sent from 127.0.0.1 at port 7400 ) I can see the UDP messages being sent, as in: I can receive the messages I'm broadcasting in Max/MSP by listening to port 7400.However, the AIR app throws IO errors when trying to connect ( via the Socket class, using Socket.connect ) to aforementioned IP and port and I for the life of me can't find out why the app has no access to the internal loopback sending UTP ( if for instance, I start a Apache server at the same IP but at different port, the Socket class connects immediately to that IP - it won't receive data of course, but at least it can establish a connection )I am thinking the problem lies outside of the AS app and is an internal networking issue, I'd like to know if someone has experienced a similar error ( I'm on OS X, btw ) as I don't think it's a security sandbox error ( as the event isn't thrown, and the application type is trusted ).
View 1 Replies
Dec 16, 2008
I am unable to unload content loaded by loader class.
View 4 Replies
Nov 28, 2008
i wonder why i am unable to access the public properties of this custom class the public var w:Number; and the Public var h:Number; i am tracing them and on an instance of the PreLoader() Class.. and ia m getting NAN;
View 12 Replies
May 29, 2009
I've got an object that contains a dozen or so fields I want to bind to form elements, so that I can use that object to send the data back to the server to be saved.
[Code]...
View 6 Replies