ActionScript 3.0 :: Detecting Event In Private Function In External Class

Mar 28, 2011

I'm building a drag and drop quiz. each draggable mc (drag#) has a base class of DragDrop. I want to detect when an drag mc has been dropped on a target
Code:
if(this.hitTestObject(target)) {}
And then add a new drag from the drops Array. so that each time a drag finds its target a new one appears. I tried to make a public var named dropped to switch from "yes" to "no" in the drop function. and even tried making the drop function public.

This code is on the timeline
stop();
var drag1:Drag1;
drag1 = new Drag1;
addChild(drag1);
drag1.x = 100;
drag1.y = 100;
[Code] .....

View 8 Replies


Similar Posts:


ActionScript 3.0 :: Difference Between 'private Function' And 'private Static Function'?

Feb 2, 2011

is there a difference between classifying a function 'private' or 'private static' in a singleton? It seems that they both do the same thing. Maybe some difference in performance?

[Code].....

View 10 Replies

ActionScript 2.0 :: Private Var Number Declared Outside The Function In The Class?

Dec 25, 2005

These two functions are taken out of my as class file, even though the setInterval is never cleared it only calls generateParticles 1 time. Someone please help me figure this out. I have been messing around with it over an hour but still can find why its only called once. emit is a private var Number declared outside the function in the class.

[Code]...

View 3 Replies

Actionscript 3 :: Calling Private Function From External File?

Jul 5, 2010

How do I call a private function from an external ActionScript3 document? I'm working in Flash Builder 4, and I need to call a private function from an external AS3 document. I think I've imported it correctly....

import myapp.utils.WebcamFaceDetector;
import myapp.utils.FaceDetector;

But I want to call a function from "FaceDetector". Here's the part of the code in FaceDetector...

public class FaceDetector
{
private var detector :ObjectDetector;
private var options :ObjectDetectorOptions;

[Code]....

I want to call "private function FaceDetector()" to initiate at a certain point in another AS3 file. How do I properly declare it and get it to run?

View 3 Replies

ActionScript 2.0 :: Access To Private Var In Private Function For OnPress()?

Aug 11, 2010

here is a snippet of my code in an as file

ActionScript Code:
class PoolBall extends MovieClip {
private var poolBall:MovieClip;

[code].....

View 4 Replies

Private Function And Private Variables In Flash?

May 25, 2011

there are classes definitions where all their methods are private my question is why are they private, because i've tried a code wherein i changed all the private access modifier to public and nothing changed!

what if you make an instance of that class with all its method private, how are you be able to access that on another class. coz i know private methods are only accessible to the class where they are declared! will the instance of that class be able to access the superclass's private methods!

on private variables, it's still not clear to me as to why make a private variable and then use a getter and setter, when you can simply make it public! are these variables called static?cause on the way i understand it private functions and private variables are static?

View 1 Replies

ActionScript 3.0 :: Mind-bending Access Control - Assign A Private Method Of Class As An Event Handler To The FlashMOGService Object

Feb 15, 2011

I have written a framework that facilitates RPC calls between AS3 and PHP 5 called FlashMOG. I recently got a forum request that has introduced a pretty bizarre question regarding access control. This will be a lot easier to discuss if you have access to the FlashMOG 0.3.1 client source which is here:

[code]...

The basic idea is that I have a FlashMOGService class which has an RPCSocket member that it may share with other FlashMOGService objects. The idea is that you can create two distinct FlashMOGService objects and have them both connect to the same host/port via socket. I use my special RPCSocket class for two reasons:

1) Let developers use one port but separate functionality into two distinct services...a form of multiplexing i guess

2) RPCSocket adds functionality to the standard Socket class that works to serialize and unserialize data and get it where it needs to go. The essence of the problem here is that created a class with a FlashMOGService object as a member and has tried to assign a private method of his class as an event handler to the FlashMOGService object:

[Code]....

