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








Updating Function Values


I have 3 variables on the _root timeline.

var a = 50;
var b = 75;
var c = 100;

then i have a prototype which uses those

MovieClip.prototype.myName = function(a,b,c){
...
}

I then have 3 sliders which change the values or a,b and c.

My question is: How do I get the prototype to update the values of a,b and c as the sliders change the values of the variables?

-Regards,
Halian




KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 05-21-2007, 11:55 AM


View Complete Forum Thread with Replies

Sponsored Links:

Updating Values For Vars In Swfs
Is there any way to update the values of variables in multiple swf files semi-permanently, with very little or no ASP, etc.

I'm also working on a MUD game.. any suggestions for databasing, XML Servers, etc? Free ones.. I'm broke. ^.^

Thanks..
Rejar

View Replies !    View Related
Storing Several Values Externally And Updating Them
I think I need a bit of help here.

I am working on a piece in which I want to keep track of what all users -- whenever they might view the piece -- do within the piece. There are really only two options for users [A or B] and I want to keep track of what each viewer does and then the total number of viewers.

I have no problem getting info from external txt files via loadVars; my question is whether I can then change the content of a txt file out of flash.

Alternately is there a way I can trigger a JAVA class to perform the necessary manipulations of the txt file.

I am hoping there is a way I am missing for ActionScript to rewrite a txt file that I am missing, or perhaps some other way to store an variable that can be accessed and updated each time a new user views the piece that isn't reset each time the swf is loaded.

I would greatly appreciate your suggestions.

Thanks.

View Replies !    View Related
Saving Variable Values And Updating Rather Than Overwriting
Ok, heres what i wanna do.

The user fills in a couple off input text boxes that tells me about himself.
The values are passed into a text file in the root but also displayed in a dynamic window in the movie. Right now what i want for it to do is when another user fills in the text boxes i wan the information to add itself to the text file in root but not overwrite whats already there, and it must also show up underneath the original text that was added in the movie so i have a list of peoples descriptions.
A bit like a guestbook i suspose.
I hope u understand what im after.

View Replies !    View Related
Function Populated By Node Values Returning Undefined Values
I have been working on some code which extracts the information from an xml document, styles it with css and then loads the various node values into a text field and arrays. The user click on a link in the text field which calls myFunction using asfunction and that in turn should enter the array values relating to that link into text fields.

Everything in general seems to work OK except the value that is returned to the two text fields on pressing the link in the CCTextField "which in turn calls myFunction" returns undefined for those values of the arrays. I check the agency[2] value in the function that populates the arrays and the value is returned as it shoiuld be so it appears there must be something amiss with myFunction, or at least it would seem so.

Any takers as to what this problem might be?

I have supplied some shortened code below.


PHP Code:



CCTextField.styleSheet = myStyle;
// NOTE: CCTextField styleSheet has been created beforehand
my_xml = new XML();
// NOTE: my_xml has been created beforehand


my_xml.onLoad = function(sucess) {
    if (sucess) {
        processXML(my_xml);
    }
};
// Load up the XML file into Flash
my_xml.load('TEST.xml');
// This is the function that will be called when
// the XML document is loaded succesfully
function processXML(xmlDoc_xml) {
    
    var listText_comm = ""; // List text variable
    var entryNum = 0; // Entry number variable
    var agency = new Array(); // Agency array
    var production = new Array(); // Production array
    
    for (var n = 0; n<xmlDoc_xml.firstChild.firstChild.childNodes.length; n++) {
    
        categoryNodeName = xmlDoc_xml.firstChild.firstChild.childNodes[n].nodeName;
        
        if (categoryNodeName == "client") {
            listText_comm += "<a href='asfunction:_root.myFunction," + entryNum + "'>" + xmlDoc_xml.firstChild.firstChild.childNodes[n];
            trace("client " + xmlDoc_xml.firstChild.firstChild.childNodes[n]);
        } else {
            if (categoryNodeName == "title") {
                listText_comm += " - " + xmlDoc_xml.firstChild.firstChild.childNodes[n] + "</a>";
                trace("title " +xmlDoc_xml.firstChild.firstChild.childNodes[n]);
            } else {
                if (categoryNodeName == "agency") {
                    agency[entryNum] = xmlDoc_xml.firstChild.firstChild.childNodes[n].firstChild.nodeValue;
                    trace("agency " +xmlDoc_xml.firstChild.firstChild.childNodes[n].firstChild.nodeValue);
                } else {
                    if (categoryNodeName == "production") {
                        agency[entryNum] = xmlDoc_xml.firstChild.firstChild.childNodes[n].firstChild.nodeValue;
                        trace("production " +xmlDoc_xml.firstChild.firstChild.childNodes[n].firstChild.nodeValue);
                        entryNum++; // click over the entry number by 1
                    }
                }
            }
        }
    }
    
    trace("AGENCY 2 = " + agency[2]); // this returns agency number 2 OK
    
    _root.CCTextField.text = listText_comm; // CCTextField shows this text OK
}

