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




LoadVars .onload Function & Class Properties



I am using a LoadVars() object inside a class. It's loading an external text file, and all is working in that regard. Here's part of the code that checks when the text file has been loaded; I named the loadvars object "load_info":
- - - - - - - - - - - - - - - - - - - - - - - - - - -
load_info.onLoad = function(true) {
if (true) {
...bunch of statements...
}
}
- - - - - - - - - - - - - - - - - - - - - - - - - - -
But within the above function literal I need to be able to reference and set some of the properties of the class, and my first mistake was assuming using 'this' would do so, but it would be referencing the function object, and not the class object, as I soon found out.

I have looked at other ways of doing the onLoad-true-checking function, but I'm still at a loss.

(I also tried the dumb solution of creating new _root variables as means to transfer back and forth the class property values--it doesn't seem to work for what I'm doing... the problem being that there are many instances of the class object setting the same _root variable)

Thanks.



KirupaForum > Flash > Flash 8 (and earlier) > Flash MX 2004
Posted on: 06-15-2005, 06:08 PM


View Complete Forum Thread with Replies

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

LoadVars.onload Doens't Work In Function?
hi all,

I got no problem with loadVars in the main stage but when I placed it in a function inside a movie clip (exactly a smart movie clip) like this:


Code:
function Init() {
this.createTextField("tf", 1, 0, 20, 300, 0);
this.tf.multiline = true;
this.tf.autoSize = "left";
this.tf.selectable = false;
this.tf.wordWrap = true;
this.tf.border = false;
this.tf.type = "dynamic";
myTextFormat = new TextFormat();
myTextFormat.font = "Verdana";
myTextFormat.size = 10;
myTextFormat.color = 0xffffff;
myTextFormat.leading = 1;
this.tf.setNewTextFormat(myTextFormat);

// may have trouble here ...............
loadVarsText = new loadVars();
loadVarsText.load(fileName);
loadVarsText.onLoad = function(success) {
if (success) {
this.tf.Text = this.varName;
}
};
// end of may have trouble here .................
}
When I debuged, the lines of code in the loadVarsText.onload function didn't work

Any idea? Any suggestion?

Thanks in advance

Sif The LoadVars.onLoad Function In Tutorial Works
sif the LoadVars.onLoad function in tutorial works
loadableData.onLoad = function(success){

I have used the above fucntion as outlined in the realtive Actionscript.org tutorial about the LoadVars object and have been sitting here for over 2 hrs trying to get it to work. Ive run trace("im here"); to find out where flash is getting stuck and this function is the culpurate.
Of course Im running Flash MX so no version problem, but after reading the macormedia site im not sure the above function is the appropriate use of the onLoad boolean.

Have any ideas whats wrong? (see below)




Code:
onClipEvent(load){
loadablePaylist = new LoadVars();
loadablePaylist.load("paylist.txt");

var status = null;

loadablePaylist.onLoad = function(success){

if(success)
{
//load outcome
status = "Paylist loaded";
trace(status);
trace(loadablePaylist.track_count);

var vertpos = 46;//vertical positioning of clips
var count = 0;
//convert string track_count to number
noOfTracks = new Number(track_count);

while(count!= noOfTracks){
duplicateMovieClip(_root.paylist.box,"box" + count + 1, count);
setProperty("_root.paylist.box" + count + 1, _y, vertpos);

vertpos = vertpos +_root.paylist.box._height;//increment verical positioning value
count++;
}//end loop

}

else
{
status = "Empty paylist";
trace(status);
//if no paylist maybe open dialog again, error!??


}
}//end function(success)


}//end onClipEvent()


-Rich

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

XML OnLoad Function In Class File
I am trying to write a class to load in an XML file.

I need to figure out how to make the XML.onLoad(success) function call the next function in the class body. For some reason, the function call to traceXML(); in the onLoad function of XML cannot find the traceXML(); function in the class body.

When I instantiate the class at runtime, the trace function inside of traceXML(); never gets ran, even though there is a reference to the traceXML(); function in the onLoad of the XML file. Can anyone tell what's wrong with my code?

I know that the XML file is loading correctly because "xml is in" is traced to the output panel at runtime. Does the onLoad function not know the path to the traceXML() function?


Code:
class XMLIn {
// Define variables
public var XMLFile:XML;


// Constructor
function XMLIn(file) {
XMLFile = new XML();
XMLFile.ignoreWhite = true;
XMLFile.onLoad = function(success) {
if (success) {
trace("xml is in");
traceXML();
} else {
trace("error");
}
};
XMLFile.load(file);
}
// function that is supposed to be called within the onLoad of XMLFile
// but nothing is ever traced to the output panel
function traceXML() {
trace("traceXML(); has been ran");
trace(XMLFile);

}
}
code in frame 1 of fla file:


Code:
var XMLLoad = new XMLIn("layout.xml");

[F8] Call Function In A Class From LoadVars
I need to call a function defined inside a class i´ve created, but the function must be called from an loadVars.onLoad(success) object nested inside another function of the same class.

The problem is i can´t use the absolute path from the _root since i use more than one instance of the class.

Using _parent won´t work even if i try to do this:
loadVarsName._parent = this;
This statement works when the loadVars is not inside a class, but when i put it inside my class it stops working.

here is the code on my example.as file.

class example extends MovieClip {
}
public function callNewFunction() {
trace ("function called");
}
public function loadArds() {
var loadedTxt:LoadVars = new LoadVars();
loadedTxt.load("file.txt");
loadedTxt.onLoad = function(success) {
if (success) {
callNewFunction(); //here is my problem!!! no relative path can get me there.
}
}
}
}
//End Class


please help!!!!!!!!!! Thanks!

Call Function In A Class From LoadVars With Relative Path Needed. Please Help
Hi all, i´m new here. I´ve been searching an answer to my problem but haven´t found it yet. If someone can help, i´ll be really grateful!

I need to call a function defined inside a class i´ve created, but the function must be called from an loadVars.onLoad(success) object nested inside another function from the same class.

The problem is i can´t use the absolute path from the _root since i use more than one instance of the class.

Using _parent won´t work even if i try to do this:
loadVarsName._parent = this;
This statement works when the loadVars is not inside a class, but when i put it inside my class it stops working.

here is the code on my example.as file.

class example extends MovieClip {
}
public function callNewFunction() {
trace ("function called");
}
public function loadArds() {
var loadedTxt:LoadVars = new LoadVars();
loadedTxt.load("file.txt");
loadedTxt.onLoad = function(success) {
if (success) {
callNewFunction(); //here is my problem!!! no relative path can get me there.
}
}
}
}
//End Class


please help!!!!!!!!!! Thanks!