My initial thought is that this should be fine because it's all done within the class. However, when I consider the monkey chain that results in this function being called, it seems almost logical that it wouldn't work. The problem is that the browser freezes when a socket message arrives that tries to call the service's client method, _service.client.firstClientMethod. This client firstClientMethod is attempted when data arrives from the server on the Socket (an RPCSocket, actually). The RPCSocket class deserializes the socket data and extracts an array with a service name, a method name, and an array of arguments. It looks into its own private class variable (an array of services using the RPCSocket) and tries to invoke whatever function was assigned thusly:

[Code]....

I'm guessing there's some kind of infinite loop going on to check access control for the various intertwined classes.

View 5 Replies

ActionScript 2.0 :: Private Class Not So Private?

Nov 26, 2006

Okay so you've got your private vars in your AS2 Class, you think they're all safe right? Wrong.

Doing a trace(MyClass.myvar); will spit out an error that the var is private and you can't touch it.

But a trace(MyClass["myvar"]); will work perfectly fine. You can use it normal, without any setters getters outside the class.

Is there a way to protect against this? I think this is a huge security flaw. I know it's simple OOP, but a private var in an object should have rules.

View 7 Replies

ActionScript 3.0 :: Detecting Keyboard Presses On The Stage From An External Class?

May 29, 2009

I am working on a small section of my game and am attempting to detect key presses from an external class but I cannot get it to work. This code worked just fine when within the document class but now it's unresponsive. I'm not getting any errors, simply no activity whatsoever.Here's the applicable code:

My document class:

Code:
package
{
import flash.display.MovieClip;
public class Engine extends MovieClip

[code]....

View 4 Replies

ActionScript 3.0 :: Calling A Function From A Private Static Function?

Feb 26, 2010

i'm trying to modify some code and can't figure out what the issue i'm having it. this is the(shortened) code:

public static function Lose():void {
trace("OVER!");
Clock.stop();[code]...

this is the error i get: 1180: Call to a possibly undefined method OverIt.i just want to call a function from inside of the public static funtion.both function are inside this class:

public class Game extends MovieClip {
}

View 4 Replies

Flash - Listener In Main Document Class For Custom Dispatch Event From Another Class Does Not Respond Or Call Function?

Apr 1, 2011

I have a document class called Main.as In the class constructor I have the following listener:

enter code here
var listeningFORModeChangeToStudent:Sprite = new Sprite;
listeningFORModeChangeToStudent.addEventListener(TellAllModeChangeToStudent.STUDENT,exp);
addChild(listeningFORModeChangeToStudent);

[code]....

In a third class I make a call to the despatcher in the previous class:

enter code here
var ThisTellAllModeChangeToStudent:TellAllModeChangeToStudent = new TellAllModeChangeToStudent;
ThisTellAllModeChangeToStudent.tellAllModeChangeToStudent();

I have trace statements in eveything and from this I know the despatcher in TellAllModeChangeToStudent is being called.The problem is that the listener in the main.as is not calling the function exp.I cant see why and I dont know how to check if the listener is actually seeing the dispatch event?

View 1 Replies

Actionscript 3 :: Access Function In External Class Located In External Swf

Oct 22, 2011

I am trying to access a function in a loaded swf that has external class.. I would like to avoid having to put the function on my "Main" Doc class in the external swf and instead access the function directly from the class

This is what ive tried so far and it's a no dice:

private function startLoad(){
var loader:Loader = new Loader();
var req:URLRequest = new URLRequest("one.swf");

[Code]....

View 1 Replies

ActionScript 3.0 :: Using Private Variables In Sub Class?

Oct 13, 2009

i have created a Vehicle.as file and a Car.as file which are in the same project. The problem i am having is trying to use the properties in my Car.as from my Vehicle.as file.Vehicle.as

Code:
package
{

[code]......

View 14 Replies

ActionScript 3.0 :: Why Should Keep All Class Properties Private

Jun 4, 2011

I've heard it's considered best practice to keep all class properties private and to change them using getter and setter methods.

View 5 Replies

ActionScript 2.0 :: Private Function Load Vars?

Aug 19, 2009

ActionScript Code:
private var __milena:LoadVars;
private function Loadprom(prom:String):Void {

[code].....

View 5 Replies

ActionScript 3.0 :: Access Object In Private Function?

Jan 15, 2010

how to retrieve these in other functions.

In my main class (package) I have a function (tipTrendHandler) which creates an object TextBox. The instance in the example is ttrend. The class is imported. However when trying to access the object and apply e.g. a method, declared in another function (e.g. displaySequence) it seems this object is unknown.

ActionScript Code:
package com {
import flash.display.*
import com.mycompany.TextBox;

[Code]....

View 1 Replies

Flex :: List Private Attributes Of A Class?

Jun 11, 2010

I try to serialize objects with their private attributes, in Flex.

The introspection API does not seem to allow it:

"The describeType() method returns only public members. The method does not return private members of the caller's superclass or any other class where the caller is not an instance."

Is there another way for an instance to know the name of its private members?

View 1 Replies

Actionscript 3 :: Class Has 50 Private Members Of The Same Type?

Jan 18, 2012

I have a class which deals with a lot of visuals, which essentially are movieclips. So I have around 50 privately declared movieclips in the class. Would it be a good idea to put them in a dictionary and retrieve them by their name (as key) , put them in an array or just leave them as they are?

My issue is the visual look of my class right now with that many private members, looks like a mess visually.

View 1 Replies

Actionscript 3 :: Use Private Static Methods From Another Class

Mar 17, 2012

I am writing class that extends adobe air PNGEncoder,

I want to use the writeChunk method, but it seems to be private static and i cant seems to use it with my code But it gives the error as below

[Code].....

View 1 Replies

ActionScript 3.0 :: BUG: Cannot Use Constants In Class With Private Classes

Dec 27, 2009

I have some code from a CS3 app composed of the .FLA file with an .AS file for the class that had definitions for two private classes in it. Yesterday I brought the files into CS4 and noticed that they did not compile. Gives an 1120, access of undefined property and names a constant. I have reduced this problem down to bare bones and it still occurs, so it is a bug in CS4.

[Code]....

View 8 Replies

ActionScript 3.0 :: Private Variable In Class - Accessing Array?

Apr 9, 2011

I have a class that creates an array from a config xml file. I set a private variable in that class and use a getter in other classes to access the array. The routine that uses the array does the following:
- Call the getter and assign the returned value to a local (private) variable tmpArray.  the getter is a simple return() using a value that is established in the constructor.
- Uses a for loop to itterate over the contents
- Uses array.shift() to pop the item in tmpArray

The next time I run the routine, the contents of the array is empty. I'm using the same getter. I implemented the getter when I tried to manage both arrays in the same class figuring that as long as the original array was private (i also tried static), that the value would not change. I have since worked around the problem by moving the routine that fills up the original value from the constructor to the getter. So, consider the following code:

import flash.events.Event;
btn.addEventListener("click", btnHandler);
var myArray = new Array();
var myTmpArray = new Array()
myArray = ["one", "two", "three"];
myTmpArray = myArray;
function btnHandler(evt:Event) {
[Code] .....

If I create a variable myVar and set it to 1 then set myOtherVar = myVar, the both equal the same value. If I change the value of myOtherVar, myVar is not affected. But using the shift() method changes both the original and the copied array.

View 5 Replies

ActionScript 3.0 :: Cannot Call Private ... Method Of A Simple Class

Jul 31, 2010

I have .fla file where I have instantiated an object of a class( testclass.as ) like this in frame 1

[Code]...

View 9 Replies

ActionScript 3.0 :: Accessing The Private Variables Of One Instance Of A Class?

Aug 18, 2010

Currently I have two classes which are "bullet" and "enemy".There are two instances of the enemy class.Code from an ENTER_FRAME event in the Bullet Class:

ActionScript Code:
try
{
for(var k:int=0; k<getEnemys.length; k++)

[code]....

The Enemy Class has a private variable called "hits".What do I have to do in order to reduce the hits of the instance of the enemy that was hit by the bullet?

View 5 Replies

ActionScript 3.0 :: Color Class - Additional Private Constructor

Jan 25, 2010

I have a Color class where all the data is stored in a single uint named "_value". However, the constructor for Color looks like this:
public function Color(r:uint = 0, g:uint = 0, b:uint = 0):void
{ _value = (makeChar(r) << 16 | makeChar(g) << 8 | makeChar(b)); }

If I want to create a clone() method, I have to first convert the "_value" variable to an RGB object, then, the constructor automatically converts the object back into a hexadecimal value. Blatent waste of efficiency! However, I would rather have the constructor be user friendly and allow them to type in each color value instead of one hex value (they can use the Color.fromHex() if they really want to, but it does the same as the clone() method and converts back and forth).

Is there any way to instantiate a class without going through the one single constructor function? Any way to set up a private constructor in addition to the public one? Most Visual Studio languages allowed you to have multiple constructors, and the chosen constructor is determined by the passed in arguments. This was really convenient, but sadly, AS3 only allows one constructor, right?

View 13 Replies

ActionScript 3.0 :: First External Class / Event Handler

Jul 16, 2009

I am stepping back up to AS3 after realizing that it would be easier if I learned AS2 prior to trying to understand AS3 (all documentation, online and in books, reference AS2..."in AS2 this was done this way.I am writing my first external class and trying to associate it with an object created in the Flash via the Library Linkage.I have a movieClip on the stage and have it associated with the following class that doesn't show any transition when tested.[code]

View 11 Replies

ActionScript 2.0 :: How To Call Function On Class Event Handler

Aug 14, 2007

i have simple question about how to call a function on a class but i dont know how to do it,I have a class :

Code:
class MyClass{
private var lvSendState:LoadVars;

[code].....

View 3 Replies

ActionScript 2.0 :: Invoking A Function In A Class On A Mouse Event

Sep 10, 2008

i am trying to activate a function within a class on a mouse rollover -this is AS2 in CS3 and i have the following in my Class.as:

[Code]....

the global.pane_array is specified in my FLA Obviously i would like to see the trace from the array, but nada.... if i put the movePanes() outside the rollover event, it works fine... however this does not achieve my goals

also if i declare the function as a global function from within my FLA, and then call it on the rollover e.g. _global.movePanes() - it works!

View 3 Replies

ActionScript 3.0 :: Dictionary The Best Way To ID A Class Property In An Event Function?

Jul 23, 2009

I have a question about accessing properties of a custom class from within another class. I can do it, but I'm not sure if I am doing it the right way or if there is a simpler alternative. I have a class called legion it contains a couple of properties, a sprite called legio and an integer called loc I import the legion class into another class called Main.

Within Main I have a loop to create many versions of legion, passing parameters so that they all have unique loc values. These are put into an array called legarray:

[Code]....

View 10 Replies

ActionScript 3.0 :: Private Attributes & Class Property Definition Errors

May 22, 2010

I'm setting up functions in a document class file, then from there I am going to call that function from a movieclip in flash.  For some reason, maybe I have things set up wrong, but it is throwing me errors such as below: Line 37 1013: The private attribute may be used only on class property definitions. What am I doing wrong here and is there something I am not understanding? Here is my .as code. modal.as > package

[Code]...

View 1 Replies

ActionScript 3.0 :: 1013: The Private Attribute May Be Used Only On Class Property Definitions

Apr 7, 2011

This error is just making me wanna commit where have i gone wrong? Help would be awesomepackage classes

[Code]...

View 5 Replies







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