Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Problem Mit Methods



hi
my methode getDataProvider() doent show me the correct value of my var "xmlDataFiltered". The trace cmd in "onXMLLoaded()" shows the full XML data.


why???



PHP Code:


class Presentation
{
    var slideCounter:Number = 0;
    var xmlDataFiltered:XMLNode;
    var xmlNode:XMLNode;
    /*
      constructor parse the XML
    */
    public function Presentation(url:String)
    {
        // Referenz auf aktuelle Instanz speichern
        var ref:Presentation = this;
        var xmlData:XML = new XML();
        xmlData.ignoreWhite = true;
        xmlData.onLoad = function(success)
        {
            ref.onXMLLoaded(success, this);
        };
        xmlData.load(url);
    }
    private function onXMLLoaded(success:Boolean, xmlData:XML)
    {

        this.xmlDataFiltered = xmlData.cloneNode(true);


        // remove childrens
        this.removeSlideChildren(this.xmlDataFiltered);
        
        // this trace show correct data!!
        trace("xml"+this.xmlDataFiltered);



    }
    public function getDataProvider() {
            // this trace shows -> "undef."
            trace(this.xmlNode);

            return this.xmlDataFiltered;


    }
    /*
      Remove "slide" childrens
    */
    private function removeSlideChildren(node:XMLNode)
    {        
        do
        {
            // remove if it is a "slide"
            if (node.nodeName == "slide")
            {
                slideCounter++;
                this.removeChildren(node);
            } else
            {
                // rekursiv an go deeper into the tree if its not a "slide"
                this.removeSlideChildren(node.firstChild);
            }
            // loop until threre are no more childs
        } while (node=node.nextSibling);


    }
    /*
      Remove all childrens
    */
    private function removeChildren(node:XMLNode)
    {
        // remove each child
        while (node.childNodes.length != 0)
        {
            node.childNodes[0].removeNode();
        }
    }
}



FlashKit > Flash Help > Flash ActionScript
Posted on: 10-03-2005, 05:35 AM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Overriding Base Class Methods While Calling Original Methods
I would like to write a class that extends XMLSocket. I'd like to call my class RPCSocket. Among other things, I want to add a property which indicates that the socket is 'waiting to connect'. This would mean that the connect() method of XMLSocket has been called but the CONNECT event has not yet been dispatched. I'll therefore need to override the CONNECT and CLOSE methods of XMLSocket in my class, RPCSocket.

I haven't yet seen any reason why I can't override these methods -- they are neither constant nor static nor final and do not implement an interface method (as far as I can tell) and they are inherited.

I obviously need to call the original connect() and close() methods of the XMLSocket, however. Is this code the proper way to do this? Can anyone see any particular problem with this?

code:
package {
class RPCSocket extends XMLSocket {
public var boolWaitingToConnect:Boolean = false;

public override function connect(host:String, port:int):void {
boolWaitingToConnect = true;
super.connect(host, port);
}
public override function close(host:String, port:int):void {
boolWaitingToConnect = false;
super.close();
}
}
}

Static Methods Vs. Instance Methods And Memory Usage
Hello all, I'm pretty green to OOP (at least "real" OOP) and am trying to wrap my tiny little brain around something. I understand the difference between static and instance methods in the practical sense, i.e. how the static modifier affects a method for in a class. What I'm not 100% on is memory usage and whether I should even care. Here’s my specific scenario for context:

I am creating a package for list generation, rendering and editing, there are a number of classes in the package; Item, PlainList, EditableList and DragDropList. At a minimum, one of the list constructors is passed a target movie (where to draw the list), itemName (symbol name for Item constructor) and dataList (data items for Item constructor). There is also an EventDispatcher that fires "onInitList", "onInitItem", "onSelectItem", etc. These lists could be hundreds of items long and contain sub-list instances. So, long story there could be thousands of list/item instances at a time.

The majority of methods (in pretty much all classes) could be written as static by simply passing the target instance. For public methods, I would make lightweight wrappers that call the appropriate static method, for example:


Code:

class PlainList {
public function PlainList( target:MovieClip, itemName:String, dataList:Object, margin:Number, xOffset:Number, yOffset:Number, rows:Number ){
//bunch'o'code here
}
public function draw( type:String ){
if ( type == "grid" ) PlainList.drawGrid( this );
else PlainList.drawList( this );
}
private static function drawGrid( pl:PlainList ){
//bunch'o'code here
}
private static function drawList( pl:PlainList ){
//bunch'o'code here
}
}



