Private Messages
In the following function I am trying to send a message directly to a recipient (toWhom parameter = client.user.userName) as a private message, but cannot resolve how to do so...any suggestions/hints?
I have tried several conditional loops, but am wholly unsuccessful...
quote:Code
VideoConference.prototype.deliverMessage = function(client, msg, toWhom)
{
var now = new Date();
this.startTime = now.getTime();
var str = now.getHours() + ":";
var mins = now.getMinutes();
str += (mins>=10) ? mins : "0"+mins
if (toWhom == "everyone")
{
//Public
this.history_s.send("appendMessage", " { " + client.ip +" } " + client.user.userName+" @ "+ str + " : " + msg);
this.messages_so.send("showMessage", " { " + client.ip +" } " + client.user.userName+" @ "+ str + " : " + msg);
return;
}
else if (toWhom != "everyone")
{
//Private
this.messages_so.send("showMessage", " { " + client.ip +" } " + client.user.userName+" @ "+ str + " : " + msg);
return;
}
}
Adobe > Flash Media Server
Posted on: 07/22/2008 09:30:22 AM
View Complete Forum Thread with Replies
Sponsored Links:
Private Class Not So Private?
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 Replies !
View Related
Private Help
hey guys, i know that since i started a design company that i should know how to do flash, but its a small company and im just starting. so what im asking is that i could get someone to help me do transitions and stuff privately on msn and just pass the file back and forth, i have the design made, but i am having a bit of trouble with this, so please, anyone interested just pm me for more info.
thanks everyone!
View Replies !
View Related
Private Page...
I need a way so that when a person enter a word such as "test" in a text box, and presses a button, the movie goes to a frame with the name "test" (the name the person put into the text box).
I would really like some help...
And if this can't be done, please tell me.
View Replies !
View Related
Private ? (MX2004)
I have tried out some new as stuff in the MX2004P trial.
Doesnt seem to work:
The private access modifier - private vars are accessible to
instant variables, can both get and set them directly - no error messages.
Strictly typed variables - no protests from the compiler when
assigning values of wrong types to class instance variables.
Only when trying to assign wrong types to variables INSIDE the class
declaration I get errormessages.
Am I missing something or is this new version buggy???
Oeyvind
--
http://home.online.no/~oeyvtoft/Toft...eset/flash.htm
View Replies !
View Related
Static Vs. Private
Okay, I feel like a total Newbie for having to ask this, but I've gotta do it.
What exactly is the difference between Static and Private (for both Functions and Variables)?
I've been searching around online and in these forums for a good hour or two now, and just can't seem to find the "easy" answer I'm looking for.
Thanks in advance,
Mother
View Replies !
View Related
Problem With OOP: Private
Hi, I'm new to this forum, and I decided to post since I have a little problem going on here and I think you might help me.
I'm working on a project including several classes I've developed. I'll try to paint you the whole picture so you can have an idea of the problem. The classes are:
VPoint
BezierPoint
Polygon
PuzzleMask
PuzzlePiece
where BezierPoint extends VPoint and PuzzlePiece extends MovieClip. Up to PuzzleMask everything seems to be fine. From the main movie, I instantiate the PuzzlePiece class, like this:
var piece:PuzzlePiece = new PuzzlePiece(0,0,200,200);
Well, the big problem occurs when, inside PuzzlePiece, I instantiate a PuzzleMask, and I don't know why VPoint and BezierPoint suddenly expose their private members. Do you have any idea why this might be occurring?
The private members in question are:
(Inside VPoint)
private var xx:Number;
private var yy:Number;
(Inside BezierPoint)
private var controlPoint1:VPoint;
private var controlPoint2:VPoint;
Even more weird is for me when I instantiate a VPoint and a BezierPoint and try to access these private members from the main movie:
var d:VPoint = new VPoint(10,10);
var e:BezierPoint = new BezierPoint(10,10);
trace(d.xx); //---- error
trace(e.controlPoint1); //----error
Wich seems to be fine. But the problem seems to be inside my PuzzlePiece class, where I do this:
private var _puzzleMask:PuzzleMask;
and then, the constructor:
function PuzzlePiece(x:Number, y:Number, w:Number, h:Number) {
_puzzleMask = new PuzzleMask(x,y,w,h);
_colorMask = 0x0;
}
But after that, the members get exposed.
Any help about this would be great, because I'm taking my first steps into oop and I think I'm knocking my head with some walls
View Replies !
View Related
Private Function Won't Run
I am making a Class that affects a movie clip. The class is just a normal Class (not extends MovieClip) and in the constructor I have to define the movie clip to use:
ActionScript Code:
var nObject:ClassName new ClassName(MovieClipInstance, bla, bla);
Now here is the problem; In the constructor I have to define a onMouseMove event for the movie clip because I have to be able to know when it moves to redraw the mask that the class creates.
I have it like this, this code is inside of the class file:
ActionScript Code:
public function ClassName(targetMC:MovieClip) {
_targetMC = targetMC;
_targetMC.onMouseMove = function() {
if (this.hitTest(_xmouse, _ymouse)) {
drawMask(); // nothing
if (_disortionShadow) {
drawShadow(); // nothing
}
if (_border) {
drawBorder(); // nothing
}
}
}
}
drawMask, drawShadow and drawBorder are private functions inside of the class but Flash thinks they are functions from the _targetMC MovieClip. And if I try to use _parent.drawMask() it thinks that its from the parent of _targetMC and not from the class itself.
How can I access the private functions in this case?
View Replies !
View Related
Private / Public Var
I created a menu button:
ActionScript Code:
public class MenuButton extends Sprite {
public var _label:TextField;
public function MenuButton(labl:String) {
var shape:Shape = new Shape();
shape.graphics.beginFill(0x990000);
shape.graphics.drawRect(0,0,100,20);
shape.graphics.endFill();
var button:MyButton = new MyButton(shape);
addChild(button);
var tekst:TextField = new TextField();
tekst.x = tekst.y = 0;
addChild(tekst);
_label = tekst;
_label.text = labl;
_label.mouseEnabled = false;
addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
buttonMode = true;
useHandCursor = true;
}
private function onClick(evt:MouseEvent):void {
trace(_label.text);
}
Next I created a navigation bar with eight menu buttons.
Everything works just fine.
That is, since I changed the accessor of _label from private to public.
This I don't understand. As far as I can see, the variable is accessed only in the MenuButton class.
Can someone enlighten me?
View Replies !
View Related
Private Rooms
Hi I'm fairly new to FCS but Iknow how to program in Flash and Actionscript.
What I'm trying to build is a private video chat for a Video Game help forum that works like this:
The visitors come to the site, login and are all listed in a waiting room to talk to the Game Guru. He sees them all listed there. When he's ready, he clicks on a member in the room and a new window pops up and he vChats with just that one person privately.
I know how to change the interface based on the user name of who is logged in but what I don't know how to do is to make the private room that only the two people are in together and no one else can enter without the password.
I've seen private rooms on other sites but I don't know if this is a built in fuction og FCS or if I have to build it.
View Replies !
View Related
Private Constructor
Hi,
I am just wondering why a constructor cannot be declared as private under AS 3.0?
It was possible under AS 2.0 and in many situation it may be logical to declare it as private, for example a class which instanciates its objects only through one of its public static classes.
Declaring a constructor as private just means that you don't want it to be instantiated by an external entity, doesn't it?
thanks
View Replies !
View Related
Private Var Manupulatable From Fla ?
Okey, this is pretty weird...
I've been taught that when you have a private variable in a class it can't be accessed, let alone be altered, outside of the class. So how come I can do the mentioned actions on an objects private variables within a fla?
class:
ActionScript Code:
class myClass { private var foo; function myClass() { foo = "top secret"; } }
fla:
ActionScript Code:
obj = new myClass(); trace(obj.foo); obj.foo = "hello" trace(obj.foo);
View Replies !
View Related
Private Var Manupulatable From Fla ?
Okey, this is pretty weird...
I've been taught that when you have a private variable in a class it can't be accessed, let alone be altered, outside of the class. So how come I can do the mentioned actions on an objects private variables within a fla?
class:
ActionScript Code:
class myClass { private var foo; function myClass() { foo = "top secret"; } }
fla:
ActionScript Code:
obj = new myClass(); trace(obj.foo); obj.foo = "hello" trace(obj.foo);
View Replies !
View Related
Private Type
in visual basic would use the code:
private type thing
value as boolean
name as string
end type
dim me as thing
to get values of me.value and me.name
how can i do similar in flash
View Replies !
View Related
Willing To Pay A Private Tutor For Basic Help.
I am trying to make some basic animated gif's for an upcoming school project (I'm the teacher), and I am running out of time and patience. The "interactive ebook" I bought to teach me the basics of Flash 5 doesn't work, and my blood pressure is getting too high. I am willing to pay a moderate fee to someone who could guide me through importing jpeg files, making them move through some little routine, and saving as GIF file for use on a web page. I'm thinking around $10/hr Canadian. Interested? Please email me at gonfish@hotmail.com and we'll talk.
BL
View Replies !
View Related
Private Properties & Methods
I am confused about how to write private (local) class properties and methods in Actionscript. I want prototype members to be able to access these but have them not be accessible outside of the class.
If I call the variable:
this.myVar = 1
in the constructor, it is accessible not only in the prototype members but also by anyone who has instantiated the class. If I name the variable:
var myVar
it is only accessible in the constructor. The same goes for methods. Is there another way to write this? Is this even possible?
Little help?
View Replies !
View Related
Private + Public Methods In AS2.0
Hi (me again ),
I have defined a function as private within one of my classes:
Code:
private function setInternalProperty (newInternalPropertyValue:String):Void {
aProperty = newInternalPropertyValue;
}
Now, I SHOULD NOT be able to call this method from outside the class! But I can! Look!
Code:
myObject = new MyClass ();
myObject.setInternalProperty ("Hello");
value = myObject.aProperty;
trace (value); // gives "Hello"
Why is this? A bug in MX04?
View Replies !
View Related
Private Vs. Public Functions...
Hello...
I've been reading up on OOP to try and get better at it. What I can't find anywhere, however, is a simple explanation as to what the difference is between marking a function "private" versus "public" in a class...
...can anyone either tell me why you'd use one way over the other (or what the practical distinction is between the two), or else just point me to a web article anywhere that can explain this to me (again, providing a practical example(s))? Thanks!
View Replies !
View Related
Private Message Spam?
Hello,
I have not visited Flashkit in a while and this morning, I got an email stating I have received a private message. Did not know this poster but I was curious so i went to read the message and it was bogus! Something about God, etc.
Has the board been compromised? Does anybody else received these emails?
Thanks,
L.
View Replies !
View Related
[CS3] [AS2] Accessing Private Members
I've got a class called Group that has a has-a relationship with another class, Item, in that it holds an array of Item instances.
I'd like to be able to select several items at once, and then perform the same function on all the selected items. to do this, I'll need an private array in Group that has pointers to all selected instances of Item.
To add to a selection, I have a selectItem function defined in Item. But I need to update the array in Group.
Long story short, is there a way to grant only a specific classes access to another class's functions/members, while maintaining that it is still private to everything else? Keep in mind that there is no inheritance going on here.
View Replies !
View Related
Weird Private OOP Issue
Hi there.
I have a very simple code, just for testing purposes;
ActionScript Code:
// in a .as file:
class Statething {
private var statePopulation:Number;
}
Now, when I do these two different things,
in flash:
ActionScript Code:
var north:Statething = new Statething();
north.statePopulation = 100;
trace (north.statePopulation);
and
north = new Statething();
north.statePopulation = 100;
trace (north.statePopulation);
In the first example, I get a error message, saying that the member is private. This doesn't happen in the latter.
Why is it so?
View Replies !
View Related
Private Variables = Undefined?
When using a callback function like when setting an interval to call a class method.. for some reason when using these callback functions in particular they lose scope somehow and can't seem to recognize the private variables within that class which should be visible to any methods of that class.. is there a way around this.. I'm trying to set up an interval in the main timeline that calls a method of a class.. that method in turn increments a private count variable so that i can keep track of what is being displayed when.. that count variable is coming up undefined as well as the movieclip variables that are private to the class. It doesn't make sense.. if i just run the method without calling it through a callback function it works fine but i want to use the callback functions so i can control the delay between the animations being called within the method. I hope that isn't too confusing .. basically why are callback functions so damn limited and why do they not act as any other function would and maintain scope... it's rediculous!!
View Replies !
View Related
Private/public Question
here's another tidbit i've been wondering about... in other languages.. setting a function in a class to private would keep it from being called from other classes... why can i access any and all private functions and variables in a class from a .fla file? and is there anything i can do to "protect" these functions/variables? thanks!
View Replies !
View Related
What Does Public And Private Mean In This Statement?
what does public and private mean in this statement and when do I need to use it?
this is not my code just using it as an example.
package {
import flash.display.Sprite;
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.EventDispatcher;
public class LoadXML extends Sprite {
public var xml:XML;
private var url:URLRequest;
private var loader:URLLoader;
// make the event variables unchangeable but
// still accessible outside this class
public static const LOADED:String = "loaded";
public static const NO_DATA:String = "noData";
// use: var myVariable:QuotesXML = new QuotesXML(url:String);
public function LoadXML(file:String):void {
url = new URLRequest(file);
loader = new URLLoader(url);
loader.addEventListener(Event.COMPLETE, completeHandler);
loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
}
// use: myVariable.addEventListener(LoadXML.LOADED, loadedHandler);
// and: myVariable.addEventListener(LoadXML.NO_DATA, noDataHandler);
// if there's data in the xml dispatch a LOADED event
// if not, dispatch a NO_DATA event
private function completeHandler(event:Event):void {
if(loader.data) {
xml = XML(loader.data);
dispatchEvent(new Event(LOADED));
//trace("fired LOADED event");
}else{
dispatchEvent(new Event(NO_DATA));
//trace("fired NO_DATA event");
}
}
// always handle IOErrorEvents! - good coding practice.
private function ioErrorHandler(event:IOErrorEvent):void {
trace("IOErrorEvent.IO_ERROR in LoadXML.as " + url);
}
}
}
Thank you
View Replies !
View Related
Private Chat Problem
Hi gurus,
I am working on a private chat(One to One) just like a messenger.
I am using tutorial_text (sample) as base.
Is there any code available for the private chat. Please help gurus..
The Main.asc file is as show below... What should be in the client ?
ActionScript Code:
application.onAppStart = function()
{
trace("Begin sharing text");
// Get the server shared object users_so
application.users_so = SharedObject.get("users_so", false);
// Initialize the history of the text share
application.history = "";
// Initialize the unique user ID
application.nextId = 0;
}
//application.onConnect = function(newClient, name)
application.onConnect = function(newClient, name)
{
// Make this new client's name the user's name
newClient.name = name;
// Create a unique ID for this user while incrementing the
// application.nextID.
newClient.id = "u" + application.nextId++;
// Update the users_so shared object with the user's name
application.users_so.setProperty(newClient.name, name);
// Accept the client's connection
application.acceptConnection(newClient);
// Call the client function setHistory, and pass
// the initial history
newClient.call("setHistory", null, application.history);
// The client will call this function to get the server
// to accept the message, add the user's name to it, and
// send it back out to all connected clients.
newClient.msgFromClient = function(msg) {
application.users_so.send("msgFromSrvr", msg);
}
}
application.onDisconnect = function(client)
{
trace("disconnect: " + client.name);
application.users_so.setProperty(client.name, null);
}
View Replies !
View Related
Private Tutor Madrid
I'm looking for a private tutor in Madrid, Spain.
If interested please contact me at
flash@artificialidea.com
--
Iván F. Villanueva B.
A.I. library: http://www.artificialidea.com
<<< The European Patent Litigation Agreement (EPLA) >>>
<<< will bring Software patents by the backdoor >>>
<<< http://epla.ffii.org/ >>>
View Replies !
View Related
Use Private Function With Interface
I'm working with ActionScript 2 and wanted to use an interface for one of my classes. However, the functions that it would define should be private in the classes that implement the interface. The problem is that I can't define private functions in the interface, and if I leave off any scope in the interface ("function findAndSetInformation():Void;") and make it private in the implementing class ("private function findAndSetInformation():Void {...") I get the error: "The implementation of the interface method doesn't match its definition.
View Replies !
View Related
Basic FMS Multiroom/private , How To?
Hi,
I've created a flash video chat from bits and pieces and now it just hit me. How does it work server side when a user jumps between rooms and private chats?
So if anyone has a simple tutorial/help file or anything to explain the basics of multiroom/private chat session on FMS please let me know.
Now i have a fully working chat that has serverside shared object that keeps track of the users and their settings (camera/mic on/off etc..)so how do a user switch rooms/private?
BR
View Replies !
View Related
FMS Returning Private IP Instead Of Public Ip
Ok here is the situation we have a FMS server setup behind our Firewall with the NAT running as well. The port 1935 is open on the firewall for the FMS server and everything seems to be working internally but when I try to access the the stream from outside the network it does not work at all.
The interesting thing is when I netstat the box that I am making the call from it is getting the 10.xxx.xxx.xxx private address from the FMS server and runs through the ports it should ( 1935, 80, 443 ) but I can not for the life of me figure out why it would be getting the 10. address and not the public IP..
Any help on this issue would be great.
View Replies !
View Related
Why Is It That AS3 Does Not Support Private Constructors As AS2 Does?
Why is it that AS3 does not support private constructors as AS2 does?
Private constructors are standard in most OOP languages (for example
C++ and Java) and were supported in Actionscript 2. However, this is
not the case in AS3 which only allows its constructors to have the
'public' access modifier.
I have legacy code that I hope to migrate to the AS3 platform. Some
key elements of my code rely on design patterns like the Singleton
pattern which in turn depend on private constructors. I could refactor
my code but, ultimately, I would lose the benefits of the pattern
(ie. one and only one instance of the Singleton class).
I have also used private constructors to simulate enumerated types
much like the enums you would find in Java 5 and up. But I can't
use the same implementation in AS3 without private constructors.
I do not want to resort to mixing legacy code with new AS3 code to
keep functionality intact. Are there any possible work-arounds for
this issue?
If not, are there any lobbying groups I need to know about so that
we can get this feature back?
View Replies !
View Related
Public, Private And Static... Oh My
Hi All,
Im just starting to get my hands into Action Script v2, and Im having a really hard time working out what the difference is between Public, Private and Static Variables, it seems that declaring variables in these types makes no difference what so ever to the avaliablility of my variables...
Could someone be so kind as to put me on the right path?
Thanks in advance.
View Replies !
View Related
Classes: (not So) Private Variables?
ActionScript Code:
class Vector2d extends Math {
private var x:Number;
public var y:Number;
var ux:Number;
var uy:Number;
var mag:Number;
function Vector2d(n1:Number, n2:Number) {
x = n1
y = n2
getMag();
getUnit();
}
function getMag():Number{
mag = sqrt((x*x)+(y*y))
return mag
}
function getUnit():Void
{
ux = x/mag
uy = y/mag
}
}
ActionScript Code:
import Vector2d
n = new Vector2d(150, 100)
trace(n.x)
n.x+=150
trace(n.x)
I can't seem to get my private variable, x, to be private. From my understanding of private variables, tracing n.x should throw an error, and adding 150 should throw an error. I've tried changing the variable's name, and the cast type, to no avail. The first trace goes through, the addition goes through, and the second trace goes through.
I'm new to classes, so I could easily be overlooking something vital. But the vars need to be private, because I want to use get/set to update the variables when one or another changes. For instance, if 50 is added to the y value, the magnitude and unit vectors would change, so I want to update them using getMag and getUnit. That whole system would be thrown off if the user had direct access to the properties. If for some reason this whole idea is impossible, let me know.
View Replies !
View Related
Private/public Problem
Hi.
Everything I need is find some nodeValue in xml file like this:
Code:
<school name="13">
<place name="facade">1.jpg</place>
<place name="entrance">2.jpg</place>
<school>
I wrote an abstract xml class which loads file:
ActionScript Code:
class ruhe.util.AbstractXML extends XML { private var link:String; private var event:String = "onXMLLoad"; private var errorEvent:String = "onXMLLoadError"; var dispatchEvent:Function; var addEventListener:Function; public function AbstractXML(xml_url : String) { super(); EventDispatcher.initialize(this); ignoreWhite = true; link = xml_url; this.load(link); } private function onLoad(success:Boolean):Void { if(success) { this.dispatchEvent({type: event}); } else { this.dispatchEvent({type: errorEvent}); } }}
and xml handler class:
ActionScript Code:
class ruhe.school.XmlHandler { private var info : AbstractXML; private var hash : Object; public function XmlHandler() { info = new AbstractXML("tree.xml"); info.addEventListener("onXMLLoad", Proxy.create(this, processXML)); info.addEventListener("onXMLLoadError", Proxy.create(this, raiseError)); } private function raiseError() : Void { throw new Error("no xml found"); } private function processXML() : Void{} public function find(lookFor : String) : String { for (var n : Number = 0; n < info.firstChild.childNodes.length; n++) { if(info.firstChild.childNodes[n].attributes.name == lookFor) { return info.firstChild.childNodes[n].firstChild.nodeValue; } } }}
find method doesn't work. it returns undefined. But when I change it to private and call from the processXML method everything works well.
ActionScript Code:
private function processXML() : Void{ trace (this.find("entrance")); <i>==> 2.jpg</i>}private function find(lookFor : String) : String{ for (var n : Number = 0; n < info.firstChild.childNodes.length; n++) { if(info.firstChild.childNodes[n].attributes.name == lookFor) { return info.firstChild.childNodes[n].firstChild.nodeValue; } } }
I thinck there is a stupid mistake somewhere in my code. I need public function find, not private.
View Replies !
View Related
Keeping XML Files Private
Hello folks
I'm having a bit of a problem trying to keep some files safe, here's the deal:
I'm creating a quiz for the website of a bar (or pub or whatever). The contestants have to answer 20 questions about rock and music, and depending on their score they get different prizes from the bar.
The motor of the quiz is made using flash, and the bank of questions (120 so far) is in an XML file that the SWF loads, picks a subset of questions, and verifies.
The problem is that this file is perfectly visible for anyone with enough curiosity and experience, because it's in the same server, and obviusly, anyone with access to the file won't have much problem solving the quiz, and getting the prizes.
I tried securing the XML with .htaccess but I just can't find a way to make the XML invisible for the web browsers but still visible for the SWF. I tried with the PHP technique for external domains exposed here but still the PHP can't see the file.
I also tried putting .htaccess and .htpassword protection to the XML but then the browser prompts for user and password when the SWF tries to reach the XML.
Any ideas? Perhaps some special .htaccess trick to select who can open the XML? Or a Flash tweak to open the XML in some other way? A way to send the user and pwd so the browser doesn't prompt to the user?
Thanks everyone.
View Replies !
View Related
Public, Private And Static... Oh My
Hi All,
Im just starting to get my hands into Action Script v2, and Im having a really hard time working out what the difference is between Public, Private and Static Variables, it seems that declaring variables in these types makes no difference what so ever to the avaliablility of my variables...
Could someone be so kind as to put me on the right path?
Thanks in advance.
View Replies !
View Related
Private Message System
Hi Guys,
I am developing a PMS ( Private Message System ) to use in our extranet and also offer it for our clients. to enter in contact or follow the customer service in our extranet.
This new tool are developed using flash, php and xml.
please check at:
http://www.insenic.com/tst/FlashIM/flashIM.php
Instructions:
1. Open 2 browsers and enter the url: http://www.insenic.com/tst/FlashIM/flashIM.php of each one of the browser windows.
2. on the browser 1:
username : guest
password : guest
3. on the browser 2:
username: demo
password: demo
4. both browser click on the Private Message option on the bottom
( you will see the INBOX )
5. Now you can compose a new message from guest to demo or from demo to guest and check it online how works...
6. after send a message you must click in the private message again to show your inbox and there you can click in the outbox button to see your sent message
I still making some adjustments but basic work everything.
Please any comment or suggestion let me know here !
I hope everybody like the idea !
View Replies !
View Related
Private Static Functions?
Hi all,
Just wondering in which case would you use a private static function in AS2.0.
Is it even possible or is would it be a syntax error? (I guess I'll have to try to find out, hehe).
Anyways, hope someone out there knows!
View Replies !
View Related
Setting A Private Var In A Class
Hi all just stared action scripting and having a bit of a problem with my class.
Bascially I want to load a value from a test web service (which just returns a string value 'hello world'), the class will get this value and once the result has been returned call a function on the main movie time line that sets a label to the web service result.
The webservice result is being stored in one of the classes properties (webResult). However once the class function (setData) that sets the web service result has finished excuting webResult reverts back to its default value almost like setData has its on reference to webResult that only exists for the scope of the function.
I've tried using a normal function and a set function (the set function crashes the code), I successfully using a ser function else where in the class though.
Heres a copy of my class, hope some one can help its driving me nuts!
ActionScript Code:
import mx.services.*;
class testClass
{
private var myName:String;
private var monkey:Boolean;
private var counter:Number;
private var conStr:String;
private var aWebSer:Object;
private var webResult:String;
private var movieRoot:Object;
function testClass(aName:String, aMonkey:Boolean, aMovieRoot:Object)
{
//constructor
myName = aName;
monkey = aMonkey;
counter = 0;
conStr = "http://10.0.0.60/webserviceTest/test.asmx?WSDL";
movieRoot = aMovieRoot;
webResult = "set here";
}
public function getWebData()
{
trace("get web data called");
aWebSer = new WebService(conStr);
var myResultObject = aWebSer.HelloWorld();
myResultObject.onResult = setData;
//myResultObject.onResult = myWebResult;
}
/*public function set myWebResult(result:String):Void
{
trace(result);
webResult = result;
}*/
public function setData(result:String)
{
trace("get data called");
webResult = result;
trace("webResult = " + webResult);
_root.wobbler(webResult);
}
public function get myResult():String
{
trace("my result called: " + webResult);
return webResult;
}
public function setMyName(newName:String):Void
{
//sets the name
myName = newName;
}
public function get monkeyName():String
{//returns this things name
return myName;
}
public function set monkAbility(monkeyness:Boolean):Void
{//sets the year
monkey = monkeyness;
}
public function get monkAbility():String
{
if (monkey)
{
return "I'm a monkey damn it";
}
else
{
return "No monkeys here sir";
}
}
}
View Replies !
View Related
[AS2] DispatchEvent Vs. Private Functions
Ok, so I've been doing some researching on AS2.0 and using Classes and the such. One thing I wanted to learn how to use was the eventDispatcher. I figured it out, and it works great, but I found another way which is probably not the best programming practice. I'll post it and let you AS2.0 guru folks tell me why it's wrong.
Basically, I just created a blank private function inside my class. I call this function once a script is done doing it's job. Similar to XML.onLoad used in the XML object.
The eventDispatcher, although more flexible, has alot more code. I found this to be an easier way of doing the same thing.
Here's the code.
The MessageBroadcaster class
ActionScript Code:
class MessageBroadcaster {
function dispatchEvent() {};
function addEventListener() {};
function removeEventListener() {};
function MessageBroadcaster() {
// set instances up as dispatchers:
mx.events.EventDispatcher.initialize(this);
}
public function moveMe():Void{
// Listener dispatch (event dispatcher way)
dispatchEvent({target:this, type:"onMove"});
// function event (my way)
onMove();
}
// my private method for (my way)
private function onMove(){};
}
This goes in the FLA.
ActionScript Code:
stop();
// create an instance of the MessageBroadcaster class
myMB1 = new MessageBroadcaster();
// define an object to listen to myMB (Event Listener way)
myObj = new Object();
myObj.onMove = function() {
trace("Listener: onMove()");
}
// subscribe myObj to both MessageBroadcaster
myMB1.addEventListener("onMove",myObj.onMove);
// Assign a function to the event (My Way)
myMB1.onMove = function (){
trace("Function : Move");
}
// trigger the event
myMB1.moveMe();
If you run it, you'll notice that both my events get called. The difference is the amount of code required to do a similar function.
So... why shouldn't people use this method?
View Replies !
View Related
Isnt The Variables Private In A Function ?
Hey, quick question. I have a function that uses among others a setintervall().
Lets say it use it like this
myFill(clip1,clip2);
This fills clip1 with clip2 and it works fine.
But if I want to clips to be filled at the same time:
myFill(clip1,clip2);
myFill(clip3,clip4);
Then only the last one is being filled!
I thought the variables in a function were private.
How do i construct the call so that I get "new" variables instances?
Thanks!
View Replies !
View Related
Use Your Private And Public Variables Wisely T_T
An issue that has caused me 2 weeks worth of problems turned out to be a simple one.
I had code such as this
code:
// ini vars
someArray = new Array();
totalArray = new Array()
function one(){
while(someArray.length > 0){
someArray.pop();
}
// someArray is given values //
someObject = new Object();
someObject.holdingArray = someArray;
totalArray.push(someArray);
}
function two(){
while(someArray.length > 0){
someArray.pop();
}
// someArray is given DIFFERENT values //
someObject = new Object();
someObject.holdingArray = someArray;
totalArray.push(someArray);
}
sorry for the terrible fake code, but what was happening was totalArray.holdingArray[0] and totalArray.holdingArray[1] would be the same values causing all sorts of crap. basically holdingArray[x] was one away from the values it should have been.
What fixed it?
code:
// ini vars
totalArray = new Array()
function one(){
someArray = new Array();
// someArray is given values //
someObject = new Object();
someObject.holdingArray = someArray;
totalArray.push(someArray);
}
function two(){
someArray = new Array();
// someArray is given DIFFERENT values //
someObject = new Object();
someObject.holdingArray = someArray;
totalArray.push(someArray);
}
using private variables fixed it... may seem simple here, but on a 500 line program that is working... almost perfectally it was the last place i looked.
Well hopefuly this helps some one but I just wanted to vent my frustration over such a stupid problem that has held me up. Well at least I learned something
View Replies !
View Related
|