ActionScript 3.0 :: Using Object Class As Parameter?

Oct 23, 2010

Let say I have two type object, one is MovieClip and other is Sprite, then I'm creating a function to access its child.
ActionScript Code:
function accessChild(parentObj:Object, childObj:Object):void {
trace(parentObj.childObj);
}

Then using "Analyze Project Source Code..." from FlashDevelop tools to analyze my code, I've got an error message:
"Do not use Object class. It is a bad practice to use the dynamic class Object. Prefer using strongly typed object, or marker interface in order to avoid silent compilation errors while refactoring". What type of object should I use in the parameter if I don't know the type of object if using an Object class as type object is a bad practice?

View 2 Replies


Similar Posts:


Actionscript 3 :: Passing Custom Class As Parameter To Custom Class Where Parameter Class Not Constructed?

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

ActionScript 3.0 :: Set A Default Value For A Class Parameter Of Type Class?

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

ActionScript 3.0 :: Class Name As Function Parameter?

Sep 10, 2009

I wanna pass a class name as a function parameter.In that function I wanna make instances of that class, any1 know how?

View 1 Replies

ActionScript 3.0 :: Pass A Parameter In A Class?

Dec 16, 2011

I have seen this code in ultitouch gesture samples. But I don't kno how can I pass a bitmap parameter to the statement  [Embed(source="imagenes/prueba.jpg")], how can I use this code with other bitmaps using parameters in this class?
 