As I understand it, if I use static methods, the method is instantiated only once for the class and there is only one pointer to it. If I were using instance methods each method is uniquely instantiated with it's own memory space and pointer for ever instance of the class. Given that there could be thousands of class instances at a time each with 20-30 methods, does the technique described above make sense? Will I be saving memory? Is this bad OOP? And finally, although right now I am using AS2 in Flash 8, I will be updating to Flash 9 ASAP, any implications regarding AS3? For example, usage of the "protected" and "final" modifiers? Thanks.

Overriding Methods While Accessing Original Methods
I would like to write a class that extends XMLSocket. I'd like to call my class RPCSocket. Among other things, I want to add a property which indicates that the socket is 'waiting to connect'. This would mean that the connect() method of XMLSocket has been called but the CONNECT event has not yet been dispatched. I'll therefore need to override the CONNECT and CLOSE methods of XMLSocket in my class, RPCSocket.

I haven't yet seen any reason why I can't override these methods -- they are neither constant nor static nor final and do not implement an interface method (as far as I can tell) and they are inherited.

I obviously need to call the original connect() and close() methods of the XMLSocket, however. Is this code the proper way to do this? Can anyone see any particular problem with this?


ActionScript Code:
package {
    class RPCSocket extends XMLSocket {
        public var boolWaitingToConnect:Boolean = false;

        public override function connect(host:String, port:int):void {
            boolWaitingToConnect = true;
            super.connect(host, port);
        }
        public override function close(host:String, port:int):void {
            boolWaitingToConnect = false;
            super.close();
        }
    }
}

Methods Called From Methods
I created a class, set some methods for the class, and registered to an object. Is it possible to call methods for this class inside other methods inside the class? I mean, if there were two functions called 'a' and 'b', would it be possible to do something like:



Code:
myClass.prototype=function(){}
...
myClass.prototype.a=function(){
...

b()

...
}
myClass.prototype.b=function(){
...
}
...

Methods Called From Methods
I created a class, set some methods for the class, and registered to an object. Is it possible to call methods for this class inside other methods inside the class? I mean, if there were two functions called 'a' and 'b', would it be possible to do something like:



Code:
myClass.prototype=function(){}
...
myClass.prototype.a=function(){
...

b()

...
}
myClass.prototype.b=function(){
...
}
...

[F8] What Are Methods.
An Object is everything you can create and put on the stage.

Properties is everything that makes the Object different to other objects such as, colours, position, hight e.t.c.


Can someone explain to me what Methods are like you would explain it to a 30 year old that needs to be explained to like a 3 years old?

OOP Methods
I'm new to OOP though not of course to actionscript in general, but I was trying to figure out certain methods or ways of thinking about how to code projects taking full advantage of actionscript 3.0 as I learn it and I came across one that stumped me..

How can you access a function or variable from within a class instance, upwards to its container?

so say I have a .fla:

Code:
var newObject = new myClass();
addChild(newObject);

function DoSomething() {
trace("Calling DoSomething")
}
and the .as

Code:
public class myClass extends MovieClip {
public function myFunction() {
// I would like to call DoSomething from here
}
}
or is this backwards thinking and my brain hasn't adjusted properly to the new paradigm?

Different Methods #1
Hi there!

I am working on my base .swf for my website and i was wondering. Is it better loading all the .swf seperatly from different locations or just making it all in one big .swf.

I think the small .swf's are better but i am not sure. Also should i load my 3 different music tracks from 3 different swf's because doing it that way i can vary them easier than normal. Just wondering if i am doing my website a bad way.

VisualAid-

Methods /javascript Help
I am trying to place a javascript in my html that will cause an .swf file to skip to a specific frame. I know it involves the GoToFrame flash method but I am not aure how to write the javascript. It is further complicated by the fact that the flash movie (.swf file) and the html file are in different framse of a frame document.

Any ideas anyone?!?!?!

Flash Methods And IE On A Mac
Does anyone know why a flash methos that works perfectly on a PC won't work on a Mac running IE 5?

trying to use the SetVariable in JavaScript which is done on a page load in one frame, setting the variable in the .swf in another frame.