function myFunction(listItem) {
    clientF = agency[listItem]; // THIS RETURNS undefined ON PRESSING THE LINKS IN CCTextField
productionF = production[listItem]; // THIS ALSO RETURNS undefined ON PRESSING THE LINKS IN CCTextField

    trace(listItem); // this trace = the list item passed by asfunction OK


View Replies !    View Related
Updating GetBounds After Scale Function
----------code---------
function mapScale() {
_root.map._xscale = _root.scaleBy;
_root.map._yscale = _root.scaleBy;
_root.bounds = getBounds(_root.map);
//trace(_root.map._width);
updateBounds();
}
function updateBounds() {
l = _root.bounds.xMin;
r = _root.bounds.xMax;
t = _root.bounds.yMin;
b = _root.bounds.yMax;
}
-------end code-------


The above function does not seem to update the getBounds...how though _width and _height properties update fine...

The background to this is I need to scale a map interactively and want to retrict the movement to the bounds of the window size...as you would...any help, as always, is gratefully received!

If needed I can send the fla on request...

ss

View Replies !    View Related
Making A Function And Updating It Every Minute
Hi.

I need to make a function that can update itself every minute. can anybody help med?
(to be exact it has to update a clock, so different things can be triggered when certain times come)

Thanks, Andy

View Replies !    View Related
Question : Flash Auto Updating Function
hi all, i would like to ask for a favor. I did a websiet with flash animation embedded to it. But when i keep on updating teh flash animation, those people or visitors with the previous flash files inside their temporary internet folder could not view my latest updates.

is there a functions for flash to auto update itself???

or is there any alternative i can use for teh flash embedding part???

thank you for any replies

View Replies !    View Related
Function To Set Values
I want to assign a value to a variable with an alternate to be assigned if the value is not valid.

In perl, I would say:

Code:
myVariable = something || something_else;


What is the easiest way to do this in ActionScript?

I tried:

Code:
function setValue(which,val,alt) {
if (val == null || val == undefined)
which = alt
else
which = val
}

var myVariable = "test"
setValue(myVariable,"Value","Alternate")
trace(myVariable)


...but that doesn't work. I tried looking in the Flash manual for how to pass variable pointers, but as usual, the Flash manuals have proven to be no help.

View Replies !    View Related
HELP Need A Function To Return 2 Values
ok, i've written a function and im trying to get it to return 2 different values

example of what i need


Code:
thisArray = myFunction(args)
----output----
thisArray[0] = first value
thisArray[1] = second value
is there a way to do this?

or do i return 1 string value which is a concantenated string of 2 values with an identifier in between?


Code:
thisVariable = myFunction(args)
thisArray = split(thisVariable, ":")
----output----
thisArray[0] = first value
thisArray[1] = second value
where the : is the identifier

im trying the second method now, but for some reason it returns 'undefined' all the time...

View Replies !    View Related
Can You Trade Function Like Values?
Hello, I was wondering can you do something like the following?


Code:
tempArray[0].onRelease = movArray[0].onRelease;
tempArray[1].onRelease = movArray[1].onRelease;
tempArray[2].onRelease = movArray[2].onRelease;

movArray[2].onRelease = tempArray[0].onRelease
movArray[1].onRelease = tempArray[1].onRelease
movArray[0].onRelease = tempArray[2].onRelease
I have a series of objects that rotates after a function completes. I want to make the objects react as they should for their spot. Any ideas?

View Replies !    View Related
Different Return Values For A Function?
Hey,

I have a function which could return different types of possible datatypes,
depending on the input. What should i set to be the return value of the function in the definition?

Isn't this ok:

ActionScript Code:
public function getSubData(inDataType:string):Object {
  var obj_to_return:object;
 if (inDataType == "arr") {
       obj_to_return = global_array; //An array with some sprites in it.
  }
 else if (inDataType == "sprite") {
     obj_to_return = global_array[0]; //A sprite
 }
  return obj_to_return;
}

When using the function in my code:

var sprite_obj:sprite = getSubData("sprite");

i get:
"1118: Implicit coercion of a value with static type Object to a possibly unrelated type..."



Is this possible?
Thanks,
Guy

View Replies !    View Related
My Function Won't Read Values
I have a one frame movie with the following function in it.

function setTextboxes (AppName, DragBoxNum, Solution, EPS, Correlation, Report, Device, User, URL) {
if (AppName == CurrentApp1) {
_root.Solution1.text = Solution;
_root.EPS1.text = EPS;
_root.Correlation1.text = Correlation;
_root.Report1.text = Report;
_root.Device1.text = Device;
_root.User1.text = User;
_root.URL1.text = URL;
} else if (AppName == CurrentApp1) {
_root.Solution2.text = Solution;
_root.EPS2.text = EPS;
_root.Correlation2.text = Correlation;
_root.Report2.text = Report;
_root.Device2.text = Device;
_root.User2.text = User;
_root.URL2.text = URL;
} else if (AppName == CurrentApp1) {
_root.Solution3.text = Solution;
_root.EPS3.text = EPS;
_root.Correlation3.text = Correlation;
_root.Report3.text = Report;
_root.Device3.text = Device;
_root.User3.text = User;
_root.URL3.text = URL;
};
};

I'm passing the values from a movie clip like so:

on (press) {
this.startDrag (false);
}
on (release) {
stopDrag();
_global.AppName = "EX 550";
_global.Solution = "Entry level high availability 2U logging appliance";
_global.EPS = "Up to 500 EPS";
_global.Correlation = "Up to 30,000 EPS";
_global.Report = "Up to 30 Days";
_global.Device = "Up to 64 Devices";
_global.User = "Up to 2 Users";
_global.URL = "http:exurltobedeterminedlater";
if (this.hitTest(_root.dragbox1)) {
this._visible=1;
this._x=269.5;
this._y=220;
_root.contents.sec.endY=100;
_global.CurrentApp1 = "EX 550";
_global.DragBoxNum = 1;
setTextBoxes (AppName, DragBoxNum, Solution, EPS, Correlation, Report, Device, User, URL);
} else if (this.hitTest(_root.dragbox2)) {
this._visible=1;
this._x=421.8;
this._y=220;
_root.contents.sec.endY=0;
_global.CurrentApp2 = "EX 550";
_global.DragBoxNum = 2;
setTextBoxes (AppName, DragBoxNum, Solution, EPS, Correlation, Report, Device, User, URL);
} else if (this.hitTest(_root.dragbox3)) {
this._visible=1;
this._x=573.7;
this._y=220;
_root.contents.sec.endY=0;
_global.CurrentApp3 = "EX 550";
_global.DragBoxNum = 3;
setTextBoxes (AppName, DragBoxNum, Solution, EPS, Correlation, Report, Device, User, URL);
} else {
this._x=269.5;
this._y=67;
}
}

So, at the end of the drag event, I'm assigning values to all of these global variables. I've confirmed that they're being assigned via Trace(); within that Movie Clip.

However, when I put the Trace(); below my function on line 1 of the root movie clip, all of my variables come up as undefined. I expected them to come up as undefined initially, but when I finish the drag event, they don't change...is this an issue of scope? Am I not calling the function correctly? Or am I simply an idiot?

View Replies !    View Related
Passing Values To A Function
Ok I have a gallery.. All the images and the Title of each pic is in a DB, I get the data through xml and create an array object to hold all the image info , eg Title, Filename, Width, Height etc....

I have an onRollOver Function (Thanks Kirupa) that produces hover text

each image in the gallery is added to the mc in a loop,

eg image=myMC.createEmptyMovieClip("img"+i...... etc

and I set the onRollOver Function as shown here....

image.Box.onRollOver = function() {
_root.x = 1;

_root.HT.txt.text = array[counter].strTitle;

this.fader._alpha = 100;

};

How Do I pass the value of array[counter].strTitle into the function...

NB.. image.Box is another MC that creates a little fade effect over the image...
I hope I have explained this properly.

thanks guys

John

View Replies !    View Related
Passing Values Into A Function
Last edited by flashspeed : 2003-10-28 at 15:23.
























Hi Guys, I want to pass a value into a function via a button click.
The trouble is, i'm using the function as an onClipEvent(enterFrame) the code I have attempted to use is as follows :


on (release) {
_parent.movePix(180); //this will pass the value of 180 into the function.

_parent.collage.CollPix.onEnterFrame = _parent.movePix;
}

On the Parent M/C this is the function :

function movePix(x) {
this._x += (x-this._x)/20;
if (this._x<=x) {
delete this.onEnterFrame;
mc.onEnterFrame = moveMc;
}
}
When I do a trace(x) inside this function, the value is 180 once, then it is undefined for the rest of the ClipEvent.
Can anyone please help?
Thanx in advance
Speedo

PS :: I'm using MX ::

View Replies !    View Related
Dynamic Function Values
When creating a dynamic function, how can I set values within the function? Is there a way to do this? Currently, I'm tucking the values within the object like "button.id=42" but I just need to use them within the function. I can't reference the static name of "valueArray" because the "valueArray" values are always changing.

For example:

Code:


function setButton(valueArray:Array){
//button.id = valueArray["id"]; //want to avoid

button.onRelease = function(){
//trace(this.id); //want to avoid
trace(valueArray["id"]); //want to resolve to the value of 'id'
}
}



Any ideas?

View Replies !    View Related
Function Returning Mulitple Values
Can I set it up so that a function returns more than one value?

View Replies !    View Related
Function Not Retrieving Property Values
Hi there,

This should be a simple one:

I'm trying to create a function that moves a movie clip within a specified range.

I'm defining the function on the main timeline and then running it using setInterval when a button is pressed:

function makeMovieGoDown (){
if (_root.Movie._y >= 10){
_root.Movie += 3
}
}

I've read about this somewwhere before but can't remember the solution. For some reason the function only will only access _root.Movie._y once, and not with every itteration of the setInterval ....


Can anyone explain to me why ?

cheers

View Replies !    View Related
GetTimer() Function, How To Stop And Get Values?
I have variables attached to the getTimer() function that returns mins/seconds/miliseconds etc.. which is all nested within an onEnterframe() function. What I am trying to accomplish is the ability to run another function that will stop the getTimer function, pull the values at that exact time of mins/second/mili and then move to the next frame.

I keep getting an infinite loop returned.

View Replies !    View Related
Changing Property Values From Within A Function
I'm wondering how I can change a property of an instance from within a function inside a method. I have some code here... Basically I just need to set _lynn_idle to false when a tween is occuring and _lynn_idle to true when the tween is finished. Unfortunately I can't seem to simply set it to false or true inside these listener functions like I'm able to anywhere else (seems the variable is only local to the function when I need it to access the variable associated with the instance). Any help is much appreciated.







Attach Code

private var _lynn_idle:Boolean;

public function moveToTile(tilecoord:Array):Void {
// move lynn with a tween
var startx:Number = _lynnmc._x;
var starty:Number = _lynnmc._y;
var endx:Number = (30*tilecoord[0])+(30*tilecoord[1]);
var endy:Number = 15*(tilecoord[0]-tilecoord[1]);
// determine how long the tween should take
var movedur:Number = 12;

var moveListener:Object = new Object();
moveListener.onMotionChanged = function():Void {
_lynn_idle = false;
// check depths of props and swap

}
moveListener.onMotionFinished = function():Void {
_lynn_idle = true;
// rebuild floor
_lynn_pos = tilecoord;
_global.room.newFloor();
// doAc() to props
}

var moveLynnx:Tween = new Tween(_lynnmc, "_x", Regular.easeInOut, startx, endx, movedur, false);
var moveLynny:Tween = new Tween(_lynnmc, "_y", Regular.easeInOut, starty, endy, movedur, false);

moveLynnx.addListener(moveListener);
}

View Replies !    View Related
Changing Property Values From Within A Function
I'm wondering how I can change a property of an instance from within a function inside a method. I have some code here... Basically I just need to set _lynn_idle to false when a tween is occuring and _lynn_idle to true when the tween is finished. Unfortunately I can't seem to simply set it to false or true inside these listener functions like I'm able to anywhere else (seems the variable is only local to the function when I need it to access the variable associated with the instance). Any help is much appreciated.







Attach Code

private var _lynn_idle:Boolean;

public function moveToTile(tilecoord:Array):Void {
// move lynn with a tween
var startx:Number = _lynnmc._x;
var starty:Number = _lynnmc._y;
var endx:Number = (30*tilecoord[0])+(30*tilecoord[1]);
var endy:Number = 15*(tilecoord[0]-tilecoord[1]);
// determine how long the tween should take
var movedur:Number = 12;

var moveListener:Object = new Object();
moveListener.onMotionChanged = function():Void {
_lynn_idle = false;
// check depths of props and swap

}
moveListener.onMotionFinished = function():Void {
_lynn_idle = true;
// rebuild floor
_lynn_pos = tilecoord;
_global.room.newFloor();
// doAc() to props
}

var moveLynnx:Tween = new Tween(_lynnmc, "_x", Regular.easeInOut, startx, endx, movedur, false);
var moveLynny:Tween = new Tween(_lynnmc, "_y", Regular.easeInOut, starty, endy, movedur, false);

moveLynnx.addListener(moveListener);
}

View Replies !    View Related
Insert Values In An Array (within A Function)
Hello,
I can't seem to get values insert in an array. I know it works outsite the function but
when using variables in a function and trying to insert this in an array it does not work.
The values are empty.

But if you uncomment the line someArray.push(a0,a1,a2) and uncommend the for loop it works.

In actionscript 2.0 i could use eval ..but in actionscript 3.0 you have to use this to convert a string to a value.

Does anyone see, what i am doing wrong?


function doSomething() {
var a0:String = "hello";
var a1:String = "why doesn't it";
var a2:String = "work!";

var someArray:Array = new Array();

//someArray.push(a0,a1,a2);

for (var i:uint =0; i<=3; i++) {

someArray.push(this["a"+i]);

}


trace(someArray);

}


doSomething();

View Replies !    View Related
Problem Returning Values From A Function.
I need to load data from a database, so I created the following function and placed it in frame 2 on the main timeline.

Code:
getQuestionSet = function (category:String, subject:String, level:Number, count:Number):Array {
var questionSet:Array = new Array();
var writeV:LoadVars = new LoadVars();
var readV:LoadVars = new LoadVars();
// stop browser from returning cached results
writeV.cacheKiller = new Date().getTime();
writeV.category = category;
writeV.subject = subject;
writeV.level = level;
writeV.count = count;
trace(writeV.toString());
writeV.sendAndLoad("getQuestionSet.aspx", readV, "GET");
readV.onLoad = function(success) {
if (success) {
questionSet[0] = readV.pk1;
questionSet[1] = readV.pk2;
questionSet[2] = readV.pk3;
questionSet[3] = readV.pk4;
questionSet[4] = readV.pk5;
questionSet[5] = readV.pk6;
questionSet[6] = readV.pk7;
questionSet[7] = readV.pk8;
questionSet[8] = readV.pk9;
questionSet[9] = readV.pk10;
_root.questions = questionSet;
}
};
return questionSet;
};
I also created a variable in the first frame of the main timeline as so.

Code:
var questions:Array = new Array();
Whenever I try to call the function, it fails to set the value of the questions array. It always appears empty(questions[0]-questions[10] have the value undefined). But, if I check the values from within the function after I have set them, it works, so I know that it is receiving the values. What am I doing wrong?

Code:
questions = getQuestionSet("Art and Music", "Art", 1, 10);
Here is an example of how I have would call the function.
Also, please feel free to give me constructive comments on my actionscripting, I'm still new.

View Replies !    View Related
Function Returning Multiple Values?
How can I rewrite this code so that I get all the four values returned in the function each time it is called.


ActionScript Code:
x=0;AverageShare=new Array();for(k=1;k<=10;k++){ AverageShare=update();  trace(AverageShare); trace("x = "+x);}function update(){ x++; for(i=1;i<=4;i++) return x+i;}

View Replies !    View Related
Anonymous Function – Return Values
Hello, I will appreciate any help with this problem; let me describe a little bit what I’m trying to do:

I have 2 SWF, one.swf and two.swf
1 LocalConnection to send 1 variable from one.swf to two.swf


one.swf code:

var param:Number = new Number(5);

var sending_lc:LocalConnection = new LocalConnection();
sending_lc.send("_Connection1", "myMethod", param);


two.swf code:

this.createTextField("text1_txt", 1, 20, 20, 100, 20);
texto1_txt.border = true;

var receiving_lc:LocalConnection = new LocalConnection();
receiving_lc.connect("_Connection1");
receiving_lc.myMethod = function (param:Number){
text1_txt.text = param; //just to test values
temp = param;
};

// I need to do this
Switch (“param value”) {
….
}

This code actually works pretty well sending the “ param ‘ from one.swf to two.swf

Problem:

I need to be able to use “param” value out of the function, because a I need to perform a switch with this value, since the function wich receives de “param” value is an anonymous function I don’t know how to do to get the value from outside the function because a don’t have a reference name to the function so, the normal way to return a value is not going to do the job.

I will appreciate any help, thanks

View Replies !    View Related
GET Function Returns Most Correct Values, But Not All.
I have a get function defined as such:


Code:
final protected function get data()
:Array
{
return _array;
}
This function is defined in a parent class, and then used in derrived classes. As you can see, this is a GET function that returns an array. I can do things like this without a problem:
trace(data['some_index']); // give correct value

But these gives me incorrect values:
trace(data); // shows blank (i.e.: Nothing)
trace(data.length); // gives length of 0, even thoght it has members

Is there a way to have those operations return correct values?

View Replies !    View Related
HELP Function's Returning Values Before Lv.Onload
Hi, everyone. I'm trying to create class that'll call a php file to save data into a mysql database, however i'm stumped with the problem of the function returning the result of the query( 0 if mysql saved the data, >0 if error occured ) BEFORE the onload event is executed.

The data is saved into the database, i just want the savedata function to hold its horses and return the value after the onLoad event is done, is what I'm trying to do reasonably correct ? hope i aint barking up the wrong tree... Or is there a better way to do it ?

I've looked around on the web, found a few posts of users trying to do the same thing, but they ended up asking the same question too.

Thanks in advance !



ActionScript Code:
//IN savedata.as
 
class phpdata.savedata
{
    //Variable declaration and initiation
    private var startMili:Number = 0;
    private var startSec:Number = 0;
    private var endMili:Number = 0;
    private var endSec:Number = 0;
    private var savedata_lv:LoadVars;
    private var returnVal:String;
    private var errno:Number;
    private var execTime:Number = 0;
    private var errnumber:Number = 0;
    private var phpurl:String = "";
   
    function savedata(ssavedata_lv:LoadVars, sphpurl:String):Number{
        phpurl = sphpurl;
        savedata_lv = ssavedata_lv;
    }
   
    function save():Number{
        savedata_lv.onLoad = function() {
            var endTime:Date = new Date();
            endMili = endTime.getMilliseconds();
            endSec = endTime.getSeconds();
            execTime = (endSec*1000+endMili)-(startSec*1000+startMili);
            execTime = execTime/1000;
        }
        if (this.returnVal == "success") {
                return 0;
            } else {
                return this.errno;
            }
        savedata_lv.sendAndLoad(phpurl+"?uniqueID="+getTimer(), savedata_lv, "POST");   
        var startTime:Date = new Date();
        startMili = startTime.getMilliseconds();
        startSec = startTime.getSeconds();
                return this.errno;
    }
}
 
//Code in .fla button
on(release){
    import phpdata.savedata;
    saveCalendar_lv = new LoadVars();
    saveCalendar_lv.quan = abc_txt.text;
    var abc = new phpdata.savedata(saveCalendar_lv, "http://192.168.0.102/testinggrounds/save.php");
   
    save_txt.text = abc.saveit();
}

View Replies !    View Related
Cannot Use Array Values Inside A Function
I am trying to use values in an array within a different function than where the array was created.

I created and am attempting to access the array as _global

Is there something special I need to do than I am already doing.

PolishEagle

View Replies !    View Related
Returning Values From A Function's LoadVars.onLoad..
Hi all, the subject was a bit cryptic, so i'll explain my question a bit.

im trying to put my loadvars function in a class, savedata, and inside savedata.as is the following codes


Code:
class phpdata.savedata
{
//Variable declaration and initiation
private var startMili:Number = 0;
private var startSec:Number = 0;
private var endMili:Number = 0;
private var endSec:Number = 0;
private var savedata_lv:LoadVars;
private var returnVal:String;
private var errno:Number;
private var execTime:Number = 0;
private var errnumber:Number = 0;
private var phpurl:String = "";
private var loaded:Boolean=false;

public function get errnoa():Number {
return errno;
}

function savedata(ssavedata_lv:LoadVars, sphpurl:String){
phpurl = sphpurl;
savedata_lv = ssavedata_lv;
}

function saveit():Number{
savedata_lv.onLoad = function() {
var endTime:Date = new Date();
endMili = endTime.getMilliseconds();
endSec = endTime.getSeconds();
execTime = (endSec*1000+endMili)-(startSec*1000+startMili);
execTime = execTime/1000;
errno = this.errno;
return errno;
}
savedata_lv.sendAndLoad(phpurl+"?uniqueID="+getTimer(), savedata_lv, "POST");
var startTime:Date = new Date();
startMili = startTime.getMilliseconds();
startSec = startTime.getSeconds();
return errno;
}
}


However, in my .fla, i'm calling the saveit function like this


Code:
import phpdata.savedata;
saveCalendar_lv = new LoadVars();
saveCalendar_lv.quan = abc_txt.text;
//var abc = new phpdata.savedata(saveCalendar_lv, "save.php");
var abc = new phpdata.savedata(saveCalendar_lv, "http://192.168.0.102/testinggrounds/save.php");

save_txt.text = abc.saveit();


and as you might have guessed, saveit returns an undefined variable back !

so my question is,
1) am i on the right track doing this in my current way, or am i barking at the wrong tree altogether ? I'm still quite fresh in terms of flash exposure, so if there's a better way of doing it, i'll appreciate it if you can give me a pointer or two I'm trying to reuse this bit of code by placing it in a separate AS file.

2) how do i get the saveit function to return the correct value once the onload function is executed ? And not before the onload function is done ?