package
{
import flash.display.Bitmap;
import flash.display.Sprite;

[Code]....

View 4 Replies

ActionScript 3.0 :: Extend A Class That Needs Parameter?

Sep 20, 2009

i have a button class that i use like:

btn1 = new ButtonClass("Label");

i want to extend ButtonClass.but this is giving me an error.

public class EnterButtonClass extend ButtonClass

how can i pass the param?

View 1 Replies

ActionScript 3.0 :: Passing Object As Parameter?

Jan 17, 2010

I have a function that goes like this;

Code:
function goback1(event:Event) {
cont.nums.y=86.5;

[code].....

View 1 Replies

ActionScript 3.0 :: Class Default Parameter As A Function?

Jun 30, 2009

Is it possible to set up a Class to have a Default Parameter as a new function? An example of Default Parameters:

Code:
function sayHello(somebody:String = world):void {
trace(hello, +somebody);
}

If so, what is the syntax for it?

View 3 Replies

ActionScript 3.0 :: Pass Parameter From First Frame To Class?

May 31, 2010

I have an application that gets its variable data in XML file.

This application is used for different clients with different data.

Some of the data I pass to the Document class from the first frame. I would prefer to pass url to the XML file the same way, without the necessity to update the document class. But now I have to hardcode this url in the class every time, because I cannot get parameters from the first frame to the class at once, only after some time (like after loading XML with hardcoded url).

Is there a way to force executing of the code on the first frame before the code in the class will proceed?

View 9 Replies

Flash - Parameter To Swf Loaded With Loader Class

Apr 15, 2010

im loading a child swf into my parent swf and I want to pass some parameters to the child swf.

Here is my code:

var req:URLRequest = new URLRequest( "test.swf" );
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener( Event.COMPLETE, loadComplete );
loader.load(req);

[Code]....

View 1 Replies

ActionScript 3.0 :: Cannot Pass Parameter To Already Written Class

Feb 5, 2009

I have written a class that works fine, but as soon as I try make it re-usable and pass a parameter. It gives me this error "1120: Access of undefined property xmlList_0."

Here is ActionScript Code:
package Classes{
import flash.display.*;
import flash.events.*;
import flash.net.*;
public class Carousel extends MovieClip {
[Code] .....

This is the code in my fla.file to run this class:
ActionScript Code:
import Classes.Carousel;
var carousel:Carousel = new Carousel(xmlList_0);
addChild(carousel);

View 3 Replies

ActionScript 3.0 :: Pass A Class Name As A Function Parameter?

Sep 10, 2009

I ran into a problem today. Since I wanna pass a class name as a function parameter. In that function I wanna make instances of that class,

View 3 Replies

ActionScript 3.0 :: Array As Parameter And Custom Class?

Dec 23, 2010

If I set my variables as type MovieClip instead of the type of the class for the MovieClip I am calling them as, will this affect my presentation in any way? Say I have a movieClip Walls with a class definition Walls. Will

var newwall:MovieClip = new Walls(); or
var newwall = new Walls();
be any different than
var newwall:Walls = new Walls();

View 9 Replies

ActionScript 3.0 :: Retrieve Parameter From An Object (Xml Reader)?

Dec 4, 2010

I have 2 classes and im trying to receive the variable "xmlResult" from the object my_XML,but its always null.I understand that is an asynchronous problem, but I dont know how to resolve this.

XmlClass.aspackage  import flash.net.URLLoader; import flash.net.URLRequest;  import flash.events.Event;import flash.events.EventDispatcher; import flash.display.Loader  import

[code].....

View 1 Replies

Javascript :: JS Function Invocation From Object In Parameter?

Oct 17, 2011

I'm building an AIR desktop application. At one point the application loads a popup window (an MXML component based on s:Window), which contains an mx:HTML component which loads a local (in the application directory) html file, blank.html. The relevant elements in blank.html are:

<script src="jw/jwplayer.js"/> <!--JW Player's JS-based Embedder-->
<div id="jwtarget" /> <!-- the target that the embedder will use -->

Since the parameters I want to use are determined at runtime, I use the domWindow property to invoke the method which loads the player. Here's an example that works:

[Code]...

View 2 Replies

ActionScript 3.0 :: Library Object's Constructor Can't Have Parameter's

Oct 11, 2009

I have a class in my .fla's library called StatBar_object. StatBar_object is an inherited class that extends from a custom class StatBar, while StatBar extends from MovieClip.

However, StatBar's constructor has a parameter (the constructor reads "public function StatBar(target:int)"). Thus, I continually get an output of:

"ArgumentError: Error #1063: Argument count mismatch on StatBar_object(). Expected 0, got 1.
at actionscript.stat::StatBox_object()
at actionscript.modes::battle_mode()"

Is there any way to get StatBar_object's constructor to include StatBar's parameter?

View 8 Replies

ActionScript 3.0 :: Nullify An Object With A Reference Parameter?

Jul 27, 2010

Having this simple [code]...

Why the function nullify() changes the value of the property "a" but doesn't do the "= null " assigment to the object passed by parameter ?

View 8 Replies

ActionScript 2.0 :: HitTest - Passing Object Name As Parameter

Jun 16, 2004

I'm having troubles activating the HitTest, passing the objects name as a parameter through a global function. Let's say there is the following function on the main timeline:

Code:
_global.fallIntoBasket = function (fallingObject) {
if (_root[fallingObject].hitTest(_x, _root.basket_mc._y+(_root.basket_mc._height/2)-7, true)) {
trace ("teste");
_root[fallingObject]._alpha=0;
}}

I then call this function passing the this._name of the object as a parameter in a onClipEvent (EnterFrame) on each of the falling Objects action box. The whole detection thing doesn't work though... but if I place the hitTest code on each of the object, and change the _root[fallingObject] to this it works. Can I not pass hitTest through a function?

View 3 Replies

ActionScript 3.0 :: Passing URLs For Class As Parameter In Flash

Aug 19, 2009

I am calling java servlets from flash using the following code [below is a sample Flash code for calling a java servlet in Flash which I am using]:
String url_String="[URL]"; var req:URLRequest = new URLRequest(url_String);

In this case, the servlet is called/working fine only in my system where the flash application is deployed & not working when I execute the application in different system using the "IPAddress" of my system. So, What changes I need to make in above Flash code in order to call the same servlet successfully from my system and as well as from other systems? (OR)

Is there any need to pass the servlet-url's relative instead of absolute? If so, How can we pass relative-path of url's in Flash? && Can anyone explain me with an example? How to change my above code to pass the url 'relative' rather than 'absolute'? If I pass the url relatively, does my issue gets resolved?

View 8 Replies

ActionScript 3.0 :: Pass A XML Element Path In As A Parameter Of A Class?

Dec 28, 2010

I am creating a class to handle some audio in an app I am building. This class will need to accept the XML element path as a passed parameter and or a getter.

examples of some XML elements I would like to pass to the the audio handler class to access them.

Dialog.introScreen.text

or

Dialog.secondScreen.main.text

ect.

I pretty sure this is not a string data type and thus cannot be passed as a string (I could be wrong though), if not, what data type would I pass it as?

View 7 Replies

ActionScript 2.0 :: Class Linkage To MovieClip And Pass Parameter?

Nov 7, 2004

I have a class that has a constructor which accepts some parameters.
Code:
class MyClass {
var myNumber:Number;
function MyClass(number) {
myNumber = number;
}}
Is there a way I can link this to a movieclip and pass the parameter? From what I've found there are two ways to link the class to a movieclip, one using the registerClass and another typing the name intro the Linkage Box in the Library. But in both cases there are no parameters being setup.

View 2 Replies

ActionScript 3.0 :: Adding Parameter From A Custom Class To An Array?

Jun 16, 2011

In class Main I am instantiating a custom class NavLabel that creates a textField. With in NavLabel I dispatch a custom event CustomEventWithParams on a reference to class Main that passes the parameter theLabelWidth along with it. from with in class Main i can trace the theLabelWidth for each of the instantiated NavLabel objects. I want to hold those values in an array labelWidthArray and then use them to position the NavLabel objects. how can I do this?

class Main

Code:
package
{
import flash.display.*;
import flash.events.*;

[Code]....

View 2 Replies

Pass Link URL Values Into A Flash Object As A Parameter?

Apr 28, 2009

I have created a small banner for the homepage of a website for a company. The problem is that when they load the banner to their website the link no longer works. I have tested it myself and it works fine on my website. have the banner be clicked and open up in the same browser to another page on this website."define a way to pass link URL values into a flash object as a parameter."

"We need the functionality ASAP so can you start by working on this and creating a sample. It shouldn�t be too difficult as it is a fairly common requirement. Can you put together a basic example (it doesn�t need good graphics) that shows this idea working over " [URL]

View 5 Replies

Javascript :: Setting Flashvars Parameter Of Swf Object Dynamically

Feb 18, 2012

I have a rquirement where i want to play the song based on the checkbox checked.I mean i want to set the flashvars parameter of swf object on click of checkbox to play respective song.I am using the tag for this is

[Code]..

in my website. Here i want to change the flasvars dynamically on checkbox(function as radion button) checked

View 1 Replies

ActionScript 3.0 :: Inheritance / Interface - Override A Function That Return An Object Of Class A And Make It Return An Object Of Class B Which Extends A?

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

ActionScript 3.0 :: Turning A Object Of Class A Into An Object Of Class B Extends A?

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

ActionScript 3.0 :: Error On Using An Untyped Parameter In The Constructor Of A Document Class?

Aug 9, 2010

I got an error like "Incorrect number of arguments.. Expected  0." when I was trying to make an instance of a user-defined class that I've written in the document class of my project.Here's the line in my document class:private var myNotice:myNoticeClass = new myNoticeClass(this);An untyped parameter is supposed to be the only argument to the constructor method of class myNoticeClass and the constructor is something like this

public function myNoticeClass(ref:*)
{ ......
}

[code].....

View 7 Replies

ActionScript 2.0 :: Keeping The Data Parameter Of The Object Created With A While Loop

Mar 7, 2004

i've been struggling with the following:

i am creating a list of buttons with an attachMovie. the AS is :

//as
var i = -1;
while(++i<userlist.length){
var user = userlist[i];

[Code].....

okay the problem is this: then i assign an on click function to every button right in the while loop that uses the data parameter of the "ob" object and when i play the movie the data parameter is always the parameter of the last object created for all the buttons. I know why this is happening- it overWrites the old "ob" with the new with every itteration of the loop.

But how would i go differently about creating an individual "ob" for each button created and still be able to have a function with a data parameter like this.onRelease.userClicked(data)?

View 9 Replies

Javascript :: Lightweight Method To Change Embedded Object Parameter Values

Apr 15, 2012

I would like to change the parameters of an object, or values like width and height, via javascript but I need a very lightweight method. In the end some of the thing that I want to change would be width, height and a parameters src value. So far I'm having no luck of getting it by id $('#test').attr('src','test.html') or the javascript method of getElementById().

What is the best - lightweight - method to do this?

An object being like this:

<object type="application/x-shockwave-flash" width="600" height="500" data="http://www.thisembed.com" style="margin:0px;padding:0px">
<param name="allowFullScreen" value="true" />

[Code].....

View 1 Replies

ActionScript 3.0 :: Parameter In Filerequest That Gives The Full Path Of The Object Selected In The Browser?

Mar 11, 2011

Whats the parameter in Filerequest that gives the full path of the object selected in the browser?

I want to display the image selected in a loader.

View 2 Replies







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