Any help would be appreciated.

Flash Methods In NS6
hi,
i'm using some flash methods to control a movie with javascript, i'm trying to get this to work in netscape but no joy. is there a way?
var mov=document.getElementById("flashmovie");
mov.GotoFrame(2);

thx

New To Actionscript, Need To Know Something About Methods
So when you want a method that would be used by a bunch of stuff in your program, would you just put it in a frame in a layer named methods or something? I've got a method that where I want a boolean value to be returned. It looks like this
Function setVar() {
*does stuff to make something = true or false*
return something;

then I have movieclips which each have their own variable and I assign the variable like this.

onClipEvent(enterFrame)
myVar = setVar();
}

I'm doing something wrong though because the program wont work. Inside the function it tests to see if a movie clip that is used as the cursor has come in contact with 'this' which is the calling object isn't it? Any help would be appreciated.

Publishing Methods.
Hey people,

I'm having problems publishing my website... Well not problems, I'll explain.

When I publish, it's a .swf file and an .html file that doesn't do much. This method means someone has to download the entire .swf file, it just doesn't stop. How do I publish so that each page loads individually? This might be a stupid question, I dunno... Do I need more software or what? Any examples?

Best regards,

KD.

Movieclip With Methods Help
I have a small mc that has a button (startMenu) and a menu that animates out when the button is pressed. When the mouse rolls out of the mc it returns to the first frame and waits to be pressed or at least that what I want it to do. The position of the mc is controled by the mc called "follow" that makes if follow the mouse around the screen.

The actionscript in the first frame is:

startMenu.onRollOver = function(){
follow.stop();
}
//when the mouse rolls out start the follower
startMenu.onRollOut = function(){
follow.play();
}
//play the menu animation
startMenu.onPress = function(){
gotoAndPlay("menu");
}

//stop the movieclip here
stop();

At the end of the menu animation the actionscript is:

stop();
//when the mouse rolls off the mc go to the first frame and stop
//start the follow mc again
this.onRollOut = function(){
this.gotoAndStop("start");
follow.play();
}

Like I said above, when the this.onRollout method is called and the mc goes to the first frame the code in the first frame is ignored.

Flash Methods
So, I'm trying to get some javascript to talk to my flash movie... I've found out that flash methods just plain do not work with mac/IE...

They DO work with IE/win, and opera... but I cannot get mozilla/netscape to cooperate.

Does anyone know if flash methods do indeed work with moz... or am I wasting my time?

Flash Methods And NN
Having some difficulty firing a flash method on the window.onload event.

works in IE but NN 7 seems to dislike it.

trying to fire window.document.myFlashObj.play();
I have included the swfLiveConnect=true param in my obj/embed tags.

url to site = http://www.thunderwolveshockey.com

is there anything I am missing?
any help would be greatly appreciated.

thanks in advance,
turtle69

Event Methods...
I'm having some difficulties with functions assigned to objects.

I have a list where the names of my objects are held. From this list I'm trying to assign functions using "= function(){....}" with a for loop.

My list contains all info about the path for each object.

But how do I set up the path to each object?

Please help me!

Flash MX - Methods?
Hi,

i'm familiar with actionscript and have taught myself quite well so far, my knowledge of Java has helped me greatly to understand and write code for Flash. I was just curious whether or not it is possible to write your own methods to use within your code. I know it is possible to write methods in java and i have read that ActionScript is loosly based around the java language, syntax and semantics.

any info wood b great?

Thanks4Reading

ActionScript Get And Set Methods
Can someone please show me how to do the following:
1.get text from a textfield
2.set text to the textfield
3. loading sound in flash
4 and loading a playlist too.

Thanx, I hope that many of you will help me solve these problems.

Flash 5 Methods
is there any good tutorials on functions used as methods in flash 5. i know how to use them but dnt understand how they work. or if someone could explain it to me that would be great.

i am using flash 5.

i put functions into the master movieclip and then i can use this as a method to affect all other instances of that clip. is it possible to use that function without having to use the 'call' or the other command?

i have books on the subject but none of them seem to be very good at explaining this particular topic.

i think i posted somthing similar before but i cant find the thread, so sorry bout that.

so a thorough tutorial on the subject would be great (i already know how to make function and how use use and call them, just a bit hazy on using functions as method, actually dnt understand it)