XML Loads Other XML Files, Onload Function In Onload Function
I am writting an image gallery that loads one intial xml file named galleries.xml.
From this point each xml node loads a XMl file for that gallery that holds all the images.
The problem arises in the fact that to do this I need a onload function within an onload function. Onload functions dont accept parameters so I can pass down the variable that shows what loop the gallery loop is on as I need that in the function that holds the images. I hope you can understand what I am trying to say.

I will include the galleries.xml file and a sample image xml file and the fla.

LoadVars, OnLoad?
Hi all,
I'm using the LoadVars object to pull data from an ASP.net script. I'm having some trouble with the function that I set up to trigger once the data has loaded.

So a simple question:
When you use loadVars, does the success function fire off as soon as data is loaded or when all of the data is loaded?

Someone told me that I needed to add a loop to make sure all of the data is loaded... but I though you didn;t need that if you use the LoadVar object...

Thanks

LoadVars.onLoad Help
hi

i am using loadvars to load url encoded data from a php file.

when i trace the output it shows that the variables have been retrived successfully.

now i need to use the values by assingning then to a variable. i cant seem to get this going

i am using flash 8 with as2.


myVars.onLoad = function (success) {
if (success) {
trace (" variables loaded ");
ad1id.text = myVars.ad1id;
ad1src.text = myVars.ad1src;
clipid.text = myVars.clipid;
clipsrc.text = myVars.clipsrc;
ad2id.text = myVars.ad2id;
ad2src.text = myVars.ad2src;

} else {
trace (" Error loading variables ");
}
}

is the above method used for assigning the variables correct.

i need to use the values of the variables on the left in another part of the script. the script extracts url encoded data from a php script very successfully i have already check this with trace.

ram

LoadVars OnLoad
Is there any fixed sequence in which onLoad and onData event handlers of LoadVars object is called.

And are there any chances that following code snippet written in the first frame of timeline lead to infinite loop showing the error "The script in your movie is making the Macromedia Flash Player to run slowly. Do you want to abort the script?"

stop();//stop till everything gets loaded
myLoad=new LoadVars();
myLoad.load(<someip>,myLoad);
myLoad.onLoad=getMy;
function getMy(success)
{
if(success)
{
play();//go ahead when everything is loaded
}
else
{
//show some message if loading unsuccessfull
}
}


which is correct method to use in this situation.
onLoad or onData?

Please reply as soon as possible.

LoadVars OnLoad
Is there any fixed sequence in which onLoad and onData event handlers of LoadVars object is called.

And are there any chances that following code snippet written in the first frame of timeline lead to infinite loop showing the error "The script in your movie is making the Macromedia Flash Player to run slowly. Do you want to abort the script?"

stop();//stop till everything gets loaded
myLoad=new LoadVars();
myLoad.load(<someip>,myLoad);
myLoad.onLoad=getMy;
function getMy(success)
{
if(success)
{
play();//go ahead when everything is loaded
}
else
{
//show some message if loading unsuccessfull
}
}


which is correct method to use in this situation.
onLoad or onData?

Please reply as soon as possible.

OnLoad Or LoadVars
Have I just found some code to load xml into Flash:

moXML = new XML();
moXML.onLoad = makeArray;
moXML.load("xmltest.xml");

Previously I was loading the info in from a .txt file using:

var oVars = new LoadVars();
oVars.load("asp_data2.asp", "_root");

which method should I use?

monkey

LoadVars Problem (using An OnLoad)
I had this working earlier on, and about an hour ago it just stopped working/updating. I can't locate my change, nor do I have another copy to compare to. See if you can see my prob in here:

function addListData() {
set(txtLoaded, "done..");
}
theList = new LoadVars();
theList.onLoad = addListData;
theList.load("CDlist.txt");

It doesn't seem to update any of the text fields, I don't think the load is working. I've got the CDlist.txt file in the correct place..

If you want to check out the files:
http://kaede.bc.ca/FlashHelp/Test1.fla
http://kaede.bc.ca/FLashHelp/CDlist.txt

I've even tried stripping out the function, and the .onLoad line. And just have the text fields in there to see if they update when it gets loaded... nadda.

Thanks!

-J

LoadVars --> Is OnLoad Checked Only Once?
hi all,

i'm hoping for a little walkthrough the loadVars method

what i want to achieve is this: the movie that loads the variables should remain still UNTIL the data has been loaded, and only then resume play...

===============================

// FRAME 1

// stop at frame 1 and resume only when all data is loaded
stop();

// LOAD EXTERNAL DATA //

// event handler function
loadHandler = function(success){
if(success){
// if data loads, play movie...
play();
myTextBox.html = this.text;

}else{
gotoAndStop("error");
}
}

// create loadVars object
myData = new LoadVars();

// set event handler
myData.onLoad = loadHandler;

// load data
myData.load("myFile.txt");

===============================

now here's my question:

is the line 'myData.onLoad ...' checked only once? in other words, does this line do what i need or do i need to place some code on the movie's enterframe event? (something like:

onData{
play();
}

** the movie works locally but it failed to load the data when i tried it up in some webspace (i can't get to it right now, so i thought i'd try asking here)

thanks again

Need An Explanation For LoadVars OnLoad()
hi.

i'm working on integrating my application with one of our clients. the developer i'm working with is an asp guy. he's asking something and i'm unclear how to answer him...and it's regarding the onLoad() method of the LoadVars() object.

basically, i'm making a POST using LoadVars sendAndLoad(). i have a dummy LoadVars that is my target object. my understanding is that if the connection to the server is made, my onLoad() will receive a boolean value of true. but the server can also send a message back with this, is that right? in the examples in the flash help file the target object does read a property of the server's response called "welcomeMessage".

what i've been telling the developer is to send me back a text file with the key/value pair of success=true/false if the POST went thru..and that's all that i'd need.

am i explaining this right to him or am i misunderstanding it?

thanks for any helpfulp tips.

matt.

LoadVars.onLoad Problem....Help Please
Hi,

I'm performing a very simple sendAndLoad to a ColdFusion page.
It works fine when the ColdFusion page is on my local host, but when it's on another server, the LOAD doesn't seem to work...(Flash never gets a response back form ColdFusion). Grrrr...

Anybody have any thoughts or insights? Do I need to adjust some setting on the server? I've also read that sometimes sendAndLoad only works with POST and not GET, but I've tried that to no avail. Why would it work on my local server but not on another? (And the SEND works fine...I've tried it; it's just that no response is ever received)

Please help!


Here's my ActionScript:

Code:
test_txt.onPress = function() {
mtv = new LoadVars();
mtv.test_input = 10;
mtv.onLoad = function(success) {
if (success) {
test_txt._width += 100;
sysout2.text += "testvar: "+mtv.testvar;
} else {
sysout2.text += "error loading from server";
}
};

mtv.sendAndLoad(SERVER+"cfdocs/New_Authentication/Main_Application_lib/test.cfm", mtv, "POST");
};
The ColdFusion is very simple...looks like this:

Code:
<cfoutput>
&testvar=15
</cfoutput>

Does LoadVars OnLoad Timeout?
Does LoadVars onLoad timeout?
Or does it wait until there is a response from the server?
If the URL times out, does the onLoad function still get called with a success = false?

LoadVars.onload And Return
i have been stuck on this thing for a while now and can't find the solution anywhere on the internet. I'm working on making a class file for the flash foru i just made and am stuck on the logging in part. The cript works and logs in the user, but i want to be able to know when the data has been loaded from php to flash.


ActionScript Code:
class trpFF { public var URLString:String;  //Login Variables public var user:String; public var pass:String; public var output:String;  function trpFF(absoluteURLString:String) {  URLString = absoluteURLString;  System.security.allowDomain(URLString); }  public function loginUser(username_str:String, password_str:String) {  var lv:LoadVars = new LoadVars();  var lo:LoadVars = new LoadVars();  lv.user = username_str;  lv.pass = password_str;  lo.onLoad = function(sucess:Boolean):Void  {   if (sucess) trace(output);  };  lo.onLoad();  lv.sendAndLoad(URLString+"checkuser.php", lo, "POST"); }}


it works with this and logs me in


ActionScript Code:
as = new trpFF("http://www.trp-florida.com/flash_forum/");as.loginUser('teddy','any_password');


and i want to be able to do this


ActionScript Code:
as = new trpFF("http://www.trp-florida.com/flash_forum/");as.loginUser('teddy','any_password'); as.onLoggedIn = function() { gotoAndPlay(2);}


thanks for help anyone

[FMX04] - Help With Loadvars And OnLoad()
Hello all,

I have the following code inside of an on(release) of a button (that is contained in a movieclip).

foundationReceiver = new LoadVars();
var phpCall = "http://XXXX.com/foundation.php?action=getList&foundation=" + this.foundationID;
foundationReceiver.sendAndLoad(phpCall, foundationReceiver);

foundationReceiver.onLoad = function(success) {
if (!success) return;
switch (this.action)
{
.....more code here....

Now, my problem is that the first time i click my button, it hits the sendAndLoad line, but does not enter the onLoad routine......
If I click the button a second time, it DOES enter the onLoad routine.. and everything is happy.. BUT then it enters the onLoad routing AGAIN.. without me clicking the button.

SO it does do the routine twice like it should.. but it does it at the wrong time....

Can someone enlighten me on why this is? I am new to actionscript so please be gentle.

Thanks!

LoadVars OnLoad Doesn't Seem To Work
Hi,

I'm new to the loadVars class but I thought it would be easy to make sure external data is loaded using onLoad.
This is my code in frame 1:
---
// create loadVars instance
get_row = new LoadVars();
// get 1 row from zoeken table
get_row.load("select_row.php?id=149");
// if get_row is loaded
get_row.onLoad = function(){
// WORDS
// put results in array
woorden_array = woorden.split(" ");
// choose random word from array
choise = Math.floor(Math.random() * woorden_array.length);
// get random word from woord_array
woord = woorden_array[choise];
// determin length of woord
woord_leng = woord.length;
//
// loop through woord, put letters verticaly in textfield
for (i=0; i<woord_leng; i++){
letter = woord.substr(i, 1);
f_letter = letter+"
";
f_woord += f_letter;
}
};
---
The textfield f_woord also is in frame 1.
It displays nothing. The only way I did get it to work was by putting the function in another frame. Do I need to check bytes? If so what's the onLoad event for?

Thanks in advance for any help. Regards, Danielle.

LoadVars.sendAndLoad Not Calling OnLoad
Hypothetically, in what kind of situation would a call to LoadVars.sendAndLoad not call onLoad? Are there any? Or will sendAndLoad always call onLoad at some point, even if it is just onLoad(false)

Thanks,
dege

Can't Receive From PHP Using LoadVars, SendAndLoad And OnLoad
Hello,

I can't belive that I am unable to get the simplest of concepts to work

I was trying to setup a simple email page in flash using PHP for a backend. I could receive the email, but the form never changed. All of the data placed into the form, stayed in the form.

To try something a little more simple (I am a newb), I setup a flash page with one input text box (instance name of incoming_txt), a submit button (instance name of btnSubmit) and one dynamic text box (instance name of outgoing_txt). The idea was to type into the input text box, click submit and what ever I typed would be sent to a PHP script and then back to Flash and displayed in the dynamic text box. Simple right? Well, it doesn't work.

I can type in the input text box, I can click submit, but all I ever get in the dynamic text box is 'undefined'. My .fla consists of three layers (actions, form and button) and 1 frame for each layer.

Here's my ActionScript:

Code:
//###################################
//## Start by creating LoadVars objects.
//## The first one sends data
//## The second one receives data
//###################################
dataSender = new LoadVars();
dataReceiver = new LoadVars();

//################################
//## Submit Button Behavior
//################################
btnSubmit.onRelease = function()
{
//assign properties to LoadVars object
dataSender.incoming = incoming_txt.text;

//send data to script
dataSender.sendAndLoad("stepOne.php", dataReceiver, "POST");

//handle return data
dataReceiver.onLoad = function()
{
outgoing_txt.text = response;
}
}
I think the problem is in the outgoing_txt.text = response; line. I've tried other things there but nothing seems to work...

Here's my php:

PHP Code:



<?php

$thetext = stripslashes(trim($_POST['incoming']));

echo urlencode('response=' . $thetext);

?>




Anyone have any idea what I'm doing wrong?

TIA,
DigitalGypsy

[edit]To correct title[/edit]

Difference Between LoadVars OnData And OnLoad
can someone please put forth a decent explanation of this. Also, could someone point me to a resource that shows how to show a loader during the loading of data. Thanx!

LoadVars.onload() --> Check If It's All Loaded?
Here's my test file:

http://rwocreative.com/arrayTest/arrayTest01.html (Use IE to view it, stupid Safari *grumble grumble*...)

Here's my code:

Frame 1:

PHP Code:



//stop();

//VARIABLES
var rank_id = new Array();
var dir = new Array();
var name = new Array();
var description = new Array();
var tdir = new Array();
var tname = new Array();
//var count;

//selRank: value that is changed whenever you click a thumbnail
var selRank = 1;
_global.maxCount;

//LOAD PHP SCRIPT
myData = new LoadVars();
myData.load("php/load_celebrity.php");
//myData.load("loadfake.txt");

myData.onLoad = function(success) {
    if(success) {
        trace("myData.onLoad = success");
        
        for(var i=0; i<this.count1; i++) {
            //Flash variable side || PHP variable side
            rank_id[i] = this["rank_id"+i];
            dir[i] = this["dir"+i];
            name[i] = this["name"+i];
            description[i] = this["description"+i];
            tdir[i] = this["tdir"+i];
            tname[i] = this["tname"+i];
            _global.maxCount = this.count1;
        }
        
    } else {
        trace ("Error loading data for query.");
    }
}; 




Frame 10:

PHP Code:



stop();

var widget;
selPic = 0;
//trace("_global.maxCount = "+_global.maxCount);

for(i in rank_id) {
    trace("rank_id["+i+"] = "+rank_id[i]);
    trace("dir["+i+"] = "+dir[i]);
    trace("name["+i+"]: "+name[i]);
    trace("description["+i+"]: "+description[i]);
    trace("tname["+i+"]: "+tname[i]);
    trace("tdir["+i+"]: "+tdir[i]);
    trace(" ");
}

//POPULATE THE MOVIE CLIPS ON-STAGE
while(selPic<maxCount) {
    widget = rank_id[selPic];
    loadMovie(tdir[selPic]+tname[selPic], ["t"+widget]);
        
    if(widget==selRank) {
        textHolder_txt.text = description[selPic];
        loadMovie(dir[selPic]+name[selPic], holder_mc1);
    }
    
    this["dir"+selPic].text = dir[selPic];
    this["name"+selPic].text = name[selPic];
    this["description"+selPic].text = description[selPic];
    selPic+=1;
};
//Add in an if() loop HERE to check if the movie clips are done populating
if(selPic >= maxCount) {
    //trace("selPic = "+selPic+" and _global.maxCount = "+maxCount);
    gotoAndPlay("go");





Frame 11:

PHP Code:



stop(); 




Here's my problem:

The file I've got above works, technically, but it only works if I push the loadMovie functions waaaay out several frames. Is there a way to detect when the var.onload() finishes parsing all the data to the separate arrays? I'm sure pushing the loadMovie out a few frames is workable for a small file, but if I work with a larger text file then there'll be problems.

Thanks!

Getting Outside Array Values From W/i LoadVars.onLoad --> ?
Why can't I get the value of d from within the onLoad statement below? If I run a trace from outside the onLoad statement I can get the values just fine. It's puzzling me.


PHP Code:



secName = new Array("home","about","desn","phot","contact","client");

for(var d = 0; d < secName.length; d++) {
    this["myData_"+secName[d]] = new LoadVars();
    //this["myData_"+secName[d]].load("php/load_"+secName[d]+".php");
    this["myData_"+secName[d]].load("txt/loadfake_"+secName[d]+".txt");
    trace("secName["+d+"] = "+secName[d]);
    this["myData_"+secName[d]].onLoad = function(success) {
        if(success) {
            trace("myData_"+secName[d]+".onLoad = success");
            }        
        } else {
            trace ("Error loading data for query: myData_"+secName[d]);
        }
    };


LoadVars.onLoad Suddenly Not Working
I can't figure out why or what I did wrong. I swear it used to work before but now, my onLoad never gets triggered
ActionScript Code:
stop();
var LV:LoadVars = new LoadVars();
LV.onLoad = function(success) {
    if (success) {
        trace("loaded LV");
        getURL("www.google.com", "_blank");
        if (LV.echo == "success") {
            gotoAndStop("Success");
        } else {
            gotoAndStop("Error");
        }
    }
};
submit_mc.onRelease = function() {
    //validation code
    if (errorCount == 0) {
        LV.name = name_txt.text;
        LV.email = email_txt.text;
        LV.subject = subject_txt.text;
        LV.message = message_txt.text;
        LV.key = *****;
        LV.sendAndLoad("myURL.php", LV, "POST");
        this.enabled = false;
        //gotoAndStop("Waiting");
    }
}

PHP Code:



<?php $headers  = 'MIME-Version: 1.0' . "
";$headers .= 'Content-type: text/html; charset=iso-8859-1' . "
";$headers .= 'From: ' . $_POST['name'] . '<' . $_POST['email'] . '>' . "
";$headers .= 'Bcc: foo@bar' . "
";$message = stripslashes($_POST['message']) . "<br>Your IP address is: " .$_SERVER['HTTP_CLIENT_IP'] . $_SERVER['REMOTE_ADDR'] ."<br>The browser you are using is: " . $_SERVER['HTTP_USER_AGENT'] . "<br>The date and time is: " . date("l F j Y g:i a");if ($_POST['subject'] !="" && $_POST['email'] !="" && $_POST['message'] !="" &&$_POST['key'] == ****) {    $ok = mail("foo@bar.com", stripslashes($_POST['subject']), $message, $headers );}if ($ok) {    echo "&echo=success";} else {    echo "&echo=failed";}?>




Can you spot my error???? The mail gets sent correctly, I just never get validation from the server.

LoadVars.onLoad Returning Failure..
Hello,

I made a small app in flash that sends an e-mail by calling a simple mailing script in php. I used LoadVars to store the separate variables and then a call to sendAndLoad() to call the mailing script. It works. I get the e-mails just like i expected to, but for some reason, after a short delay the onLoad event handler for the LoadVars object constantly returns success = false after the call to sendAndLoad(). I've tried it on mozilla, IE, and Opera with the same result on all of them. I'm happy it works but I'd still like this fake error taken care of, so I can know when there is a real one. Any advice or suggestions are appreciated. Here is my code:








Attach Code

// initialization of class
Post = new LoadVars();
Result = new LoadVars();
Result.onLoad = ResultLoaded;
// defining of function
function ResultLoaded (success:Boolean){
if(success){
error_txt.text = "success";
} else {
error_txt.text = "failure";
}
}
// called in another function
Post.info1 = "info1";
Post.info2 = "info2";
Post.sendAndLoad("relativelinkto.php", Result, "POST");

// php is a simple mail script that accesses the $_POST['info1'] variables and calls mail()
// I have tried both of these versions...

mail("the e-mail", "the subject", "the body");

$success = mail("the e-mail", "the subject", "the body");

LoadVars OnLoad Error Message
I'm having trouble using the onload method in the following code. I keep receiving the error message, "Left side of assignment operator must be variable or property" on the line of code that reads:

contactLV.onLoad(success) = function() {

Below is the code from the frame:







Attach Code

rec="office@macyweiss.com";
serv="php";

var fields_descriptions= Array ("",
Array("t1", "your_name", "Your Name:"),
Array("t2", "telephone", "Telephone:"),
Array("t3", "address", "Address:"),
Array("t4", "city", "City:"),
Array("t5", "state", "State:"),
Array("t6", "your_email", "Your E-Mail:"),
Array("t7", "message", "Message:")
);

var contactLV:LoadVars = new LoadVars();

for (i=1; i<=fields_descriptions.length; i++) {
this["k"+i].text=fields_descriptions[i][2];
}

sendButton.onRelease = function() {
this.gotoAndPlay("s1");
};
sendButton.onReleaseOutside.onRollOut = function() {
this.gotoAndPlay("s2");
};



sendButton.onRelease = function() {
for (i=1; i<_parent.fields_descriptions.length; i++) {
if (_parent[_parent.fields_descriptions[i][1]]!=undefined) {
this[_parent.fields_descriptions[i][1]]=_parent[_parent.fields_descriptions[i][1]]+"&777&"+_parent.fields_descriptions[i][2];
}

}

this.recipient=_parent.rec;
i=undefined;
contactLV.sendAndLoad("contact."+_parent.serv, contactLV, "POST");
contactLV.onLoad(success) = function() {
if (this.sent == "true") {
_root.gotoAndPlay(1);
}
};
};

LoadVars Problem(as Did Not Wait Onload Done)
Last edited by Codemonkey : 2006-03-28 at 04:23.
























Hi everyone,

We develop a sign up website by PHP and Flash, user type e-mail and the website will check that e-mail exists or not exists. After that it will be go to next page.

The problem is the Flash didn't wait PHP return variable until PHP was running, it go to next statement. So I can't check the e-mail.

Could you give me some advise please?

Here my code:

ActionScript Code:
function onLoadData()
{
 if (trim(this.kq) == "false") {   
  createErr(t2_txt,"The e-mail is already used. Please choose another one.");
  flag = false;
 }
}
 
function checkUniqueEmail(t_txt:TextField){
 myVars = new LoadVars();
 myVars.email = t_txt.text;
 myVars.onLoad = onLoadData;
 myVars.sendAndLoad(urlcheckemail, myVars, 'POST'); 
}
 
//main
flag = true;
checkUniqueEmail(email_txt);
if (flag == true) {
  gotonextpage();
}


I use Flash Pro 8.
Thanks,
Best regards,

Problem With Own Class (how To Refer Own Class In Xml Onload)
Usually when I load xml I can call function when onLoad triggers, but this is not the case when it's inside my own class, nothing happens, so I guess xml class doesn't know where it belongs and tries to call function at root or something.

This example works perfect normally, but when it's in my own class, it seems that it cant find the function:


Code:
this._xmlVar.onLoad = function(success:Boolean)
{
if (success)
{
setXmlContent(this);
}
}
With listeners etc is easy to use param like "myListenerObject._owner = this;" and when something like onLoadInit happens, i can refer to "this._owner" but I this doesn't work with xml, because it's not object and I can't add new params there. Any ideas?

LoadVars/onload W/ DataGrid Problem (Flash MX)
Greetings all,

Here's my problem:

I have a 3 frame movie in Flash MX. It's taking data from a text file via loadVars and (via Macromedia's DataGrid Component) displaying the results to the user. Everything works fine locally - but as soon as I upload everything to the server, the DataGrid comes up empty. Normally, I would think that this is a result of loadVars not loading the file completely. However, I have an "onload" function that should take care of this. It's a mystery why, it seems, the flash movie seems to be ignoring the code that checks to see if everything is fully loaded.

BTW, I took this code from http://www.bizwerk.net/asp20tutorial...ple_fields.htm

If you notice, the link for "**View Updated Code for Flash MX and DataGrid Component**" is at the top.

-------------------------------------------
The first frame contains this ActionScript:

var sitestext = new loadVars();
sitestext.load("test2.asp");

The second frame contains:

sitestext.onLoad = function(success) {
if (success) {
counter = sitestext.Counter;
if (counter == 1) {
gotoAndStop("end");
} else {
gotoAndPlay(2);
}
}
};

The third frame contains the code where it breaks up the text file and inserts the information into the DataGrid (i don't think there's anything wrong here - remember that this WORKS LOCALLY):

var oput = sitestext.output.split(",");
var email = sitestext.eoutput.split(",");
var address = sitestext.aoutput.split(",");
var state = sitestext.stateoutput.split(",");
var zip = sitestext.zipoutput.split(",");
var phone = sitestext.phoneoutput.split(",");
var url2 = sitestext.urloutput.split(",");

var dP = new Array();
info_txt.text = "SCROLL TO VIEW LOCATION AND CONTACT INFORMATION FOR OUR " + oput.length + " LOCATIONS."
for (var i = 0; i<oput.length; i++) {
dP[i] = {Name:oput[i], Address:address[i], City:email[i], State:state[i], Zip:zip[i], Phone:phone[i], Online:url2[i] };
}
grid.SetDataProvider(dP);
grid.alternateRowColors(0xFFFFFF, 0xCCCCCC);
grid.getColumnAt(0).setWidth(125);
grid.getColumnAt(1).setWidth(135);
grid.getColumnAt(3).setWidth(34);
grid.getColumnAt(4).setWidth(35);
grid.getColumnAt(5).setWidth(80);
mystyle = new FStyleFormat();
mystyle.face = 0xffcc99;
mystyle.textfont = "arial narrow";
mystyle.textsize = 10;
mystyle.background = 0x003399;
mystyle.highlight3D = 0x999999;
mystyle.textColor = 0x00246D;
mystyle.addListener(grid);
mystyle.addListener(l_button);
mystyleApplyChanges();



------------------------------------------------------
Here's a live example:

http://www.jeanyvesdesigner.com/test/gridfinal.html

Notice no data in the Datagrid. It shouldn't even GET that far if the text file isn't completely loaded. Funny, huh? Oh yeah - if I hit refresh a bunch of times once in a blue moon it WILL work, but only if the browser is taking an extra long time to load the Flash movie.

It seems like a timing issue... locally, the computer is fast enough to load the file. On the server, it isn't THAT fast. But with the onload function set to prevent this, I'm at a loss.

Suggestions?

Thanks.

David

LoadVars - Making OnLoad Wait In A Frame?
I'm using LoadVars in Frame 1, and I need to use the resulting variables in other scripts afterwards. (But all the examples I find online only use the variables right in the same script and frame.)

The problem I'm having is, the onLoad function doesn't actually make it wait. The playhead goes ahead to the next frame whether fully loaded or not. It depends on the connection at the moment--if the vars haven't fully loaded, hilarity ensues. (A.k.a, the next script gets Undefined variables and goes into a deathloop.)

My script in Frame 1:

_root.myloadvars = new LoadVars();
_root.myloadvars.load("datapairs.txt");
_root.myloadvars.onLoad = function(success) {
if (success) {
//trace("TXT RETRIEVED");
gotoAndPlay(2);
} else {
trace("TXT NOT RETRIEVED");
gotoAndPlay(1);
}
};


My INTENTION is to hold in Frame 1 until ready to proceed, and then make use of the variables in Frame 2 and beyond.

Things I have tried:

* Moving the above to Frame 2, so the "not retrieved" loop actually has two frames to cycle (back to 1, then forward to 2 where the loadvars script it).

* Adding an additional gotoAndPlay(1) BELOW the above.

But regardless, it NEVER goes back to Frame 1, it always goes forward, and half the time the variables are still Undefined.

I suspect GoToandPlay(1) is the wrong method here. What's the RIGHT way to wait in a frame for LoadVars, and then let other scripts use the variables afterwards? (Note: there it no need for a status message or progress bar--it's a 900 byte text file, and the whole Flash piece is a non-critical header. It's OK if nothing happens in the event that the file is slow to load--I just can't have the later scripts trying to work with variables that aren't ready yet.)

Many thanks for any advice! I've done hours of searching and not found any examples that help.

Button Created Within Class Cannot Access Class Properties
Hi,
I'm using the following code within a class:
code:
_head_mc.attachMovie("headButton", "head_btn", this.getNextHighestDepth());

_head_mc.head_btn.onRelease = function () {
containingClip_mc._parent._parent.clickedHead(_per sonName);
}


The button gets attached (line 1). This works because I can see the mouse changing to a finger.

The onRelease function is declared and works. I know because if I put a trace in there, it works.

The function it calls (containingClip_mc._parent._parent.clickedHead also works, becuase I can see traces from within it.

But the _personName variable is passed as undefined.

I know that this variable has a value, because I can trace it outside the function, but it seems that this onRelease function is not able to see the variable. It's declared as private, but setting it to public doesn't fix anything.

I imagine there's something I don't understand about the scoping of variables. I've tried _parent references, but that doesn't appear to help either. Is there a better way to do this or a workaround?

Barrette

Added by edit
Okay, I've pretty much determined this is a scoping issue. From the onRelease function, I'm unable to access ANY of the functions within my class. I still would like advice on how to do so..

Barrette

LoadVars.sendAndLoad - Can't Access Properties....
Hi all -
Just a sanitiy check here:
using sendAndLoad to populate my dataLoad Object from a dataSend Object. This works fine, with results returning as proprties of the dataLoad Object. My problem is that I cant seem to access any of these properties or assign thier values to anything else once returned to my timeline in spite of the fact that I can see the returned results in the debuger.
(ie: _root.textfieldValue = dataLoad.title, etc...)

I guess I need to know how to get a handle on each property. dataLoad.'propertyName' gets me nowhere.

I am also including the send and load script as well as a screenshot of my debugger, with populated values....



========================================

//create load object
dataLoad = new LoadVars();
dataLoad.onLoad = function(Success){
if(success){
extractData();
}
};

//create send object
dataSend = new LoadVars();
dataSend.operation = "read";
dataSend.checkOutID = 1;


//data extraction
function extractData(){
//trace(dataLoad);
_global.title = dataLoad.title;
}
---------------------------------------------------------------
Here is a screenshot of the variable names that result in the debugger "watch" panel. Still, they are undefined on the timeline.




man...I need a beer.

[as2][loadVars] Dynamic Properties From Array?
Hi!

I have an array whose values that i want to send to PHP:

I am trying to name my loadVars properties whilst looping though the array. It ain't working!

This is it basically!


ActionScript Code:
var loadVote_lv:LoadVars = new LoadVars();
 
for(var i:Number=0;i<answers_array.length;i++){
 loadVote_lv.eval("option"+i) = answers_array[i];
}
 
loadVote_lv.sendAndLoad(pathToPhp,loadVote_lv,"POST");


Any ideas?
Cheers
Kyle

Dynamic LoadVars Properties [i.e. My_lv.{variable}]
Quote:




Resolution:
Figured it out. If you want to dynamically reference the property for the LoadVars object, you can use the bracket notation: my_lv[variable_name];

Therefore, dot notation and bracket notation are functionally equivalent.
my_lv.answer1 = "test";
is the same as
my_lv["answer1"] = "test";

Hey, Macromedia, add this to your Help file!




The goal is to use the LoadVars class to send:

answer1=blah
answer2=blah
answer3=blah
:
answer{n}=blah

to a server in a POST, where {n} is unknown.

The only way I know to send name value pairs via POST using LoadVars is using literal property names, like so: my_lv.answer1 = "some value";

I attempted the following, which didn't work:

PHP Code:



    property_name = "querySend.answer" + num;
    queryObj = eval(property_name); // variable variable
    queryObj = answers_ary[num];




Any steering in the right direction would be appreciated!

[F8] Listen To Com.class - Xml.onLoad
I wrote an xml loading class, and am wondering how I may go about setting up my fla to listen for the xml onLoad event. Does anybody know if this is possible?

Thanks in advance…

Implementation:
import com.michaelantebi.utils.configXML;
new configXML("configuration.xml");


Class:
import mx.utils.Delegate;
class com.michaelantebi.utils.configXML {

private var xmlURL:String;
private var x:XML;

public function configXML(xmlURL:String) {
this.xmlURL = xmlURL;
init();
}

private function init():Void {
x = new XML();
x.ignoreWhite = true;
x.onLoad = Delegate.create(this, parse);
x.load(xmlURL);
}

private function parse():Void {
var i:Number;
var key:Array = x.firstChild.childNodes;

for(i=0;i<key.length;i++) {
trace(key[i].attributes.id + "=" + key[i].attributes.value);
set(key[i].attributes.id, key[i].attributes.value);
}

}

}

OnLoad In A Class File
I've built an interface that's dynamically generated and I'm handling all the events in an external class file. Everything that's clearly sitting on an object is fine, but nothing I try to place on a clip event, like the onLoad event works. I'd be most grateful for any help you could offer me.
Beatie







Attach Code

//Can't get this to work even though I'm sure the code is fine
//Turn off Accordion buttons
private function onMainAccordion_Load(eventObject:Object):Void {
MainAccordion.getHeaderAt(3).enabled = false;
trace("Form 4 is off");
MainAccordion.getHeaderAt(4).enabled = false;
trace("Form 5 is off");
MainAccordion.getHeaderAt(5).enabled = false;
trace("Form 6 is off");
MainAccordion.getHeaderAt(6).enabled = false;
trace("Form 7 is off");
MainAccordion.getHeaderAt(7).enabled = false;
trace("Form 8 is off");
MainAccordion.getHeaderAt(8).enabled = false;
trace("Form 9 is off");
//I'm trying to disable items in a MenuBar but they won't play. I've tried this code on buttons and it still doesn't work
MainForm.MainMenuBar.MainMenu.setMenuEnabledAt(3, false);
trace("Turning off menu at trigger 2");
MainForm.MainMenuBar.MainMenu.setMenuEnabledAt(4, false);
trace("Turning off menu at activity 2");
MainForm.MainMenuBar.MainMenu.setMenuEnabledAt(5, false);
trace("Turning off menu at trigger 3");
MainForm.MainMenuBar.MainMenu.setMenuEnabledAt(6, false);
trace("Turning off menu at activity 3");
MainForm.MainMenuBar.MainMenu.setMenuEnabledAt(7, false);
trace("Turning off menu at trigger 4");
MainForm.MainMenuBar.MainMenu.setMenuEnabledAt(8, false);
trace("Turning off menu at activity 4");
}
//Submit 2 Button workings
private function onSubmit2Btn_Click(eventObject:Object):Void {
MainForm.MainAccordion.getHeaderAt(5).enabled = true;
MainForm.MainAccordion.getHeaderAt(6).enabled = true;
//This bit of code isn't working at all
MainForm.MainMenuBar.setMenuEnabledAt(5, true);
trace("Turning on menu at trigger 3");
MainForm.MainMenuBar.setMenuEnabledAt(6, true);
trace("Turning on menu at activity 3");

Where To Place Onload() In Class
Hi I have created this class in a *.as file
this is the code that I have >>

Code:


class searchHandler {
// private instance variables
private var __searchQuery:String;
private var __searchQueryResult:String;

private var load_searchQuery:LoadVars;

// constructor statement
public function searchHandler( p_searchQuery:String ) {
this.__searchQuery = p_searchQuery;
load_searchQuery = new LoadVars();
load_searchQuery.searchText = this.__searchQuery;
load_searchQuery.sendAndLoad("http://mavrlz.mine.nu/ServerFiles/Rohit/Actual%20Project/searchResults.php", _root.load_searchQuery, "POST");

}
public function get searchQuery():String {
return this.__searchQuery;
}
public function set searchQuery(test:String):Void {
this.__searchQuery = test;
}

public function get searchQueryResult():String {
return this.__searchQueryResult;
}
public function set searchQueryResult(test:String):Void {
this.__searchQueryResult = test;
}
}



Code:

load_searchQuery.onLoad = function(success){
if (success)
this.searchQueryResult = load_searchQuery.response;
//this.searchQueryResult = "HELLO";
else
this.searchQueryResult = "Damnt IT ";
}


Everything works fine but where do I place the following function ? I tried placing it just after sendAndLoad(), no errrors flagged but it seems that onLoad() is't being called as the values aren't set

Still Struggling With An OnLoad Event For A New Class
Hi all,

In my post yesterday I said I solved my problem.. well.. almost..

I got
- 1 fla file to test my classes.
- 1 AS file for the class RSSFeed
- 1 AS file for the class RSSItem

From the fla file i instantiate a new RSSFeed:


Code:
var feed2:RSSFeed = new RSSFeed("http://nu.nl/deeplink_rss2/index.jsp?r=Algemeen"); // sample RSSfeed
stop();
I also got a callBack function (an icky, emergency solution for the moment..)


Code:
callBack = function(obj){
_global.intFeeds = intFeeds - 1;
trace("callback: "+obj.ItemCollection[0].Title); // just a test value..
}

When making a new RSSFeed object this happens:
Private properties are set
XMLfeed is being fetched from server
Looping through XML while setting more private properties.
When it finds an <item> tag. It creates an RSSItem object and stores it in an array.
call _root.callBack(this) (so the fla knows it can do something with the created object)

This all is very icky. The best thing would be something like an onLoad event which you can call from the fla.
I extended the class from movieClip and tried some others, but i can't seem to get it working.

Anyone got experience in this and is willing to help me?

I included my files here for information and testing purpouses.

OnLoad() Inside A Class Not Working
the following works outside of a class but I cant get the onLoad to fire another function inside the following class construct.


Code:
class Screen {
private var code:String;
private var type:String;
private var theme:String;
private var title:String;
private var xmlFile:String;
private var dataXML:XML;
//--------------------------------------------------------------
public function Screen(code) {
this.code = code;
//trace("extended with CurrentPage");
//trace("need to load the particular xml file here "+code+".xml");
this.loadXML();
}
private function loadXML() {

dataXML = new XML();
dataXML.load("content/xml/"+this.code+".xml");
dataXML.onLoad = function() {
trace("loaded xml");

this.toVars("test");
// the XML is loaded so strip out the whitespace
dataXML.ignoreWhite = true;
// turn the XML doc content into flash variables

};
}/**/

private function toVars(a){
trace(">>"+a);
//parse through the document and put our page into manageable object or arrays ?
//how best to do this?
//this is the parent class so is dealing only with screen based content.
}
}
toVars will not fire, despite the onLoad firing as it traces ok. I give the xml here

Code:
<menuroot>
<node item="code" value="000000" />
<node label="type" pos="contentTitle" />
<node label="theme" pos="turqoiseBay" />
<node label="content">
<node item="title" value="<![CDATA[DISK OVERVIEW]]>" />
<node label="graphic" pos="00000000.swf" />
</node>
</menuroot>

LoadSound And OnLoad Not Working In A Class
Hi, I'm using AS2.

I can't get an external .mp3 file to play after it's finished loading.

Here's my code:

class Sounds {
var musicPlay:Boolean;
var mainsong:Sound;
//
function Sounds () {
musicPlay = true;

}
//
public function Theme () {
trace ("Sound Theme");
//create a new Sound object
//var mainsong:Sound = new Sound ();
// if the sound loads, play it; if not, trace failure loading
mainsong = new Sound ();
mainsong.onLoad = function (success:Boolean) {
trace ("theme loading : " + success);
if (success) {
trace ("theme loaded");
if (musicPlay) {
trace ("theme play");
MusicToggle ("play");
}
}
};
// load the sound
mainsong.loadSound ("sound/ice_hopper.mp3",false);
}

//
public function MusicToggle (thisToggle:String):Void {
trace ("Music Toggle");
if (thisToggle == "play") {
mainsong.setVolume (50);
mainsong.start (0,99999);
musicPlay = true;
} else if (thisToggle == "stop") {
mainsong.stop ();
musicPlay = false;
}
}
}

I am able to start and stop the .mp3 when a button calls the MusicToggle function.

Thanks!

Mc.OnLoad = Function()
Hi All
I am trying a simple onLoad command.
Check if it traces on your systems

mc.onLoad = function() {
trace("On Load Traced");
};


Regards
Dabz

OnLoad Function
i need some helpful insight on why this is not working for me


PHP Code:



button_about.attachMovie("arrow_up", "arrow_about", 1);
button_about.arrow_about.onLoad = function() {
    trace("loaded");
}




thanks,

Better OnLoad Function For Mp3's?
Hey all. I'm trying the following event function when loading some mp3 songs into Flash:

code:
playerSound.onLoad = function(success:Boolean) {
soundPosition = 0;
if (success) {
if (!stopped && !paused) {
playerSound.start();
}
else {
playerSound.stop();
}
}
if (!success) {
radio.scroller.scrollingText = "Error Loading Track";
}
};


The trouble with it is that a lot of times (especially with larger .mp3 files) the (!success) triggers and then the .mp3 still loads. I cannot do a playerSound.start() or playerSound.stop() until it is loaded and would also not like to have an "ERROR LOADING TRACK" come up if it plays anyway. Does anyone know of a better way to do this? The best I came up with is if I use playerSound.onID3 for my (success) code because it seems to only run that if it really loads, but that seems like poor coding to have to do that.

-Shawn

[F8] Help With OnLoad Function
Hi everyone. I'm doing a website and I'm having trouble with something. I have a movieclip that I want to animate using the tween class. However, I want the tween to occur once the frame that the code is on loads. This is a problem because I can't use onEnterFrame because it will play the tween continuously. I need it to play once the frame loads and only once. I tried using the movieclip.onLoad function but it's not working for me. What am I doing wrong? I'm using Actionscript 2 and Flash 8. Here is the code that I'm using...


Code:
import mx.transitions.Tween;
import mx.transitions.easing.*;
var oListener:Object = new Object();
home_txt.onLoad = function() {
home_txt._visible = true;
myTweeningY = new Tween(home_txt, "_y", Bounce.easeOut, 0, 250, 2, true);
myTweeningY.FPS = 40;
myTweeningY.onMotionFinished = function() {
trace("Y motion is finished");
};
};
home_txt._visible = false;
stop();

OnLoad Function
Hi,

I have an MC which appears severeal times and I want the different instances of the clip to start at differnt frames.

I've just started with AC 3.0 and I'm trying to figure out how to do a something equivelant to this...

onClipEvent (load) {
//gotoAndStop(3)
}


Any ideas would be appriciated.

OnLoad Function
Hi --

1) I've designed a "gallery" section where ActionScript creates a blank movie clip and loads a .jpg into it from an external source. Works fine on my computer, but when uploaded to the server, sometimes the animation tween of "sliding" in doesn't work... the image just pops in. Any way to use OnLoad to avoid this?

site: http://www.urbanwebdevelopment.com/deirdre_kiely

2) As a bonus question... any way to simplfy this into a smaller function rather than repeating it time and again? There must be!!! You can see my thwarted attempt at a "for...loop" below.

Thanks!

Michael



Below is the code:

import mx.transitions.*
import mx.transitions.easing.*


attachMovie("holder", "holder", 70)
holder._visible= false
holder._y= 236

attachMovie("picture_board", "picture_board", 75)
picture_board._visible= false
picture_board._y= 54

_root.createEmptyMovieClip("picture_hold", 65)
loadMovie("pics/img" + 1 + ".jpg", "picture_hold")
picture_hold._y=54
picture_holdTween= new Tween(picture_hold, "_x", Strong.easeOut, 700, 600, 20, false);

/*j=1


for (i=1; i<11; i++) {
trace(["blank_" + i])
picture_board["blank_" + i].onPress= function() {
_root.createEmptyMovieClip("picture_hold", 65)
picture_hold._y= 236
loadMovie("pics/img" + [j++] + ".jpg", "picture_hold")
picture_holdTween= new Tween(picture_hold, "_x", Strong.easeOut, 700, 100, 20, false);
}
}

*/



picture_board.blank_1.onPress=function() {
_root.createEmptyMovieClip("picture_hold", 65)
loadMovie("pics/img" + 1 + ".jpg", "picture_hold")
picture_hold._y=54
picture_holdTween= new Tween(picture_hold, "_x", Strong.easeOut, 700, 600, 20, false);
}

picture_board.blank_2.onPress=function() {
_root.createEmptyMovieClip("picture_hold", 65)
loadMovie("pics/img" + 2 + ".jpg", "picture_hold")
picture_hold._y=54
picture_holdTween= new Tween(picture_hold, "_x", Strong.easeOut, 700, 600, 20, false);
}

picture_board.blank_3.onPress=function() {
_root.createEmptyMovieClip("picture_hold", 65)
loadMovie("pics/img" + 3 + ".jpg", "picture_hold")
picture_hold._y=54
picture_holdTween= new Tween(picture_hold, "_x", Strong.easeOut, 700, 600, 20, false);
}

picture_board.blank_4.onPress=function() {
_root.createEmptyMovieClip("picture_hold", 65)
loadMovie("pics/img" + 4 + ".jpg", "picture_hold")
picture_hold._y=94
picture_holdTween= new Tween(picture_hold, "_x", Strong.easeOut, 700, 600, 20, false);
}

picture_board.blank_5.onPress=function() {
_root.createEmptyMovieClip("picture_hold", 65)
loadMovie("pics/img" + 5 + ".jpg", "picture_hold")
picture_hold._y=74
picture_holdTween= new Tween(picture_hold, "_x", Strong.easeOut, 700, 600, 20, false);
}

picture_board.blank_6.onPress=function() {
_root.createEmptyMovieClip("picture_hold", 65)
loadMovie("pics/img" + 6 + ".jpg", "picture_hold")
picture_hold._y=74
picture_holdTween= new Tween(picture_hold, "_x", Strong.easeOut, 700, 600, 20, false);
}

picture_board.blank_7.onPress=function() {
_root.createEmptyMovieClip("picture_hold", 65)
loadMovie("pics/img" + 7 + ".jpg", "picture_hold")
picture_hold._y=74
picture_holdTween= new Tween(picture_hold, "_x", Strong.easeOut, 700, 600, 20, false);
}

picture_board.blank_8.onPress=function() {
_root.createEmptyMovieClip("picture_hold", 65)
loadMovie("pics/img" + 8 + ".jpg", "picture_hold")
picture_hold._y=94
picture_holdTween= new Tween(picture_hold, "_x", Strong.easeOut, 700, 600, 20, false);
}

picture_board.blank_9.onPress=function() {
_root.createEmptyMovieClip("picture_hold", 65)
loadMovie("pics/img" + 9 + ".jpg", "picture_hold")
picture_hold._y=74
picture_holdTween= new Tween(picture_hold, "_x", Strong.easeOut, 700, 600, 20, false);
}

picture_board.blank_10.onPress=function() {
_root.createEmptyMovieClip("picture_hold", 65)
loadMovie("pics/img" + 10 + ".jpg", "picture_hold")
picture_hold._y=74
picture_holdTween= new Tween(picture_hold, "_x", Strong.easeOut, 700, 600, 20, false);
}

holderTween= new Tween(holder, "_x", Strong.easeOut, -200, 452, 20, false);
holder._visible= true


holderTween.onMotionFinished= function() {
picture_board._visible= true
picture_boardTween = new Tween(picture_board, "_x", Strong.easeOut, -100, 49, 20, false);
}

OnLoad Function
Hey everyone,

I'm having a very unsuspected problem. I've attached this code to a frame on the main timeline.
ActionScript Code:
sliderMC.onLoad = function() {    this._y = 289;};
Nothing happens but when I add the same code directly to the movieclip itself on the stage I have no problem. I was hoping someone could explain to me why this doesn't work when attaching it to a frame. Thanks

Kyle

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