ActionScript :: Custom Class With Return Type?
May 24, 2010
i want to essentially classify a simple function in it's own .as file. the function compares integers. but i don't know how to call the class and receive a boolean return.
here's my class
package
{
public class CompareInts
{
[Code]....
so now i'd like to write something like this:
if (CompareInts(1, 5) == true). or output 'true' by writing trace(CompareInts(1, 5));
View 3 Replies
Similar Posts:
Feb 22, 2009
I'm making a custom class and all my get functions are working fine except the one that returns an array. Here is the code for my class (abridged to the relevant parts):
ActionScript Code:
/*
VolcanicIsland class for Polypelago
Script in progress
[Code].....
How do I get an array to return correctly? Doing trace(VI1.getData()[0]) doesn't work either.
View 1 Replies
Feb 11, 2010
How do you return data from a custom class, and only when something in the custom class has completed something. For example, let's say I have this code in the custom class[code]...
This, of course, doesn't work. I need the whatever.getLoadedObject() method to wait until the loading has finished inside the custom class then do whatever with the image loaded.
View 2 Replies
Jul 26, 2009
I'm trying to make my own picture browser for my webpage, and have run into a problem I can't solve. My guess is that this is kinda a newbie-problem, but anyway here I go...
I have made a class (as an extention to MovieClip) in a seperate file where I can load a picture and later resize it into a thumbnail. I have no problem showing them, but when I tried to make a MouseEvent for clicking onto the shown thumbnail and then tries to access the instance the event sends me, I get :
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Loader@22c30791 to ThumbNail.
at PicBrowser_fla::MainTimeline/clickedOnThumbNail()
I don't understand why it complains on 'Loader'!?And what is the best way to access the instance of the 'ThumbNail' in the MouseEvent?
The .as file looks something like this :
Code:
package
{
import flash.display.*;
import flash.events.*;
[code]....
View 2 Replies
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
Feb 11, 2009
I have a shuffleList.as file with this code...
[Code]...
When run this file the compiler report this error: "A constructor cannot specify a return type." Where I'm wrong; I'm new in actionscript..
View 5 Replies
Oct 25, 2011
It doesn't appear to be possible to get the return type of a function. Is this correct?
View 1 Replies
Jan 13, 2010
I'm extending the AS3 class Rectangle with a class called Bin. I want to override the Rectangle clone() method with a method that returns a Bin object, not a Rectangle object. If I try to override the clone method but specify Bin as the return type, I get a #1023: Incompatible override error. Here's my Bin class:
package {
import flash.geom.Rectangle;
public class Bin extends Rectangle {
[Code].....
This class works, but when I use the clone() method to create a new Bin instance, I get type errors when I try to use the Bin methods on the new instance.
How do I override clone() and send an actual Bin instance?
View 1 Replies
Mar 27, 2011
public function t()
{
if(xxx)return xxx;
//don't return anything
}
How to define the return type for such method?
View 5 Replies
Jul 26, 2011
I use wamp server and Propel.I have written my service using Propel but when I want to connect the data returned from the service Flex cannot recognize the return type.This is the php code that I wrote
<?php
// Include the main Propel script
require_once 'C:/wamp/propel/runtime/lib/Propel.php';
[code].....
View 1 Replies
Mar 24, 2012
I got two classes.
class A{
protected var _value:A;
public function get value():A{
[Code]....
I got error in my overriding and I don't know how to work around. I want to override a method and change it's return value.
View 3 Replies
Jul 27, 2009
I'm using the following javascript code:
[Code]...
The call gets made and I get the alert of either "Returning TRUE" or "Returning FALSE" but the result in the boolean "visibleRet" is always "false" in my "throw" message. Is there something special I need to do in order to grab the return type correctly from the javascript call?
View 2 Replies
Sep 22, 2011
how to return a generic value from a AS 3.0 function/method ex:
function MyFun():GenericType{
// if int
return 10;
// if string
[Code].....
View 2 Replies
Jun 6, 2010
Some constructor methods I've seen have the return type :void, even though they can't actually return any values anyway. If it's not required, is there a standard/best practice for that?
View 4 Replies
Sep 27, 2011
I constantly get:Implicit coercion of a value of type Class to an unrelated type lash.display.BitmapData.var ba:ByteArray = jpg.encode(BitmapData);This is my code from where it tells me it's wrong"
ActionScript Code:
var jpg:JPEGEncoder = new JPEGEncoder();
var ba:ByteArray = jpg.encode(BitmapData);
[code].....
View 8 Replies
May 4, 2009
Basically plots a dot wherever you click. Getting the error 1067: Implicit coercion of a value of type Class to an unrelated type Function.
package { import flash.display.MovieClip; import flash.events.MouseEvent;
public class particle extends MovieClip { //private var _xmouse:Number; //private var _ymouse:Number; private var mc1:MovieClip = new MovieClip(); private var mc2:MovieClip = new MovieClip(); private var mc3:MovieClip = new[code].....
View 7 Replies
Aug 15, 2011
These are my errors: in Adobe Flash CS5.5
I don't understand why this script doesn't work. I am new to Action Script 3.0 and I watched this incomplete video on youtube. -- [URL] and I got the fails below.
[Code].....
View 1 Replies
Apr 5, 2012
So for instance, I've got three .as files called 'Helicopter.as, Game.as, Blue.as'
and I also have a .fla file called Helicopter.fla (These files are all suppose to link together, to make the helicopter game) . In the Game.as file, I have the following;
[Code]....
Flash doesn't recognise the original Helicopter symbol (in the Helicopter.fla file, because I deleted it). But I want the system to detect the 'circle' drawn using API (In the Helicopter.as file). And I have no idea how to how to name the API drawn circle 'Helicopter', thus I'm getting an error. So how do I name the API circle to 'Helicopter', so the Game.as file recognises it.
View 1 Replies
Jan 23, 2010
I am new to AS3, as well as Flash in general, so forgive me if this seems highly elementary. All I am trying to do is create a custom class that extends the MovieClip class and contains a custom property of "marker". I want to be able to use and change the value of this custom property on the timeline for an instance of this class and have it behave just like any other (Ex: this.x ==> this.marker).
[Code].....
View 13 Replies
Jun 16, 2011
I have a custom class being constructed from my main class. In the custom class it has another custom class that is passed in as a parameter. I would like to strictly type the parameter variable but when I do, 'the type is not a compile type constant etc'.This, I understand, is because the custom class used as a parameter has not yet been constructed.It all works when I use the variable type ( * ) to type the parameter.I suspect this is a design flaw, in that I am using an incorrect design pattern.It is actually hand-me-down code, having received a large project from someone else who is not entirely familiar with oop concepts and design patterns.
I have considered using a dummy constructor for the parametered class in my main class but the passed in class also takes a custom class (itself with a parametered constructor). I am considering using ... (rest) so that the custom classes' parameters are optional.Is there any other way to control the order of construction of classes? Would the rest variables work?edit)in main.as within the constructor or another function
var parameter1:customclass2;
customclass1(parameter1);
in customclass1 constructor:
[code].....
View 1 Replies
Oct 11, 2011
Is it ever preferred to not declare the data type of the return value of a function? Data type of return value is not declared:
[Code]....
View 2 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
Dec 2, 2011
This is my first time working with a class attached to a movieclip that is nested inside a class attached to a movie clip.I've tested all the properties and methods of PTListItem.as and they work properly but when I try to call them on the list item through PTListTop.as it returns undefined.The end goal is to dynamically load a checklist via a txt file.
View 1 Replies
Nov 4, 2011
I have the following situation:I have an event handler, that displays small messages in my application's statusbar.These messages get passes through by dispatching events from custom components.A simple message could be like "HTTP Error" or so.Now, the main event listener, in the main application file, listens to the event dispatched by any custom component,but seems to refuse listening to events dispatched by custom AS classes.Here is my code for the custom event:
package main.events
{
import flash.events.Event;[code]..
So to sum it all up:
- The event listener listens to the custom event dispatched by any custom component.
- The event listener does not listen to the custom event duspatched by an AS class.
Those who wonder, the event really gets dispatched, that's why I added a trace call.
View 2 Replies
Jan 25, 2010
I couldn't work it out yet...
package components {
public class templateSelection extends VBox {
static public var tempSelectionBag:Dictionary;
[Code]....
I want to have a custom class tempSelection with a Dictionary as a public accessable property of that class. If I use this code, the compiler tells me:
1046: Typ wurde nicht gefunden oder war keine Kompilierungszeit- onstante:Dictionary
Which translates to:
Type was not found or was not a compile-time constant: Dictionary
View 1 Replies
Oct 14, 2010
I created an flv video player using Flash Builder 4. This "BasicVideoPlayer" project is compiled into a SWC that will be eventually be used to create other video players that extend the functionality. One of the features is a view that appears when the video has finished playing that displays a "Play Again" button. This "Play Again" view has its own class, "BasicPlayAgain", that accepts a graphic asset that is exported from a .fla file that contains all of the graphic/UI assets.
In my new project, "EnhancedVideoPlayer", I'm using the BasicVideoPlayer SWC as a library to create a new video player that will add more functionality to the "Play Again" view; specifically it will add more buttons to that view.The EnhancedVideoPlayer uses a default class that extends the BasicVideoPlayer class. The BasicVideoPlayer class has a member called "playAgainScreen" whose type is BasicPlayAgain. The EnhancedVideoPlayer needs to override the playAgain member and recast it as EnhancedPlayAgain so it can control the new buttons properly.
View 1 Replies
Feb 19, 2010
I realize this is kind of an odd issue, but I am wondering if there's any way to get Flash to allow me to access a class's static functions using a class variable that points to the class. Example:I create a class called FooClass that has a static function named fooI then create a variable of type Class that points to it
Code:
var class:Class = Class(getDefinitionByName("FooClass"));
However, when I try to call foo() using the variable, it errors saying the function
[code].....
View 6 Replies
Aug 17, 2009
Below is basic structure of LetterClip class which extends WMovieClipwhich inreturns extends Movieclip Class.
public class LetterClip extends WMovieClip
{
public function LetterClip(char:String):void
[code]...
Error occurs at the push statement.It throws the given below error only when the same activity is executedsecond time in a sequece.
TypeError: Error #1034: Type Coercion failed: cannot convertorg.waterford.activity.erp.erp1.r1lt08.clipclass::LetterClip@282e9281 to org.waterford.activity.erp.erp1.r1lt08.clipclass.LetterClip.#Operating System: Windows XPBrowser: Microsoft IE
View 1 Replies
Feb 2, 2010
I'm working on an accordion component and I was thinking that it'd be cool if I could write a very basic one and then set it up so that it would be possible to pass in any kind of container class and child class so long as they subclassed a particular parent or implemented an interface (haven't really gotten that far yet).
What I've noticed though is that I can't setup a default class for my constructor parameter. For example I'd like to do this:
Code:
public function DropDownList(containerClass:Class = ContainerSprite, childClass:Class = ChildSprite)
However it gives me the following error:
1047: Parameter initializer unknown or is not a compile-time constant.
[Code]....
View 4 Replies
Jun 15, 2009
So I have an input TextField and I'm wanting to use a custom font for it. I tried to use setTextFormat() with a TextFormat object, which does not make any difference. When setting embedFonts to true, Nothing at all gets displayed. I know the problem isn't with the TextFormat object, because I can apply the same format to a regular TextField and it works
View 1 Replies