thanks in advance !!

*EDIT the is supposed to be startTime:/*--*/Date

View Replies !    View Related
Passing Values To Flash From A Javascript Function..
ok I have this and it works ok:

in my html:

<script language = "JavaScript">
<!--
function PassFlash(){
window.document.movie2.SetVariable("trackNo", "track1");
}
//-->

</script>

and then:

<a href="#" onClick="PassFlash()">Pass The Variable</a>

now that works fine and passes the value to my flash movie but is there any way of making it more useful, passing a parameter to that js function, sorta like:

<script language = "JavaScript">
<!--
function PassFlash(whichTrack){
window.document.movie2.SetVariable("trackNo", whichTrack);
}
//-->

</script>

then calling that function using diff params for "whichTrack"

<a href="#" onClick="PassFlash("track1")">Track1</a>

<a href="#" onClick="PassFlash("track2")">Track2</a>

and so on for track 3, track 4 etc

Now sadly that dont work can it be done? just trying to make a function more useful.

any helo massively appreciated!

View Replies !    View Related
Position Values Sent To A Public Function From A String
Hello,

I was wondering if anyone could help me with this. I need to call several instances of the same movie clip, but their position values can't be defined statically in the actionscript window. The postion values are defined by a string that is being received by a public actionscript function.

If anyone could help me with this it would be much appreciated, I know how to load variables from an external file to be used as values, but I don't think this is what I'm being asked to do.

