Actionscript 3 :: Return Loader Object As Class?
May 16, 2011
I have to implement a menu with icons using actionscript only. I create a data provider from XML and set
menu = Menu.createMenu(null, dataArray, true);
menu.iconFunction = iconFunction;
Till here everything is fine and my menu is presented, but only with labels.
I create iconFunction as following:
private function iconFunction(item:Object):Class
{
var st:Loader = new Loader();
st.load(new URLRequest(item.icon));
return ?;
}
how do I return my loader object as Class?
View 2 Replies
Similar Posts:
Aug 4, 2009
I'm having some troubles with the use of interface and inheritance in AS3. I've done lots of OOP in the past and what I'm trying to do seems obvious to me, but doesn't work in AS3. The question is : Is it possible to override a function that return an Object of class A, and make it return an Object of Class B which extends A ? It seems not to be possible, since I'm getting a signature error in Flash, when compiling. For example, the following set of class do not compile (the code in function definition doesn't matter):
[Code].....
View 3 Replies
Nov 6, 2010
I want to load an array with images in Main.as, by using a loader in another class. The problem is, I have to wait for the images to load before returning the array. How do I return the array images[] (once it's loaded) back to characterGFX[] in Main.as? I'm just lost.
Main.as
Code:
package {
public class Main extends Sprite{
private var gfx:Gfx = new Gfx();
[code]....
View 9 Replies
Aug 18, 2009
I found myself loading a new XML file every day and so decided to create a small class that will load the xml file and return it.The class is loading the file but when i try to return it to a new xml object in the document class it doesnt load it.I think that it's something to with the return being in a nested function but i tried a few ways and non seems to work.
[DOCUMENT CLASS]
loadXML:LoadXML = new LoadXML();
myXML:XML = new XML(loadXML.loadXMLFile("gallery.xml"));[code].....
View 1 Replies
Mar 16, 2011
I have a CSV reader class that parses a CSV file.....
1,11.15126526
2,11.28306635
3,10.78296071
4,10.79878325
The CSV reader class works and produces a Vector.<Point> ... However the container class (which includes an instance of the CSVFile class) needs to access the resultant Vector. Whenever I 'return' the Vector.<Point> to the container via a CSV method it is always empty...I don't know if its something to do with the size of the Vector<> or what?
View 5 Replies
Jul 27, 2009
I created a button class with a method that will allow me to control an external SWF. However, the loader for the SWF is created on my main timeline. Is it possible to access the loader object from within my button class?No matter what I try I either get an error that the variable is not defined (rightfully so because I haven't defined it in the class, it's defined on the main timeline) or that the object is null (when I declare the loader from within the class, which I know is wrong as well)
View 4 Replies
Feb 24, 2010
I have a class (ImageLoader) that extends Sprite container and loads an external image to its instance. When i instantiate an object of this class from another (Main) class i want to have the dimensions (width, height) of the loaded image being known to this (Main) class. It seems that is difficult for me as the dimensions are known after the image compete loaded. But i don't know how to pass this information from completeHandler event handler to the Main class.
package
{
import flash.display.Sprite;
import flash.events.Event;
[Code].....
View 1 Replies
Sep 8, 2011
I am really pulling my hair out with this one. Flash game, container swf loads a img using the loader class. The image is the map which will be used on the levels. The problem im having is that I originaly had each level load the map image, convert to a bitmap, and us it to create x and y's for colision detection.
the problem was that the game was loading and sometimes the map image hadent loaded. It also ment that each level was loading the same image and if the above happened on the 3rd, 4th level it was very annoying. So I need a way to load the image in the parent, but have it available to the child, however it must be available as at bitmap to work.
[Code]...
View 1 Replies
Jan 23, 2009
I have this code in a class:
Code: Select allpackage com.jhoyt{
import flash.net.URLRequest;
import flash.events.*;[code]....
and I have this code on the timeline of the movie its being loaded into:
Code: Select allimport com.jhoyt.SSIlaunch;
var ssi:SSIlaunch = new SSIlaunch();
addChild(ssi);
I know its loading because I can put trace actions into the addAndPoint function and it gets called. what can I do to make it display?
View 3 Replies
Jan 23, 2009
I have this code in a class:
[Code]...
I know its loading because I can put trace actions into the addAndPoint function and it gets called. what can I do to make it display?
View 1 Replies
Jul 9, 2011
In the first frame of that movieclip, I'm importing an external swf with Loader class,(Using actionscript2 but my main flash page using Actionscript3),It is loading well but when i pass to second frame and return to the first frame again, the Loader doesn't work. (i'm using addChild(); to show external swf)
View 9 Replies
Mar 12, 2010
I want it to return a MovieClip but only after a Loader has triggered its COMPLETE Event.
like so;
Code:
static public function loadBitmap(URL:String):MovieClip {
// create MC
// create Loader
[Code].....
but it isn't fool proof because the MC is returned before the Loader finishes loading.
View 2 Replies
Mar 25, 2010
So I have this Photo class than handles loading a pic, and dispatches an event when the loading is done with:[code]which is simple and works, but now I'd like to make something more advanced. I'd like to dispatch the load ratio.So far I have extended the Event class, with my own EventRatio class, and I can put properties on that class. Which is cool, but I need something more dynamic than just sending a fixed value.So, what is the best way to connect the Loader object of the Photo object, with the EventRatio object?
View 5 Replies
Nov 7, 2006
Is there a way to return the target of a Tween object from within the object?
Code:
myTween.onMotionFinished = function (){
trace (this.target)
}
That's obviously not the way you do it, but that's what I want it to be...
View 9 Replies
Feb 11, 2009
It seems that dropTarget only returns the name of the object that is directly under the mouse. Does anyone know whether there is a simple way for it return the name of the object that is under the entire bounding box of the object being dragged?
View 1 Replies
Oct 20, 2010
siteLoader.as, Line 23 1061: Call to a possibly undefined method load through a reference with static type Loader.
[Code]....
View 2 Replies
Oct 12, 2010
I am using the Loader class to load 3 external swfs: sharedTopics.swf (does not have a document class) fonts.swf (document class is FontManager) main.swf (document class is Main) The same loader is used to load all 3 assets.
[Code]...
View 2 Replies
Sep 26, 2010
I am trying to write my first real class (it works when I just use trace statements). The main part of the function returns a value and since the constructor can not return a value I was not sure how to handle it, so I did this...
[Code]...
View 6 Replies
Jun 10, 2009
How would I return a value from this class?
package com.ryancanulla.utils
{
import mx.collections.ArrayCollection;
[code]......
View 8 Replies
May 7, 2008
I created a class that returns and array. How can I access that return from my main timeline?
I just need to trace the return in this case.
GetTeams.as
Code:
class GetTeams {
public function GetTeams () {
var teamLoaderURL:String = "teams.jsp";
[Code]....
View 8 Replies
Nov 4, 2009
I am writing a method in a FileIO class called returnBMP()
The idea is: I want to pass it a file name, and I want it to return a Bitmap. ( not a loader )
The problem is that the only way I know how to pull a bitmap out of a loader is by creating an eventListener on the contentLoaderInfo for COMPLETE.
That just doesn't work in a return function. the return is executed before the bitmap is loaded. I get a null..
here's my code:
ActionScript Code:
public function returnBMP(img){
var bmp:Bitmap;
var loader = new Loader();
[Code]....
View 4 Replies
Sep 22, 2011
Possible to create something like the following[code]...
View 9 Replies
Oct 8, 2009
I have a question about return..example:
Code: var date: Date = new Date(); trace (date)//Thu Oct 8 23:05:51 GMT-0300 2009 How i can get a String return by a Class? The default return with a normal Class is ([object Date])... Constructor can`t return values... how i can make that? :p
View 3 Replies
Dec 11, 2011
I want to load two picture and add every picture to every sprite object,such as picture a to sprite1 and picture b to spriteb,I know I can load a pictue by following code:
loadImage('a');loadImage('b');private function loadImage(imagePath:String):void { var loader:Loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded); loader.load(new URLRequest(imagePath));}private function
[code].....
View 3 Replies
Jun 3, 2010
I'm just getting to grips now with how the Garbage Collector works.
Is there a way (like a function or a custom class available somewhere) to check an object for all its references and return them so that you can see what it's connected to?
View 2 Replies
Dec 12, 2011
I want to load two picture and add every picture to every sprite object,such as picture a to sprite1 and picture b to spriteb,I know I can load a pictue by following [code]...
View 2 Replies
Jun 18, 2009
I'm trying to create a function that determines which of 4 similar classes to create, and returns the new object itself.
Basically, I have a base class (Panel) that has 3 additional variations in layout, each of which has a subclass: TextPanel, FeaturePanel, and LinkPanel. The two parameters for my function are the "kind" of window to create and its name ("linkString"), both of which are provided by external XML. I'm wondering if it's even possible to return the new Panel as an object...?
My code will probably explain this better than I can:
Code:
// create the new Panel variable ("addPanel") with a call to newPanel:
var addPanel = newPanel(linkList[i].attribute("kind"), linkString);
Code:
// newPanel function:
[Code].....
within the Panel constructor, the provided string (linkString / 'h') is set as the Panel's .name. I did not copy that function into the subclasses, since they inherit it - unless I'm mistaken.
View 8 Replies
Jan 26, 2011
I want to assign an existing Object all the vars of a prototype Object, without a direct reference. One way to do this is:
[Code]...
This way both Object's values for .nom and .age can be independently changed, but it's tedious. Is there an automated way to assign all of protoObject's vars to enObj?
View 9 Replies
Jul 20, 2009
I have a class CoverPoint extends Pointwith some extra function.except for that ther is no difference. I would like to use the functions of Point with a return value of Point, to calculate those CoverPoints.Can i turn the return value into CoverPoint (since all the vars are the same, there shouldn't be a problem with that, right?), so that it can be stored in my var cP:CoverPoint;
View 2 Replies
Jul 14, 2009
I created a menu from a created .as extended Sprite class.
Except from this menu, I need it to return a String value of the item name the user selected.
View 17 Replies