thanks

Drawing Methods
I am trying to draw a shape at the level of a movieClip, but the code only works if I draw the line at the root level.
The movie clip is attached dynamicaly to the root, and draws the shape - only once- on enterFrame.

myMovieClip.prototype.onEnterFrame = function(){
if (!inited) {this.setHotSpot();}
}

myMovieClip.prototype.setHotSpot=function(){
this.createEmptyMovieClip( "hotSpot", 2 );
trace ("hotspot" + this.hotSpot)
with ( this.hotSpot )
{
lineStyle( 5, 0xffff00, 100 );
moveTo( 10, 10 );
lineTo( 10, 40 );
lineTo( 50, 50 );
lineTo( 50, 10 );
lineTo( 10, 10 );
}

the setHotSpot function doe not work unless I replace "this" with "_root".

Any help would be great.
Thanks
geraldine

Class And Methods
Hello,

I'm testing several methods. Methods 1 & 2 execute as expected. But, my 3rd method "mease" does nothing. Upon starting Method 3 should send a movie clip named "clip1" gliding across the stage.

I invoked method3 the same manner as the first 2 methods.


Any help would be greatly appreciated.

iaustin


//classf
clss = function(age){//f1 classification
this.age=age;
this.mreturnv= this.mpf(); //fcall

}

//--------------------------------------------------------------
clss.prototype.mpf=function(){// f2 method1 fcalled() in clss
return this.age*6;
}
//--------------------------------------------------------------


//--------------------------------------------------------------
clss.prototype.mbirthday=function(){ // f3 method2
this.age++;
this.mreturnv= this.mpf();//fcall add value to where assign to same mfp_calcu
}
//--------------------------------------------------------------


//-------------------- fease ---------------------

clss.prototype.mease=function(){ //f4 method 3
var speed = 10;
clip1._x=400;
clip1._y=250;
a=(100-clip1._xscale)/speed;
clip1._xscale+=a;
clip1._yscale+=a;
this.mreturnv= this.mpf();
}
}

//------------------end fease ---------------------


//--- invokations ---//
ioc = new clss(6); // 1 f class or function one
trace(ioc.mreturnv); // o.p value assigned to

ioc.mbirthday(); // 2 f call value of second method
trace(ioc.mreturnv);

ioc.mease();
clip1.onEnterFrame= mease;


//new invokation v=o.pfm() call assigned value also to mreturn
//functions arew called and assigned called and assigned v=f()

Methods Of Transition?
What technique should I use for transitions? For example, the transition of the stage moving from preloading to the home page of the .swf?

Should I use tweens or AS? Which would be more efficent both file size and convenience?

Disadvantages and advantages of either?

I guess it drives me nuts if I want to figure out every way to do something... made me fail classes back in high school... -_-

Several Methods For Screen The Right Key
1).Useful in flash player,unuseful in webpage:
fscommand("showmenu",fasle)

2).Add parameter at the flash position of webpage:
<param name="menu" value="false">

3).Add action at the first frame of flash:
stage.showmenu=false;

4).Or add action at the first frame of flash:
right = new object();
right.!#111nmousemove = function() {
stage.scalemode = "noscale";
};
mouse.addlistener(right);

5).Or add action at the first frame of flash:
_root.createtextfield("danger", 999, 0, 0, stage.width, stage.height);

Numerical Methods
Hallo!
My aim is to convert some Delphi code => Actionscript code.
I am solving a simple system of two differential equations using Euler method (the most simple method).
The equation i have is: y''+w0*w0*y = 0 - this is the equation of movement for a free oscillator. To use Euler methos i must have first order differentiak equation, that why i divide that 2 order equation into two => we have a system:
z=y'
z'=-w0*w0*y

Euler method gives solution for 1'st order diff. equations, as e have in the system, I'll describe briefly how it works:


we have a differntial equation: y'(x)=dy/dx=f(x,y)
and initial condition: y(x0)=y0
Then the solution of the diff equation (anothewords y values) will ba calculated using this formula: yk+1=yk+h*f(xk,yk)
h - step for x

So..I have Delphi code, you can download source project and also the compiled file from here, that works fine:


Code:
procedure TForm1.Button1Click(Sender: TObject);
begin
g1:=gettickcount();
timer1.Enabled:=true;
memo1.Clear;
memo2.Clear;
memo3.Clear;
memo4.Clear;
t:=0; h:=0.01; y:=1; z:=0; i:=0;
w:=10;
form1.Canvas.Brush.Color:=clred;
form1.Canvas.moveTo(round((g2-g1)/10),round(y*100)+500);
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
g2:=gettickcount();
label9.Caption:=inttostr(g2-g1);

z:=z+h*(-w*w*y);
y:=y+h*z;

u:=cos(w*t);
memo1.Lines.add(floattostr(t));
memo2.Lines.add(floattostr(y));
memo3.Lines.add(floattostr(u));
memo4.Lines.add(floattostr((g2-g1)/10));

form1.Canvas.Pen.Color:=clred;
form1.Canvas.LineTo(round((g2-g1)/100),round(y*100)+500);

end;
And here is a screen of delphi program:



And here is my ActionScript code (you can download flash source project from here ):


Code:
w=10; l=0;
lineStyle(1, 255 << 16 | 255 << 8 | 255, 100);
button code

Code:
on (release) {
t=0; h=0.01; y=1; z=0;
_root.moveTo(t/100,y*100+500);

ti=getTimer();

_root.onEnterFrame=function() {
t=(getTimer()-ti);

z=z+h*(-100*y);
y=y+h*z;

text2.text=y;
_root.lineTo(t/100,y*100+500);

}
}
and flash screen


fps i set to 120fps

And here is the problem: flash calculates good at the beggining, but after several seconds it takes more and more time to calculate y values, and the distance between sinusoidals - is increasing...
I am despered...don't know what to do...delphi works fine...but in flash - such a problem. But i really need that code to work good in flash

Could anyone help me?
I apreciate any ideas!
Thank you!

Classes And Methods
I have written a listBox class which creates a scrollable stack of buttons based on infomation in an XML file, labeling each button "button"+i.

In order to keep the class as reusable as possible, I want a way of altering the buttons' actions depending on what the listBox is controlling. So if the listbox is controlling an flv player, I need buttoni to trigger the playVideo method in an instance of my flvClass. If it is controlling an mp3 player, I need buttoni to trigger the playMP3 method in an instance of my mp3player class etc...

So how can I pass the desired class instance and its method to the listBox class. What data type do I pass it as?

Please and thanks.

Loading Methods
hi all,
loadClip()
loadMovieNum()
loadMovie()

==============
whats the deferance between them? can anyone tell me or directme
thanks in advance

Inheriting Methods
hello

say i have a super class

code: class superClass extends MovieClip
{
public function superClass()
{
//some code here
}
public function hello()
{
trace("Hello");
}
}


how can i use the methods in this super class in classes that extend this super class ??

cause doing something like this

code: class subClass extends superClass
{
public function subClass()
{
hello();
}
}


results in


Quote:





Originally Posted by The compiler


Line 5: There is no method with the name 'hello'.




hopefully a small thing i'm doing wrong

thnx

Static Methods
i made a public static function in my class so i can call it from the timeline, in it i make a instance of a class. but then the instance is counted as static apparently and won't let me run addChild or my methods

Different PreLoader Methods?
Hi Guys,

Just wondering, when i google for ways to do a preloader, there are now so many methods compared to AS2 that i'm a bit lost as to which way to go...

is there one way of doing that is a decent industry standard that is subtly better than the rest, or does it not really matter?

Cheers, love this forum by the way, what a resource!

Overloaded Methods?
I've read that you can't overload constructors, but what about methods in general? I'm building a custom sound player and I'd like to have two different play() methods. Without any arguments, it would simply start at the beginning or resume from a paused position. With a number argument, it would start playing from that position.

Here's what I tried:

Code:
public function play():void
{
// Play the sound file.
// If the sound is paused, resume from paused position.
// If the sound had reached the end, start from the beginning
}
public function play( position:Number ):void
{
// play the sound file from the specified position.
}

Flex 3 gave me Error 1021: Duplicate function definition.

Can I assume from this that overloaded methods are not allowed or is there some way around this error?