Thanks in advance,
León Dore

View Replies !    View Related
Recursive Function And Bizarre _height Values
disclaimer.. i tend to over look the obvious..but..

i'm trying to return the clip with the largest _height value using a recursive function ..i've modified and used this function in the past for clip counts, removals, etc. and that's worked fine ..again, here i'm trying to get the tallest clip.. but i'm getting some bizarre _height values ..it works when all movieclips have no inner movieclips ..but when i attach a clip inside another clip it blows up on me

..uncomment those last two attachment lines.. you'll see what i mean..

can anyone explain this.. or have a solution to this? THANKS!


ActionScript Code:
attachMovie("mc","mc0",0,{_height:100});
attachMovie("mc","mc1",1,{_height:200});
attachMovie("mc","mc2",2,{_height:400});
attachMovie("mc","mc3",3,{_height:250});
attachMovie("mc","mc4",4,{_height:350});
//mc4.attachMovie("mc","mc5",0,{_height:200}); //traces mc4: 1707.3 (with below line removed)
//mc4.mc5.attachMovie("mc","mc6",0,{_height:150}); //traces mc4: 6246.25

function getTallestClip(mc:MovieClip):MovieClip
{
    var tallest:MovieClip;
   
    for (i in mc)
    {
        if (typeof(mc[i]) == "movieclip")
        {
            //trace(mc[i]._height); //traces each clip's _height
           
            if(tallest == undefined)
            tallest = mc[i];
            else if(mc[i]._height > tallest._height)
            tallest = mc[i];
           
            getTallestClip(mc[i]);
        }
    }
   
    return tallest;
}

