Actionscript 3 :: Difference Between GetDefinition And GetDefinitionByName?

Jul 2, 2011

Can somebody explain what is the difference between getDefinitionByName and getDefinition inA AS3?When I load an external SWF I can't use getDefinitionByName because I get an Error #1065.

But using externalSWF_ContentLoaderInfo.applicationDomain.getDefinition works OK.So, why getDefinitionByName doesn't find the className?I mean, if the definition is inside the applicationDomain of the loaded SWF, why is not in the main SWF too? (I'm using Flex). I can't create new tags so I can't add the tags getDefinition and getDefinitionByName.

View 1 Replies


Similar Posts:


Actionscript 3 :: Loading A Class Using GetDefinition()

Jul 26, 2010

What I am trying to do is to use shared runtime library by loading a swf ('index.swf') which has numerous library objects which are named in sequence such as:

(orange1,orange2,orange3,orange4)
(red1,red2,red3,red4)

I am able to load the swf('index.swf') without any issues and even am able to load the right library asset, but I have to declare the full name as string such as getDefinition('orange1'). What I would like to do is to match first three letters of string and then run a for loop to load up all the classes that match the first three letters. I usually can do this by employing indexOf() method.

here is my code:

public function loadContent():void
{
ldr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, onloadHandler);

[Code]....

View 1 Replies

ActionScript 3.0 :: ApplicationDomain Getdefinition And Embedded SWF's?

Oct 21, 2011

I have been developing two seperate flash projects and the time has come for them to merge. To do this i have decided that, rather than try to mash the code together, i will simply use a loader to load and unload the second SWF as needed. My problem is that the SWF to be loaded uses:

Code:
var className:String = Entities[No];
var libraryDomain:ApplicationDomain = stage.loaderInfo.applicationDomain;
if (libraryDomain.hasDefinition(className)) {
var MyClass:Class = libraryDomain.getDefinition(className) as Class;
item = new MyClass();

[Code]...

This works fine seperately, but when the SWF is embedded into the parent SWF it seems to use the parent's library rather than its own. (if i put an item in the parents library it can load it, otherwise it throws an error). Is there any way to keep the child SWF using its own library? and if not, any other way to do this?

View 5 Replies

ActionScript 3.0 :: Inheritance When Using Loader.contentLoaderInfo. ApplicationDomain.getDefinition?

Jan 13, 2010

I have made a Flash app in which there is an class called "MyGame.Person" which has multiple subclasses "MyGame.PoliceMan", "MyGame.FireMan", "MyGame.Doctor" etc. "MyGame.Person" is defined in the main .fla file, but the other classes are each defined in separate .fla files. I have split each into its own .swf file so that I can extend the game without having to reissue the main .swf file.I then use a Loader to download each .swf file and call

var assetClass:Class = myLoader.contentLoaderInfo.applicationDomain.getDefinition(assetClass Name) as Class;
to extract the class from the downloaded swf file. So if assetClassName is

[code].....

View 2 Replies

Actionscript 3 :: Custom Events With Singleton EventDispatcher Using GetDefinition From Child?

Jun 11, 2011

EDIT: For whatever reason, it works in the browser but not when compiled/debugged within the IDE.I can't get my external SWFs to pick up on dispatches from my singleton event manager (EventDispatcher). Here are the particulars:

I add children from an external SWF using the getDefinition method to my main SWF.I'm using a singleton EventDispatcher that is in charge of listeners and dispatching.Using a custom event class.In this code, I am trying to get a mute button to tell the main SWF that the mute icon has been clicked (SoundClipEvent.MUTE_CLICK). After the sound has been muted, it should dispatch the event (SoundClipEvent.STATE) and confirm to the muteIcon the state. Currently, the mute icon successfully dispatches the MUTE_CLICK event and the main SWF document class is able to pick it up. MuteIcon (child SWF MC) hears nothing from the singleton.

SoundClipManager.as:

import flash.events.Event;
import flash.events.EventDispatcher;
public dynamic class SoundClipManager extends EventDispatcher {

[code]....

View 1 Replies

ActionScript 3.0 :: Extracting Multiple Classes From An Swf File Using ContentLoaderInfo.applicationDomain.getDefinition

Jan 14, 2010

I'm building a 10 channel mixer/remixer in Flash. Users can select a "song" to load from an xml driven combo box at the top of the application. In the document class, there is a function that takes the selected item from the combo box and loads in an external swf, which just serves as a library for the 10 sounds of a particular song. I then have to extract each of these sounds by their class names ("Track1", "Track2", "Track3", etc...) and send them off to their respective "MixerChannel" objects. As you can see, the following code block in the "initHandler" is pretty long and redundant. Is there any other way/shortcuts I can use to reduce the code a bit?

[Code]....

View 4 Replies

ActionScript 3.0 :: Instantiating BitmapDatas From Library Using GetDefinition - Missing Width/height?

Feb 12, 2009

I am instantiating assets (skins) from external SWF:

Code:
var asset : Class = loader.contentLoaderInfo.applicationDomain.getDefinition(myName) as Class;
var myClip : MovieClip = new asset() as MovieClip;

all works well but...The assets in library are basically images (jpegs) and I would like to avoid encapsulating them into MovieClips when you can export them for actionscript directly. This could significantly improve my work flow, but...

The problem is that the base class for any image in the library is BitmapData and the constructor for BitmapData needs two arguments, width and height which could vary...

Code:
var asset : Class = loader.contentLoaderInfo.applicationDomain.getDefinition(myName) as Class;
var myBmp : BitmapData = new asset(?, ?) as BitmapData ;

View 4 Replies

ActionScript 3.0 :: GetDefinitionByName In Loaded Swf?

Nov 15, 2010

I have the following scenarie in a multi-swf game:swf A loads an external swf B that loads a number of swf-assets.ApplicationDomain is set to ApplicationDomain.currentDomain.When I run swf B alone it can use getDefinitionByName on the loaded swf-assets to create instances of these. That all good.When I run swf A that loads swf B - swf B cannot use getDefinitionByName on its loaded swf-assets. Any ideas why this happens?

I'm also not sure if once the swf-assets are loaded using swf B would I then be able to do the following afterwards:swf A loads swf C (a different swf) and then instanciate the swf-assets loaded using swf B. I would like to have some kind of AssetManager that remembers every swf-asset loaded, so that I can easily re-instanciate assets in other parts of the game if needed instead of reloading these again and again?

View 3 Replies

ActionScript 3.0 :: GetDefinitionByName - Variable Not Defined

Nov 2, 2011

Showing error:
ReferenceError: Error #1065: Variable slip2 is not defined.
at global/flash.utils::getDefinitionByName()
at code::slip()

package code{
import flash.display.MovieClip
import flash.utils.getDefinitionByName;
import code.slip1
import code.slip2
import code.slip3
[Code] .....

View 2 Replies

Actionscript 3 :: GetDefinitionByName Of A Packageless Class?

Jun 16, 2009

Say you have a flexunit test that looks like this:

package foo {
import flexunit.framework.TestCase;
import flash.utils.getDefinitionByName;

[code].....

View 2 Replies

Flex :: Loader.loadBytes And GetDefinitionByName?

Feb 6, 2010

I am currently working on a project that will load a swc, inspect it and allow the user to view the classes inside.I load the library.swf using Loader.loadBytes (the bytes come from the unzip library I use). I create an instance of the class using getDefinitionByName.This all works fine as long as getDefinitionByName is called on the next frame. If I call it straight away I get a reference error. To get round this I've come up with a rather hacky solution:

private function processLibraries( event : Event ) : void
{
_zipFiles.forEach( processSwfs );[code].......

I really don't like using the enter frame event on the top level application. I also don't want to have to set up a timer. That's just as nasty.Loader.loadBytes doesn't fire a complete event so I don't know where I listen for an event for when the bytes have been fully loaded into the ApplicationDomain.

View 1 Replies

Flash :: Working With SWCs - GetDefinitionByName?

Nov 5, 2010

I have a bunch of graphics assets in a fla, the MovieClips are linked to some classes. I export the fla as a swc , which I add to my library with the option "Merged into Code".All works great, I can create instances of my MovieClips , just by calling their classes like this.

example 1
var newMc:BaseClass = new GraphicAsset();

Now if I want do the following , Flash throws an error , GraphicsAssetClass is null!

//example 2
var GraphicsAssetClass:Class = getDefinitionByName("GraphicAsset") as Class;


The only way I can get the above line to work is to do this

//example 3
var newMc:GraphicAsset;
var GraphicsAssetClass:Class = getDefinitionByName("GraphicAsset") as Class;[code]....

where I could simply get the class by calling getDefinitionByName()like I do on example 2 , without having to resort to example 3 solution.

View 2 Replies

Actionscript 3 :: GetDefinitionByName() And Class Visibility

Feb 23, 2012

I have main application which contains ModuleManager. Different modules are loaded by this application. Both main application and loaded modules use my custom RSL. I need to get Class object in my RSL, which is defined in one of the modules. I'm trying to use getDefinitionByName function, but since my class is not defined in RSL, I get an exception (though module with needed class is loaded). Is it possible to make module classes visible to RSL code and to get the instance of it at runtime without changing project structure?

View 2 Replies

ActionScript 3.0 :: Creating Objects Using GetDefinitionByName

Sep 14, 2010

I am trying to create a library of transition effects. Each transition type or preset is its own class. In the Client/Main class I would like to create the transition type I need based off a static constant, hoping to save myself from having to write a long switch statement to select which type of transition class to instantiate.[code]I am not using the getDefinitionByName utility correctly, what am I missing here? Is there a different way to achieve class instantiation by passing in the name of the class as a string.

View 9 Replies

ActionScript 3.0 :: GetDefinitionByName() Gives Error 1065

Nov 7, 2008

In my FLA I have a movieclip in the Library named "ContentPanel1". I have it's Linkage properties to export on first frame - class "ContentPanel1" and base class flash.display.MovieClip.

In my code I'm trying to attach an instance of this movieclip:

Code:
var instanceClass:Class = getDefinitionByName("ContentPanel1") as Class;
Now, here's the error I get:

[Code]...

View 8 Replies

ActionScript 3.0 :: GetDefinitionByName Without Path Included?

Jan 11, 2011

I import a class file with path: "src.Objects.Thing" . Later in the code I try to call getDefinitionByName("Thing"). Unfortunately, I get: "1065: Variable Thing is not defined".The way I fixed this was by writing: getDefinitionByName("src.Objects.Thing"). However, this seems like a cumbersome solution. I would really like to be able to exclude the path when calling getDefinitionByName.

View 2 Replies

ActionScript 3.0 :: Flex GetDefinitionByName Not Work

Apr 13, 2011

why i can't get a class defined by embed a .png file.like this:

[Embed(source = "../assets/level1/liquid4.png")]
public var Liquid4:Class;

then in the same class:

var str:String = "Liquid" + 4;
var disClass:Class = getDefinitionByName(str) as Class;
addChild(new disClass() as DisplayObject);

there is nothing shows up and no error report.the program seems stoped at the getDefinitionByName line.what could be the problem,and how to get a style like this when i have multiple embeded image to go over.I learned that getDefinitionByName needs the class name as its parameters.which is not Liquid4,Liquid4 is just a varialbe that hold the reference to the actual class object.Well i did get things work,but there is another problem:

-I'm using FlashDevelop as my IDE environment,the root folder "scr" which has "Main.as" and "Preloader.as" class in it.when i test my class uint which Embeded the Fluid4 Class,it works,everyone is happy.but later i decided to move it to a separate folder under the root "src" folder.things get ugly,and error shows up indicating "can't find the class",The Embed picture class.but then i moved it out the subfoler ,everyThing works again fine.

---------------------------------------
[Embed(source = "../assets/level1/liquid4.png")]
public var Liquid4:Class;
then in the same class:
//This gives us the actual class name

[code].....

This did work,but only in the "src" source file folder,not a sub folder of it.I checked this phenomenon many many times,and did use a tiny snippet program to prove it.It just doesn't work in the subfolder of "scr" root folder.

View 1 Replies

ActionScript 3.0 :: Flash GetDefinitionByName With Arrays

Feb 11, 2012

I'm having a new problem today- referring to arrays with getDefinitionByName. Anyways, in my map editor, I will have two layers of objects, and the user is responsible for choosing which layer of the map to write to. Because of this, I won't know the exact name of the array to write to until I piece together the string "map0Layer" and selectedLayer (chosen by the user):

Code:
var targetString: String = "map0Layer"+selectedLayer;
var mapTarget = getDefinitionByName(targetString) as Array;
trace(mapTarget);

Through this, I'd like to refer to an array, but every variation of the above code I've tried resulted in
ReferenceError: Error #1065: Variable map0Layer1 is not defined.
(This is subject to change because it could be "map0Layer2" as well, but you get the idea.)

View 8 Replies

ActionScript 3.0 :: Subclassing - Library Items And GetDefinitionByName?

Aug 29, 2009

I've recently inherited an AIR project, which is basically a widget that displays product images and static content (contact details etc) on the desktop.The original project was developed in CS4/AS3, and has been published and works fine. Since then, the original developer has gone overseas and I've been hired to make new versions of this widget, UI reskins, different products, etc. I work in CS3, so I've had the original Flash authoring file saved down, gotten Flash CS3 to be able to publish for the AIR runtime, and found the relevant AIR classes that I need. This has all gone smoothly.

The problem I'm having, is that there seems to be some strange way that the original developer has linked the library items to their relevant classes, and I'm trying to unravel this.I'm going to use the clip called windowApplication as my example.In the library, there is a movie clip symbol called 'windowApplication'. In its linkage settings, its class is set to 'windowApplication', and its base class 'com.aca.windows.Application'.The Application class extends the MovieClip class.However, when I test the app, I get compiler errors

'5000: The class 'com.aca.windows.Application' must subclass 'flash.display.MovieClip' since it is linked to a library symbol of that type.'
'1151: A conflict exists with definition SectionBackground in namespace internal.'
(SectionBackground is the first variable declaration in the Application class. Commenting it out makes this error change to the second variable declaration).

I can remove this error by changing the class of the 'windowApplication' symbol to 'Application' and setting the base class to 'flash.display.MovieClip', however that doesn't seem to instantiate the class properly. The symbol appears onscreen, but none of its instantiating functions are called.

The windowApplication object is instantiated using a getDefinitionByName call. I've had a google and looked around various forums, and I've seen suggestions that classes used in getDefinitionByName need to also have a fake instantiation so that they're compiled in Flash. I've tried this but it makes no difference.It seems to me that the getDefinitionByName call is working properly, as it does bring up the correct symbol - but only when the base class is flash.display.MovieClip.

I had another movie clip, called sectionMain, that also had this problem. Its original class was 'sectionMain' and its base class is 'com.aca.sections.Main'. It, too, threw a compiler error 5000. I changed the symbol's class to 'Main' and the base class to 'flash.display.MovieClip', when testing the app, this brought up the symbol. When I changed it back to the original settings, it worked fine, the object was called properly and I could interact with it. However, when the errors with the Application class are thrown, I also get the 5000 error for the Main class - without having changed anything.When I change the class of the windowApplication symbol to 'Application' instead of 'windowApplication', I get a warning that Flash can't find the class and will create one at runtime.

View 4 Replies

Firebug :: Use The Function GetDefinitionByName, Which Comes With Flash.utils?

Jul 11, 2011

I have just bought FlashFirebug Pro, so I am able to run ActionScript at runtime.I would like to use the function getDefinitionByName, which comes with flash.utils.i get an error, when I import flash.utils.getDefinitionByName.

View 1 Replies

ActionScript 3.0 :: Flex Error Using GetDefinitionByName And Array

May 29, 2010

I'm having a problem trying to use the method getDefinitionByName, I am using an array to store the names of the classes, the problem that arises is that when I am touring the settlement to create instances of classes shows me that error variable is not set, I've already created an instance of the classes that are in the array so the problem should not be because of this issue, only allows me to create the instance of an object in the array and when you try to create the following instance shows me the error that I mentioned previously

the fix that I'm using has these variables

"PlataformaPrueba", "PlataformaPrueba2"

and code with which I'm reading it:

Code:
var className: String;
var classReference: Class;
var classReference1: Class;

[Code]....

View 1 Replies

ActionScript 3.0 :: GetDefinitionByName Throws Undefined Variable Error?

Sep 17, 2008

Flash CS3 project. Can anyone explain this:

var ViewClass:Class = views.Login;
view = new ViewClass();
// ^works fine

[code].....

View 2 Replies

ActionScript 3.0 :: Classes Loaded With GetDefinitionByName Not Running Code

Feb 8, 2012

I recently discovered the incredible functionality of getDefinitionByName(), I'm attempting to load in pages for an interactive book.Each page has its own functions, listeners, nested animations, and timers.When loading in these pages, no stop()s are working within the nested clips, and any interactivty has been lost.It's just a mess of a bunch of animations running over and over.[code]

In addition to having the MovieClips not running code, I am running into serious garbage collection issues.I can unload the pages from display, but all sounds continue playing.Does anyone have an idea of why these loaded MovieClips are not running code, and why they will not unload properly with the destroy() method?

View 10 Replies

Flex :: Getting A Static Instance Of A Class (singleton) By Using GetDefinitionByName

Mar 25, 2011

I have a ManagerClass with a Singleton implementation inside, I get the instance by calling ManagerClass.getInstance().

Can I get that same instance by just having the class name as a string? I have tried something like:

var theInstance:* = getDefinitionByName("ManagerClass").getInstance as Class;
theInstance.doTrace(); // I get a 1009 error here

View 2 Replies

ActionScript 3.0 :: Using GetDefinitionByName To Make Static Function Call?

Feb 4, 2010

I found a lot of tutorials that show how to use getDefinitionByName() to create an instance of a class. Something like the following:

Code:
var classRef:Class = getDefinitionByName("menus.buttons.Icons") as Class;
var iconClassInstance:Icons = new classRef() as Icons;

[code]....

View 4 Replies

ActionScript 3.0 :: GetDefinitionByName(pictureClass) Then Display The Picture On The Screen?

Aug 3, 2011

I am using pictures for backgrounds in this game that I am making. About 10 pictures for each level. When the user starts a level all of the pictures needed for that level will be loaded into an array.

I can't use URL request because it won't always have access to the picture files at runtime.So I need to have a separate class for each picture. That is all okay. The picture class names are like so Level01_Picture01, Level08_Picture12, Level67_Picture01, ect... and are stored in the folder: theGame. To access them I user getDefinitionByName().This is the function that should return a MovieClip containing the picture specified in the parameters:

[Code]...

Firstly I'd like to ask: what does the @291d3121 mean? More importantly though, is it accessing the class theGame.Level01_Picture01? And if it is, how do I display the picture that belongs to that class?

View 4 Replies

ActionScript 3.0 :: GetDefinitionByName For Embedded Swf Symbol Not Recognized As Image.source When In Loop

Jul 19, 2010

I'm doing this in Flex, but code is pure actionscript, so if it's not the right forum please let me know:)I've embedded swf symbols like this:[code]but this code throws an exeption that 'myVar0 is not defined'. However this code:[code]

View 4 Replies

Actionscript 3 :: Overriding Public Method In Dynamically Loaded Class And GetDefinitionByName()

Aug 22, 2010

I have two SWFs: main.swf and external.swf. main.swf needs to access some methods in external.swf, so it loads external.swf into itself and uses getDefinitionByName("package.Class") to access the class and one of its methods:

var ExternalClass = getDefinitionByName("package.Class") as Class;
var ClassInstance = new ExternalClass();
var NeededFunction:Function = ClassInstance["NeededFunction"] as Function;
var response:String = NeededFunction(param);

Now, I need to extend the functionality of NeededFunction (which is a public method)... I know it's possible to override public methods, but how would I go about this with a dynamically loaded class?

I was thinking I could do something like this, but it doesn't work:

var ClassInstance["NeededFunction"] = function(param1:uint):String {
var newString = "Your number is: "+param1.toString(); //New functionality
return newString;
}

View 2 Replies

Actionscript 3 :: GetDefinitionByName In Flash Builder Acting Racist To New Classes After Switching To FB 4.5.1?

Aug 26, 2011

why the getDefinitionByName function works with "com.foo.Bar" and gives error with "com.foo.Rab"?My only clue is that the class com.foo.Bar was created before importing the project to Flash Builder 4.5 for PHP (4.5.1 namely).

My question is very specific, in fact you could try for yourself if you had FB4.5.1, a prior version of the same program, and a lot of time. Obviously I'm hoping to find someone who have experienced this particular issue or any related issue with similar functions.

View 2 Replies

ActionScript 3.0 :: Error 1180: Call To A Possibly Undefined Method GetDefinitionByName

Oct 13, 2009

var class:Class = getDefinitionByName("Box") as Class;
var box:MovieClip = new class()

*Box is a class that exists inside my library (A movieclip that is exported for actionscript) I have this code in two places: My document class and some other random class. It works in the document class. It fails to work in the other class (I get the error in the title) Both classes extend MovieClip (if that makes any difference) So what's going on here? Do you know the problem with what I'm doing?

View 2 Replies







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