Best CMS Engine Methods ?
Hi, I am trying to build a flash CMS that allows visitors full control of each movie clip instance on there pages. The are first authenticated after using a key-combination. Then if verified ...the movie clips show a thin border around when the mouse rolls over each clip. My quest ion is this...Is it best to make the main 'engine' using custom classes...or use functions...of the Flash 8 classes.
They will once chosen the movie clip to edit....click on it...and shown a combo-box menu of choices...to either add text with a wysiwyg editor...this editor sends content back to movie clip...or...they choose a media manager (SWF) and click on either a jpeg or swf to enter in the clip instead.

I am having problems on deciding the best way to go about this project...I have read about 15 ebooks over the last 2 weeks....and have only really made sense of one...(Macromedia Press Learning ActionScript 2.0.for Macromedia Flash 8). This seems to suit my learning curve better....as it is for beginners who are using Flash 8 who want ActionScript knowledge.

Any input would be better than none.
regards

Custom Methods To A MC (OOP)
I have visually constructed a MC and put it in the library. I want to add custom methods & attributes to it. How would I do it through AS & class files? I comprehend how one would extend a generic MovieClip class... but I can't understand the logic of "attaching" a class file to the custom MC that I created.

Thanks in advance!

Calling Methods By Name
Hi, I'm trying to figure out a way to call a method by it's name (stored in a string).

Basically I'm going to have an array like this:
[ [ objectReference:Object, methodName:String ] , [ objectReference:Object, methodName:String ] , [ objectReference:Object, methodName:String ] ... ]

I want to iterate through the array and invoke those methods on the objects. I can't figure out how to invoke a method by it's name stored as a string though. Is this possible in AS? I seems this may be possible in Javascript using something called reflectivity, but I've never done JS before.

I've tried various combinations of eval() and objectReference[methodName], but no luck.

Any help is appreciated, thanks.

A Problem With Methods
I have a class, Race, which contains several private methods (setSpeedometer, updateRace and updateElapsedTime)... A Race object is created inside another object called "game" (from a class called Game). In creating the new Race, I pass it a reference to Game (eg: race = new Race(this); ). Within the object "game", there is another object, "gui" (which contains all the interface elements (speedometer, track representation, elapsed time...)).

The trouble I am having is that for 2 of the methods, I can reference game without a problem, it happily runs..


Code:
private function updateSpeedometer(s:Number):Void {
game.gui.speedometer.updateSpeed(s)
trace(game); // yields [object Object]
}
and...


Code:
private function updateRace(p:Number):Void {
game.gui.trackRep.updatePos(p);
trace(game); // yields [object Object]
}
however...


Code:
private function updateElapsedTime():Void {

// ...

game.gui.elapsedTime.updateTime(e);
trace(game); // yields undefined
}
All three are in the same class, but yet one of them seems like it has a totally different scope (?) or something. Anyone have any ideas on where to start trying to track this one down?

I hope that made some sense.

Any help is appreciated.

Matt

Numerical Methods
Hallo!
My aim is to convert some Delphi code => Actionscript code.
I am solving a simple system of two differential equations using Euler method (the most simple method).
The equation i have is: y''+w0*w0*y = 0 - this is the equation of movement for a free oscillator. To use Euler methos i must have first order differentiak equation, that why i divide that 2 order equation into two => we have a system:
z=y'
z'=-w0*w0*y

Euler method gives solution for 1'st order diff. equations, as e have in the system, I'll describe briefly how it works:


we have a differntial equation: y'(x)=dy/dx=f(x,y)
and initial condition: y(x0)=y0
Then the solution of the diff equation (anothewords y values) will ba calculated using this formula: yk+1=yk+h*f(xk,yk)
h - step for x

So..I have Delphi code, you can download source project and also the compiled file from here, that works fine:


Code:
procedure TForm1.Button1Click(Sender: TObject);
begin
g1:=gettickcount();
timer1.Enabled:=true;
memo1.Clear;
memo2.Clear;
memo3.Clear;
memo4.Clear;
t:=0; h:=0.01; y:=1; z:=0; i:=0;
w:=10;
form1.Canvas.Brush.Color:=clred;
form1.Canvas.moveTo(round((g2-g1)/10),round(y*100)+500);
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
g2:=gettickcount();
label9.Caption:=inttostr(g2-g1);

z:=z+h*(-w*w*y);
y:=y+h*z;

u:=cos(w*t);
memo1.Lines.add(floattostr(t));
memo2.Lines.add(floattostr(y));
memo3.Lines.add(floattostr(u));
memo4.Lines.add(floattostr((g2-g1)/10));