var myTallest:MovieClip = getTallestClip(_root);
trace(myTallest._name + ": " + myTallest._height);

View Replies !    View Related
Event Handler Function Returns Values - HOW To Get Them?
Hello I probably am not understanding how Events work....well I have function in a class that has this line of code:


ActionScript Code:
this.addEventListener("dataRetrieved", handleHierSelectData);

"dataTrieved" is a custom event that dispatches an event with a variable set to "true".

In another section of my code I have the event dispatch:


ActionScript Code:
public function onGetRecordsResult(result:Array = null):void
{
    // convert the result array into an array
    phpData = new ArrayCollection(result);
   
    // instantiate new custom event, set the appropriate data to send back and
    // dispatch event to parent app or component
    var e:DataRetrievedEvent = new DataRetrievedEvent();
    e.dataRetrieved          = true;
    dispatchEvent(e);
}

From the addevent listener line I call "handleHierSelectData"


ActionScript Code:
public function handleHierSelectData():Canvas
{
    newProgressBar.indeterminate = false;
    newProgressBar.visible       = false;
   
    newHierSelect = new ThreeLevelHierSelect('processData', listLabels, null, phpData);
    //myCanvas.addChild(newHierSelect.generateHierSelect());
   
    return newHierSelect.generateHierSelect();
}

See, handleHierSelectData creates a new component that I need to send to my main application so I am wonder WHERE, AND HOW I can get the returned component from this.addEventListener("dataRetrieved", handleHierSelectData); ??

I am missing something here?

I guess what I want to know is...when you have an event listener and you want the handler function to return something HOW do you catch it and where?

View Replies !    View Related
Setting Boolean Values Within Function, So They Don't Confilct
Greetings, all- Here's what I'm trying to do: I have a number of buttons on stage. When you rollover, a movie clip is attached. If you roll out, it disappears; if you click, it stays. Then you can drag it around. I'm using a boolean for the rollout disappearing trick. I've set these up in named functions.
[as]function attachBar(word) {
var showIt=false;
i++;
_root.createEmptyMovieClip("bh", getNextHighestDepth());
bh.attachMovie("infobar", iBar, getNextHighestDepth());
bh[iBar]._x = _xmouse;
bh[iBar]._y = _ymouse;
bh[iBar].tField.text = word;
}
function grabIt() {
showIt=true;
bh[iBar].onPress = function() {
bh[iBar].startDrag();
};
bh[iBar].onRelease = function() {
stopDrag();
};
}
btn1.onRollOver = function() {
attachBar("Blade Runner");
//rollOut function
btn1.onRollOut = function() {
if (!showIt) {
bh.removeMovieClip();
}
};
btn1.onRelease = function() {
grabIt();
};
};[as]

All this works fine for a single button.

When I apply my code to multiple buttons, however, the boolean gets reset with every rollover, and the previously attached mc disappears. I don't want to have to set multiple boolean variables, although I suppose I could name them with arguements.

Anybody have any idea for a solution? Thanks!

View Replies !    View Related
Pass Array Values To Function Arguments
hi all,

Maybe someone could help me !

it's possible to do this ?

I have an array with some values and i want to pass this values to a function arguments.

example

var theArray:Array = new Array("test1","teste2","teste3");

function hello(t:Number,a:Array){
// do something
test(a)

}

hello(5,theArray)

function test(arg1,arg2,arg3){

// do something
}

I now that i can do like this:
test(theArray[0],theArray[1],theArray[2])

but there is another way to do that ?

thanks in advance,

View Replies !    View Related
AS 2 Function Returning Array Of Vector Of 4 Values
I have a search function that searchs an xml file and i would like every time i find a result to collect 4 values (i,j,m,n) and push them to an array. I need these 4 values to keep them together. Any idea on how to implement this in actionscript 2?

View Replies !    View Related
[function]losing Internal Values In SetInterval
Last edited by norseman : 2004-03-12 at 07:07.
























I've seen the other setInterval problem but this seems different cos its to do with an objects properties

I have the following code

ActionScript Code:
factory = function () {
    this.credits = 466320;
    this.crystals = 20;
    this.maxCrystals = 500;
    this.solar = 0;
    this.maxSolar = 5000;
    this.sellPrice = 23;
    this.prodTime = 90;
    this.prodAmount = 276;
    this.productionFlag = false;
    this.startProduction();
};
factory.prototype.startProduction = function() {
    trace("here+maxsolar"+this.maxsolar);
    setInterval(this.jo, 4125);
};
factory.prototype.jo = function() {
    trace("jo is here"+this.maxSolar);
};
pete = new factory();

in the jo function it is unable to find the maxsolar value... nay idea why, using MX NOT 04

cheers