form1.Canvas.Pen.Color:=clred;
form1.Canvas.LineTo(round((g2-g1)/100),round(y*100)+500);

end;
And here is a screen of delphi program:
http://img223.imageshack.us/img223/5061/delphi9qw.jpg


And here is my ActionScript code (you can download flash source project from here ):


Code:
w=10; l=0;
lineStyle(1, 255 << 16 | 255 << 8 | 255, 100);
button code

Code:
on (release) {
t=0; h=0.01; y=1; z=0;
_root.moveTo(t/100,y*100+500);

ti=getTimer();

_root.onEnterFrame=function() {
t=(getTimer()-ti);

z=z+h*(-100*y);
y=y+h*z;

text2.text=y;
_root.lineTo(t/100,y*100+500);

}
}
and flash screen
http://img113.imageshack.us/img113/1753/flash4cy.jpg

fps i set to 120fps

And here is the problem: flash calculates good at the beggining, but after several seconds it takes more and more time to calculate y values, and the distance between sinusoidals - is increasing...
I am despered...don't know what to do...delphi works fine...but in flash - such a problem. But i really need that code to work good in flash

Could anyone help me?
I apreciate any ideas!
Thank you!

Classes And Methods
Hello all,

I have written a listBox class which creates a scrollable stack of buttons based on infomation in an XML file, labeling each button "button"+i.

In order to keep the class as reusable as possible, I want a way of altering the buttons' actions depending on what the listBox is controlling. So if the listbox is controlling an flv player, I need buttoni to trigger the playVideo method in an instance of my flvClass. If it is controlling an mp3 player, I need buttoni to trigger the playMP3 method in an instance of my mp3player class etc...

So how can I pass the desired class instance and its method to the listBox class. What data type do I pass it as?

Please and thanks.

FMS Properties And Methods
Hi,
i need help to include communication properties and methods in Actions tool box


i place communications.XML in Custom classes(C:Program FilesMacromediaFlash 8enFirst RunActionsPanelCustomActions) folder still no classes found in actions toolbox


any other way ..........

Get/set Methods And Encapsulation
Hi all,

I'm hardly a full-time Flash programmer, so maybe this is obvious if you've spent more time with AS3 than I have.

I've often seen the following described as the "correct" way of implementing get/set methods:


ActionScript Code:
package {
 
  public class Foo {
    private var _someVar:Date;
    function Foo():void {
      //constructor body
    }

    public function get someVar():Date {
       return _someVar;
    }

    public function set someVar(newValue:Date):void {
       // do necessary checks for valid value
       _someVar = newValue;
    }
  }
}

Now of course I know the idea here is to provide a clean interface while maintaining proper data encapsulation. Whatever data checks go into the setter function ensure that the private variable can only take values that make sense in context.

The problem I have is with the getter method. By returning a reference to the internal (private) variable, haven't you completely defeated the purpose of having the getter/setter mechanism in the first place? For example, using the class above:


ActionScript Code:
var f:Foo = new Foo();
f.someVar = new Date();
trace(f.someVar);  //Tue Jan 29 15:17:56 GMT-0600 2008

var d:Date = f.someVar;
d.setFullYear(2020);
trace(f.someVar);  //Wed Jan 29 15:17:56 GMT-0600 2020

Obviously I've altered the value of the internal (private) value and broken my encapsulation.

Of course one can code around this by cloning objects (for classes that have a clone method, anyway), but I'm surprised to see so many examples putting this behavior forward as correct.

Am I missing something obvious? And what, in fact, is the usual way of handling this issue? (I understand that the "primitive" types behave as though they were passed by value rather than by reference, but more complex classes do not.)

Thanks!
--Ed

Run Methods From A Loaded Swf?
after a swf has been loaded and i try to run methods from it or return movieclips... like

myMovie.loadedSWFSprite.test();

it just says....

1061: Call to a possibly undefined method test through a reference with static type flash.display:Sprite.

Adding Methods To Mcs
Hi everyone:
I´m trying to add a method to a MC that is on the stage called my_mc.
Very simply the code on the flas in as3 is this:

ActionScript Code:
function trazando(texto:String){
    trace(texto)
}

my_mc.trazando("Esto funciona");
Really, what I want is something like this:

ActionScript Code:
function trazando(texto:String){
this.addEventListener(MouseEvent.MOUSE_OVER, quiover);
    function quiover ($event:Event){
    trace(texto);
        }
my_mc.trazando("Esto funciona");
But it is something wrong. Anybody knows why?
Thank you very much.

SWF Protection Methods
I am developing a game in flash 5 for one of my clients, this game comes with a prize for the highest score and therefore i need to keep my code and score details away from cheats.

At the moment I am passing the score to a php script, but software such as ASViewer reveals how this is done. So because of this, i need a nifty approach to some security methods in which will protect code from the latest swf readers Any ideas????

I have downloaded ASO pro to disguise my code but this stopped the main game script. I also thought about dropping a cookie from flash but my client (being as they are) does not like that idea.

Any ideas/methods whatever welcome.

thx

Sound Methods
i got a question about playing songs on my website.
i have a song that the user can listen to if they want and i was
wondering if it would cause my page to load slower if i put the song in my library and use a play button to access it(cause on the net the page does seem to load slowly) is there a method that i can use where the song is just on my server space and it will load when they push play, actually i know there is but i don't know how to do it.directions to a good tute would be much
appreciated.thanks

Trouble Using CFC Methods
Hey!

I'm a little new to Remoting and VERY new to ColdFusion, but I've run thorugh a lot of tutorials, and things have gone well... until now. I can't make my connection to the service / method of the CFC work. I have done fine connecting to services with .CFM pages... maybe there is a different syntax?

There is a tutorial on MM's website... they give you a coldFusion component to use...

I put the rdbmsResolver.cfc in a folder in my web root, called "timetrax".

To access a method inside the CFC, I tried this:


ActionScript Code:
//connect to the service
this.phoneLogService = new Service("http://{my server ip}/flashservices/gateway", null, "timetrax", null, null);
//call the remote method
getDataPC = phoneLogService.rdbmsResolver.todd();
//set the result event handlers as usual

where "todd" is a method I created in the CFC just to simplify things... just returns a string... No dice.
If I keep the same service and connect to a CFM that I put in there, it works great...

I was assuming the call to the remote function was supposed to be:

myPendingCall = myService.NameOfCFC.NameOfMethod(p1, p2);

Am wrong?

The Netconnection debugger shows that the connection was attempted, but nothing after that.

I can send files, if they would be helpful...

Get/set Methods Class
Hi everybody,

i am building a class and need get/set methods.

I am using:


PHP Code:



private var $name:String;
//...
// rest of the class
//...
public function set __name(n:String):Void
{
   this.$name = n;
};
public function get __name():String
{
   return this.$name;
}; 




This cause me error. Debugger says that the property "$name" is not static.
I don't want it to be static, just private, i want it to be in all class instances.

You can only use get/set methods for private static member of a class ?
If not, what am i doing wrong?

thanx

OOP And Class Methods
I have an OOP problem. I'm new to OOP so it can be very easy or impossible. Either way - I don't know where to look for the answer.

I have linked a class to a number of movieclips that i have on stage. The movieclips are clickable (buttons) and I want all buttons to be changed when I click one of them. E.g i want all to be dimmed if one is clicked. My problem is that i don't know how to call all my instaces of a class from one, or if it is possible!

Do I make any sense? :)

/E

Component & Methods
Hi Guys,
I've made a UI Component called ImageBox... There are lots of methods. It works fine.
What i need to know is how can we access component's methods in actionscripting environment.

do i need to use Interface? if yes please give me an example.

Thank you very much for reading this...

Looking For Methods To Achieve This
Hi folks,

I want to make my swf stream musics in a continuous way. Say you have a 10 minutes song, normally when visitor1 opens the client swf they start listening it from beginning, 3 minutes after if visitor2 jumps in and opens they too start from the begining, and so on so forth for other visitors. What i want though is to find a way such that if visitor1 opens the client while the song is playing since 2 minutes they start listening only the portion that is left, not from the beginning; visitor2 jumps in 3 minutes after him, they just listen the remaining 5 minutes of the song, see what i mean?

I can i do that? Is they any specific methods for that, or how would you define a custom approach to achieve this? Can flash alone do that or would it require server sides codes in other languages?

Thank you

Methods And Functions
can someone please explain to me the difference between methods and functions. thank you

Copyright © 2005-08 www.BigResource.com, All rights reserved