Zen

View Replies !    View Related
Object Variables Have Null Values Outside Function
I'm having issues with I think objects. I have declared my variables inside the objects and then I assign variables inside that object function. My problem is I want to be able to access this object outside this function. How can I do this? I found that if inside the object function I call the other function that I want it in then the variables work. However, this is not always good because I don't always want to tell it to run a certain function. Any way around this? Is there a global object or something?

View Replies !    View Related
Access Array Values Modified Inside Function
I'm trying to access the 'names' array values from outside the function. The textbox 'txt1' displays the correct values, however the final line won't trace out any value for names[1] (not a problem with array length). I'm sure this is a scope issue, but thought declaring the names array outside of the function would allow for the values created in the function to be accessible outside of the function. Thanks in advance for any help!


Code:
test_xml = new XML();
test_xml.ignoreWhite = true;
test_xml.load("test.xml");
var email = [];
var names = [];

test_xml.onLoad = function(success){
if(success) {
for (var n = 0; n<test_xml.firstChild.childNodes.length; n++) {
var currentNode = test_xml.firstChild.childNodes[n];
names[n] = currentNode.attributes.name;
email[n] = currentNode.childNodes[2].firstChild.nodeValue;
}
for (var i = 0; i<names.length; i++) {
txt1.text += "Name: " + names[i] + "
Email: " + email[i] + "
";
}
}
else {
trace("Problem getting XML");
}
}
trace("Name is: " + names[1]);

View Replies !    View Related
XML: Get OnLoad-function To Accept Values / Retrieve The Filename?
Hello all.

I am using the standard
Code:
var xml_group:XML = new XML();
xml_group.ignoreWhite = true;
xml_group.onLoad = loadXMLgroup;
stuff to create an XML handler and a call to the function "loadXMLgroup" to read the data from the XML.

Now, with common, default example code, the way you usually use an XML-handling function is:
Code:
function loadXMLgroup(loaded) {
if (loaded) {
// do stuff with the XML file
}
}
...but is there a way to pass a value to it / retrieve the name of the currently processed file from within the XML?

The reason for this is that I want to use the same function (loadXMLgroup) to load several XML files (several groups) and now I am trying to find an "intelligent" way of handling the data.

Before, I did it with a supervising function (with an interval) that checked if a certain "_root" value was filled and if so (or if it failed / time ran out) it would go to the next file to load... but that way it was slow because it would only load one file at a time and wait until it was done, etc...

Is that already the best way to do it? Is there a way how the XML-handling function (loadXMLgroup) can tell which file it is currently processing and fill a specific named value / array-entry instead of a generic dummy value?

Am I explaining this well enough?

Thanks in advance for your help

View Replies !    View Related
Passing Values, AddEventListener, MouseEvent Handler Function Help Request
Hello,

I have pasted the current code below. I wish to have a group of images enlarge and shrink as the mouse passes over them (eventually smoothly, not jerky as they are now, as well as fading from B&W to color on enlargement - but not relevant to this question).

As you can see I have written a separate Grow and Shrink function for each image, but this is very inefficient (I am an old hand at VBScript, but new to Actionscript).

I am seeking a way to pass the instance in question to the function so I can use one grow and one shrink function for any/all of the images that will be used, such as (where "1" is the item passed and "whichItem" represents what I am trying to do here):

galleryLoader1.addEventListener(MouseEvent.MOUSE_OVER, growImage(1));
galleryLoader1.addEventListener(MouseEvent.MOUSE_OUT, shrinkImage(1));

function growImage(event:MouseEvent, whichItem):void {
whichItem.x = whichItem.x - (whichItem.width / 2);
whichItem.y = whichItem.y - (whichItem.height / 2);
whichItem.scaleX = 1;
whichItem.scaleY = 1;
}


...... etc.

When I attempt to pass data at the addEventListener line in the line:

galleryLoader1.addEventListener(MouseEvent.MOUSE_OVER, growImage(1));

I always get errors that tell me I am trying to coerce the mouseevent to a string, and the wrong number of arguments (expecting 2). If I put two arguments in, I get a boatload of errors.

I am new, confused, but thoroughly impressed with Actionscript 3.0. I have only been working with it for about a week now and can do a lot, but this particular thing has me stumped.

THANK YOU for any assistance you can render so I can get this function running. The information is probably in several places, but I do not yet know enough to be able to know where or how to look to get my answer. Your help is of tremendous value and is appreciated.

Best regards,

Dave Xanatos


Code extracts (less the imports, addChilds, Loaders and URLRequests...):

galleryLoader1.addEventListener(MouseEvent.MOUSE_OVER, growImage1);
galleryLoader1.addEventListener(MouseEvent.MOUSE_OUT, shrinkImage1);
galleryLoader2.addEventListener(MouseEvent.MOUSE_OVER, growImage2);
galleryLoader2.addEventListener(MouseEvent.MOUSE_OUT, shrinkImage2);
galleryLoader3.addEventListener(MouseEvent.MOUSE_OVER, growImage3);
galleryLoader3.addEventListener(MouseEvent.MOUSE_OUT, shrinkImage3);
galleryLoader4.addEventListener(MouseEvent.MOUSE_OVER, growImage4);
galleryLoader4.addEventListener(MouseEvent.MOUSE_OUT, shrinkImage4);


function growImage1(event:MouseEvent):void {
galleryLoader1.x = galleryLoader1.x - (galleryLoader1.width / 2);
galleryLoader1.y = galleryLoader1.y - (galleryLoader1.height / 2);
galleryLoader1.scaleX = 1;
galleryLoader1.scaleY = 1;
}

function growImage2(event:MouseEvent):void {
galleryLoader2.x = galleryLoader2.x - (galleryLoader2.width / 2);
galleryLoader2.y = galleryLoader2.y - (galleryLoader2.height / 2);
galleryLoader2.scaleX = 1;
galleryLoader2.scaleY = 1;
}

function growImage3(event:MouseEvent):void {
galleryLoader3.x = galleryLoader3.x - (galleryLoader3.width / 2);
galleryLoader3.y = galleryLoader3.y - (galleryLoader3.height / 2);
galleryLoader3.scaleX = 1;
galleryLoader3.scaleY = 1;
}

function growImage4(event:MouseEvent):void {
galleryLoader4.x = galleryLoader4.x - (galleryLoader4.width / 2);
galleryLoader4.y = galleryLoader4.y - (galleryLoader4.height / 2);
galleryLoader4.scaleX = 1;
galleryLoader4.scaleY = 1;
}

function shrinkImage1(event:MouseEvent):void {
galleryLoader1.x = 130;
galleryLoader1.y = 350;
galleryLoader1.scaleX = .5;
galleryLoader1.scaleY = .5;
}

function shrinkImage2(event:MouseEvent):void {
galleryLoader2.x = 330;
galleryLoader2.y = 350;
galleryLoader2.scaleX = .5;
galleryLoader2.scaleY = .5;
}

function shrinkImage3(event:MouseEvent):void {
galleryLoader3.x = 560;
galleryLoader3.y = 350;
galleryLoader3.scaleX = .5;
galleryLoader3.scaleY = .5;
}

function shrinkImage4(event:MouseEvent):void {
galleryLoader4.x = 730;
galleryLoader4.y = 350;
galleryLoader4.scaleX = .5;
galleryLoader4.scaleY = .5;
}

View Replies !    View Related
Generating Random Values For A Variable While Excluding The Already Generated Values
Hey Flashers:

Here's my question this time around. I want to generate random values between 1and 50 for a variable but I want every time I generate the new value to exclude the already generated values from the pool of options. Something like playing the lottery where no two drawn numbers can be the same. Any hints or references to open code will be greatly appreciated.
As always, thanks a lot!

View Replies !    View Related
[MX] Weirdness With Values Used By Array Populated Clip Values.
Hi,

I have used invisible buttons on top of some text, as part of a volume control interface.

The text buttons are set out as 0 – 25 – 50- 75 -100 referring to the % that a music tracks volume will change to once a button is pressed – so far so good.

Now to give values to the text buttons in order for them to make the text clip that they are on top of go to & stop & the right frame I have used arrays to give a reference the location of the text clip:

numbs_array = [_root.volHold_mc.vol0, _root.volHold_mc.vol25, _root.volHold_mc.vol50, _root.volHold_mc.vol75, _root.volHold_mc.vol100];

I then reference that in a home made “release” function as “this.monica.gotoAndStop(2);” “monica” being the reference to the address of the clip.

It all works fine except the code seems to make the movie play clips in an order that they have not been designated in the array – Like a button on top of the “25”% value will play the animation for the “75”% clip?

The whole problem is probably much better seen through the movie – the problem section of which i have attached below.

View Replies !    View Related
Passing Values From ASP To Change Alpha Values Etc
Is this possible? I currently have a log in system, logging each page a user visits, these visits amount to a value and have this value passed to flash to control alpha values, tints etc to reflect look and feel. is this possible?

View Replies !    View Related
Passing Values From ASP To Change Alpha Values Etc
I have posted this before, but wondering if anyone can help?

Is there anyway of having external values controlling alpha values, tints etc of a movieclip?

View Replies !    View Related
Database Values To Array Values
Hi all,

I've created a movie which uses a number of arrays to construct the elements of a flash-based gallery.

What I need is a practical method of getting values from a database into an array via an ASP page.

The plan was to load the variables into these arrays using the an asp page and a loadvars object to create a string (basically the array values in quotes separated by commas) which was then to be inserted into the parameters for the creation of the array. Needless to say this hasn't worked- the create array object seems to interpret the whole string as the first value in the array, i can't find a way of populating the array from just a single asp page.

I've given up with this method and really need a few pointers.

Thanks

View Replies !    View Related
How Do You Change Rgb Values Hexadecimal RGB Values?
how do you change rgb values hexadecimal RGB values in action script?

View Replies !    View Related
Writing Values To A Text File And Reading Values From The Same File
Hi, I want to create a page counter in Flash and I was wondering how to write a value (the next number for the visitor) to the text file and read the current value from that file. In a simplified form I would just read the number currently in the file, add 1, and rewrite the number to the file. Eventually when I get that worked out I will adapt it to only add 1 for each different user session instead of each page hit, but I'll start with the easy stuff first.

Thanks

View Replies !    View Related
Updating
i have a window which contains a box for text, 3 boxes for 3 pictures, and a box for a movie. (this is so clients can follow the progress of their work). i want to be able to update these regularly from a folder which will contain this info, without making a new swf.

how can this be done...please!

View Replies !    View Related
Updating MX
When I'm trying to update my Falsh MX I get an error that goes like:check your Internet connection!??and I'm online using both lines on my ISDN line.Is there anybody who can gice me some tips?

View Replies !    View Related
Updating
hey guys um..is there any easier way to update flash sites without having to open the .fla file and doing it all threw that thanx

View Replies !    View Related
Updating To AS3
Hey guys I'm redoing one of my previous flash projects and I want to bring all the coding up to date since its all written in AS2 and I really have no clue where to start can someone help me? Here's me coding...


Code:
container.loadMovie("http://www.example.com/flash/one.swf");
onLoad = function () {
destinationX = buttonOne._x;
destinationY = buttonOne._y;
};
onEnterFrame = function () {
hoverSquare._x += (destinationX-hoverSquare._x)*0.2;
hoverSquare._y += (destinationY-hoverSquare._y)*0.2;
};
buttonOne.onRelease = function(){
container.loadMovie("http://www.example.com/flash/one.swf");
destinationX = buttonOne._x;
destinationY = buttonOne._y;
}

View Replies !    View Related
Copyright © 2005-08 www.BigResource.com, All rights reserved