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








Return From .onLoad Function Syntax HELP


syntax nightmare ...
I would like to load a XML file and onLoad have it return the text of a specific node to where the LOAD function was called from. I have it all worked out except for figuring out how to RETURN from a .onLoad function. Can I return from a .onLoad? See the code below. The mainXML.onLoad fires correctly, and the XML loads successfully. It does not correctly return the node value back the the function named "fLoadXML" however. It returns this:
"myVar: [type Function]"

That leads me to think that it is returning just this object "mainXML.onLoad" and not the value that is returned to it.

Code:
// define the main xml object
var mainXML:XML = new XML();
// functions that loads the XML data
function fLoadXML(file) {
mainXML.ignoreWhite = true;
mainXML.load(file);
//what to do when it loads
return mainXML.onLoad = function(success) {
if (success) {
trace(mainXML.firstChild.childNodes[0].childNodes[0]);
return mainXML.firstChild.childNodes[0].childNodes[0];
trace("XML Load Success");
} else {
trace("XML Load No Success");
return "Error";
}
};
//return myString;
//load the data
trace("load started");
}
var myVar = fLoadXML("data/xmlData.xml");
trace("myVar: "+myVar);
//


any ideas would be helpfull. I am trying desprately not to have to use any global variables anymore, and this would help me out on that front.

thanks

--mm




FlashKit > Flash Help > Flash ActionScript
Posted on: 04-27-2004, 05:11 PM


View Complete Forum Thread with Replies

Sponsored Links:

[as2]XML.onload = MyFunction - Return A Value From The Function?
Hi,

Im having a little trouble, i hope someone can help.
As an example i have :

ActionScript Code:
// Load the XML
body_xml = new XML();
body_xml.load("bodies.xml");
body_xml.ignoreWhite = true;
 
body_xml.onLoad = createbodyObjects;
function createbodyObjects (success) {
  if (success == true) {
    bodies = new Array();
    bodies[1] = new body();
    bodies[1].shape = "Im a body";
    }
 
}


After this runs, I can't reference the Array, in normal functions i could have called it using myArray = createbodyObjects(); and then returned the array, but I can't do this in this instance, I have tried making the function global etc.

Can anyone help??

Neil

View Replies !    View Related
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.

View Replies !    View Related
Return Value From Onload
I am new at as2 and haven't used as1 for years and am running into some problems. My first question is, is it possible to return a value from the onload function? I have tried but it seems to just return a bolean. Now I'm just trying to duplicate the onload function with a different name but that doesn't seem to work either.

the purpose is to load an xml document, extract the one address, and use that address in the flash movie to load a video.

here's what I have so far:
[hr]
var xmlLoc:String = "xml/video.xml";
// create the XML object
var videoLocXML:XML = new XML();
videoLocXML.ignoreWhite = true;

// create the event for when it laods content
videoLocXML.onLoad = function(success) {
if(success) {
var file:String = this.firstChild.childNodes[0].childNodes[0];
var dir:String = this.firstChild.childNodes[1].childNodes[0];
var loc:String = dir + "" + file;
trace("location = "+loc);
return(loc);
} else {
trace("there was a major error");
}
}

// the following ain't no string - it's a bolean...
// need to get onLoad to return 'loc' somehow
var _vidURL = videoLocXML.load(xmlLoc);
trace(_vidURL.value);
[hr]
it returns this -undefined
location = http://localhost/vidbb/flash/video/my_video_7.flv

does anyone have any ideas?

View Replies !    View Related
Can I Make XML.onLoad Return Something?
Hello

Im having problems with an XML's onLoad returning something in order to make other functions wait for an onLoad to execute first.



Code:
function function2() {
trace("function2 launched");
var xmlDock = new XML();
xmlDock.load("content.xml");
xmlDock.onLoad = function(success) {
if (success) {
trace("XML fetch success.");
return true;
}
};
}
function function1() {
trace("function1 launched");
if (function2()) {
trace("back in function1. do something else.");
}
}
// MAIN PROGRAM
function1();
stop();
As you can see in function1, I've made the call to function2 conditional in an if statement so that it will not execute the follwing commands until function2 has been processed. Now if I put return true; inside function2 directly, this works in that way. But I do not want for the commands to get invoked until the XML has been loaded. xmlDock.onLoad will happen independently whenever it is finished. I want for function1 to wait for that to happen.

Thanks a lot beforehand

Hoping that I've misunderstood something fundamental.

View Replies !    View Related
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

View Replies !    View Related
Simple Syntax Problem : Return False
I am trying to make a login which will re-direct to a sub-domain, no problems in javascript. However I need this login to be in swf format
This is what I have in flash :
<code>
on (press) {
submit_btn.onRelease = function() {
getURL("javascript:GoThere(txt.value);return false;", "_self", "POST");
};
}
</code>

This calls the javascript function in the 'head' of the html page. I get the error message:
error: 'return' statement outside of function

I presume it is just a simple syntax problem.

Thanks for any clues

RigorMortis

View Replies !    View Related
AS2: What Datatype Should A Function Return, If It May Not Return *anything*?
The title of this post may not make much sense, let me explain...

I have a function:

findSurface(origin:Point, vector:Point, attempts:Number):Point {...}

The function has an obscure use, but the idea is thus: given those three arguments, returns a point IF the 'line' (created by the origin and vector arguments) intersects the object the function is called on. [but that is another story...]

More importantly, if there is no point of intersection at all, what should the function return? Void? Null? Undefined? Object? Or can I use one of those return types instead of Point incase the function does not encounter an intersection?

I'd be glad to try explaining better if anyone might know, thanks.

View Replies !    View Related
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

View Replies !    View Related
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,

View Replies !    View Related
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

View Replies !    View Related
[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();

View Replies !    View Related
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.

View Replies !    View Related
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);
}

View Replies !    View Related
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

View Replies !    View Related
OnLoad Function
need sum help but dont know the correct way to code it..

i want to load an external swf onLoad of the movie.....into a emptymovieclip(my container).....

View Replies !    View Related
Mc.onLoad = Function
look at this code, what's wrong?
_parent.unit['bullet'+openbullet].onLoad = bulletload;
function bulletload() {
this.range = 5;
trace("LOAD");
}

my mc.enterfame works but this doesn't. I think it's because it's on load and for this to be implemented it has to be called after load so how do i use it? I tried to call it on the original but it didn't work.

View Replies !    View Related
XML OnLoad Function
Somebody knows how to include in a class the implementation of the onLoad function of the XML class. I have something like:

class theClass
{
private var output : XML;

private var input : String;

function theClass( )
{
output = new XML( );
output.onLoad = myOnLoad;
output.load( );
}

function myOnLoad
{
input = output.firstChild.childNodes[0].attributes.n;
}

}

BUT!! ... it doesn't work. Some ideas???

View Replies !    View Related
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

View Replies !    View Related
OnLoad Function
need sum help but dont know the correct way to code it..

i want to load an external swf onLoad of the movie.....into a emptymovieclip(my container).....

View Replies !    View Related
Mc.onLoad = Function
look at this code, what's wrong?
_parent.unit['bullet'+openbullet].onLoad = bulletload;
function bulletload() {
this.range = 5;
trace("LOAD");
}

my mc.enterfame works but this doesn't. I think it's because it's on load and for this to be implemented it has to be called after load so how do i use it? I tried to call it on the original but it didn't work.

View Replies !    View Related
This.onLoad = Function()
I put this code in the first frame of a movie clip and the output window
says: undefined, undefined,undefined,undefined....

this.onLoad = function() {
this.myFrustration = "big"
};
this.onEnterFrame = function() {
trace (this.myFrustration)
};

why?

View Replies !    View Related
Return Function Name (Function => String)
I keep coming across problems where it would be really convenient to get the name of a function in string format - like arguments.callee only a string instead of [Function, Function].

I haven't thought of a way to do this but in my head the keywords 'prototype' and 'override function' keep coming up - albeit that seems like a horrible horrible idea, but Function does extend Object so...thoughts?

View Replies !    View Related
Return From Function Called Within Function
How do I return the output from getTrialsHandler to getTrials when calling getTrials?

// THE CALL
trace( getTrials(1,16) );


// THE FUNCTIONS
function getTrials(day, userID){
var pc:PendingCall = service.getTrials(day, userID);
pc.responder = new RelayResponder(this, "getTrialsHandler", null);
}

function getTrialsHandler(re:ResultEvent, day){
if(!re.result){
trace("ERR: load trials for day"+day);
} else {
trace("SUC: load trials for day"+day);
if(re.result[1] > _root.currentDay){
goto = "closed";
} else if(re.result[0] < 5){
goto = "open";
} else if(re.result[0] == 5) {
goto = "full";
}
out = (re.result[0]+"::"+re.result[1]);
}
return out;
}

View Replies !    View Related
MyMovieClip.onLoad = Function () {
Can someone tell me if this is meant to work in this way
drop_down.dropContent.onLoad = function() {
trace("anything");
}
like in flash 5 you had
onClipEvent (load) {
trace("anything");
}
Am I loosing my mind or this is not working in my MX
I have used the
drop_down.dropContent.onEnterFrame = function() {
trace("anything");
};
and this works.

View Replies !    View Related
OnLoad Function Don't Work?
On the first frame of my timeline, i do

_root.InstanceName.onLoad = MoveUp;
// MoveUp is a function I created
it didn't work...

but when i do
_root.InstanceName.onRollOver = MoveUp;
it works

why is that...??
maybe, i am not so familiar with onLoad..but it's just a onClipEvent , why is it not workin'??

View Replies !    View Related
Having Problems With OnLoad Function
I have created one test fla file which has except the following code nothing else.When I run the fla file It is displaying only number "3" skipping "1" & "2". Can anybody tell what could be the problem. Thanks in advance.

_root.createEmptyMovieClip("tama1Holder",1);
_root[tama1Holder].onLoad = function(){
trace(1);
}
_root.createEmptyMovieClip("tama2Holder",2);
_root[tama2Holder].onLoad = function(){
trace(2);
}
_root.createEmptyMovieClip("tama3Holder",3);
_root[tama3Holder].onLoad = function(){
trace(3);
}

I have attached the file just in case if you need.

View Replies !    View Related
Content.onLoad = Function() ?
What is up with the new trend i'm noticing people saying things like
this.onLoad = function(); or that.onRollOver = function();

What are they exactly doing here? Just assigning a function which is definded after function() to the particular event instead of writing a function and naming it and later attaching to the event?

If so isn't that sloppy coding practice?

Jesse

View Replies !    View Related
Jpeg Onload Function?
Hey,
I'm loading a jpeg image into a blank mc, and I need to get some sort of notification when the jpeg is fully loaded.

With the LoadVars object, I can define an onLoad function, but I've been unable to figure out how to do the same thing with a movieclip. Does anyone have a sample of some code doing this?

I thought it might be something like this, but it doesn't appear to work:


Code:
myClip = new MovieClip;
myClip.onLoad = function() {
trace("clip loaded.");
}
myClip.load("myPicture.jpg");
The clip loads ok, but the onLoad function isn't called.

Thanks

View Replies !    View Related
Onload Function Call
I was experimenting with using PHP with Flash using the tutorial on the macromedia site. My code is as follows:


Code:
function showContent() {
var i;
for (i=0; i < this.n; i++) {
tbox1.text +="
|"+this["field2"+i]+"|"+this["field3"+i]+"
";
}
}

// Create new load vars object c for data transfer
var theVar = new LoadVars();
theVar.onLoad = showContent;

theone.onRelease=function(){
theVar.fone=1;
theVar.sendAndLoad("test.php",theVar,"GET");
};

thetwo.onRelease=function(){
theVar.fone=2;
theVar.sendAndLoad("test.php",theVar,"GET");
};



This works fine, but I don't get why the line
theVar.onLoad = showContent;
doesn't have brackets after the function call. I tried it with showContent() and showContent(theVar) and neither worked. Is just giving the function name some kind of specific type of call or something?
Thanks for any info!

-teezeCrost

View Replies !    View Related
OnLoad Function For External Jpg
hi
I've got a loop function that loads some external jpgs into dynamically-created clips.
I'd like to make it so that when the first jpg has loaded it uses an onLoad somehow to move the counter forward and then load the second jpg, and so on.

I've been trying with onLoad but i'm really not sure how it works - I've looked in the AS dictionary in Flash help but that's not much help either.

here's the code i use to create the empty clips and then load in the jpgs


PHP Code:




for (i=1; i<=_level0.numImages; i++) {
        _level0.imageLoaderMain.createEmptyMovieClip("holder"+i, i);
        _level0.imageLoaderMain["holder"+i]._visible = false;
        _level0.imageLoaderMain["holder"+i].createEmptyMovieClip("jpg",0);
}

function loadMainImages(img){
    loadMovie(_level0.baseFolder+"/"+img+".jpg", _level0.imageLoaderMain["holder"+img].jpg);
    _level0.vignetteLoaderMain.vignetteLoader["vigLoad" + img].gotoAndStop("loading");
}







how would i go about integrating an onLoad function here that would trigger another function to

i) increase the value of the variable 'img' if it isn't >=_level0.numImages
ii) send that 'img' variable back to loadMainImages() to load the next big image ?

thanks for any enlightenment you can give

View Replies !    View Related
OnLoad = Function Troubleshooting
First of all, inside Flash (using testmovie) this all works fine. But loading directly from the swf or projector exe, this doesn't work.

I've got the following code


Code:
myMusic = new Sound();
myMusic.loadSound("music.mp3");
myMusic.onLoad = function ()
{
myMusic.start();
}


From what I can tell the issue appears to be in the onLoad functionality. If I call myMusic.start(); seperately later on (for example with a button), it works fine. Also, if I enable streaming this, it works fine.

Any ideas?

Edit: This also seems to effect the myMusic.onID3 functionality.

View Replies !    View Related
OnLoad = Function() Problem
here is my code, it is in a frame on the same timeline and in the same frame as hslider mc.
I never see the trace.
so I guess the function never executes
this code seems to work for me in other movies. what could be up?
thanks mark

[code]
hslider.onLoad = function() {
trace("function executed");
//position knob at exact center of fader line
this._x=base._width/2 + base._x;
//calculate the x value of zero volume
//which is the x of the knob - half the width of the baseline
//as we positioned it at the center of the base line
volZero=this._x-(base._width/2);
//width of the base line mc is represents 0 to 100 volume
volRange = base._width;
//the x value of the slider - the x value of zero position
//divided by the total length of its movement
//multiplied by 100 gives you a range of numbers 0 to 100
//Math.floor, rounds the result down to an even number
VolValue = Math.floor(((this._x - volZero)/volRange)*100);
//display volume in textbox
_root.currentVolume = VolValue;
}

View Replies !    View Related
[F8] Calling A Function After .onLoad
Hi.
I'm trying to do a gallery, and call my MCs into my ScrollPane.
To know how many MC's I have to create in my ScrollPane, i go get some variables from an HTML. The HTMl content is actually :
&n=10
My probleme is there: i can't get my variable to go to the function.
I found something:
If i write
myVars.onLoad = showContent();
then my variable n is undefined
if i write
myVars.onLoad = showContent;
then it gets my variable, but won't do the attachMovie action.

Could someone explain me how to sort this?

Here is my full code.

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

function showContent () {
count = 0;
trace("myVars.n="+myVars.n);
while (count< myVars.n ) {

this.attachMovie("myThumb_mc", "myThumb_mc"+count, count);
// donne les attributs de myThumb_mc1
this["myThumb_mc"+count].myThumbLoader.loadMovie("galleire"+count+".jpg");
this["myThumb_mc"+count]._x = 5;
this["myThumb_mc"+count]._y = count*40;
this["myThumb_mc"+count]._xscale = 25;
this["myThumb_mc"+count]._yscale = 25;
this["myThumb_mc"+count]._alpha = 100;
this["myThumb_mc"+count].imageLink = count;

count += 1;
}
}

myVars = new LoadVars();
myVars.load("gallerie.html");
myVars.onLoad = showContent;


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


Thank you.

View Replies !    View Related
OnLoad Function Not Working...HELP
I've created a template interface with an empty movie clip for swf files to load when activated by their specific buttons. the interface animates until frame 20 when it is then static. This is the frame where I placed the empty movie clip on a new layer. On that same frame, I have indicated the Actionscript below. I can get the buttons to work but I can't get the initial page to load with the onLoad function.

The code I'm using is:

btn1.onRelease = function(){
loader_mc.loadMovie("about.swf");
}
btn2.onRelease = function(){
loader_mc.loadMovie("team.swf");
}
btn3.onRelease = function(){
loader_mc.loadMovie("clients.swf");
}
btn4.onRelease = function(){
loader_mc.loadMovie("folio.swf");
}
btn5.onRelease = function(){
loader_mc.loadMovie("kudos.swf");
}
btn6.onRelease = function(){
loader_mc.loadMovie("gofurther.swf");
}
btn7.onRelease = function(){
loader_mc.loadMovie("contact.swf");
}
onLoad = function(){
loader_mc.loadMovie("about.swf");
}

It all seems fine until I test the movie and "about.swf" will not initially load as its supposed to. I've uploaded the stuffed source files to http://www.clearlygreendesign.com/flash_help.html if anyone would like to have a look. I'm using Flash CS3 and AS 2.0.

Thanks!

View Replies !    View Related
[F8] External .as OnLoad Function Help
Hello everyone, I am having trouble getting an onLoad to work correctly.

I have a dynamic text box that I populate with a button on the stage. I am using an external .as file to tell everything what to to and how to do it.

My problem is, with this method I have to give the dynamic textbox both a var name and an instance name, otherwise my coding will not work. That spawns the problem that the dynamic text box is filled with the "Level0.mc.textbox" gibberish when the movie loads.

If I tell the textbox to display "" on load it won't work.

So far the only way I have found to do this is to place this on the parent MC (that holds the textbox)


Code:
onClipEvent(load){
this.dynamicTxt = "";
}


Where "this" is the parent MC and "dynamicTxt" is the var and instance name of the text box.

I am trying to find a way to put this in the .as file, but nothing I have tried works, including setting a function, or using relative and/or absolute pointers.

Anyone have any ideas?

~MoN

View Replies !    View Related
[CS3] OnLoad Visibility Function
Hey guys,

Basically I want to have a movie clip be invisible on load and then on rollover of a certain symbol the image will appear.
I have four symbols and when you rollover each one a different image will appear.

Trouble is, I can't find a way to make the images disappear when the frame loads.

I have tried:

on(enterFrame) {

_root.image1._visible = false;
}

and the same but with on(load).

This is really bugging me.

Please help

View Replies !    View Related
OnLoad=function Problems
Several times I've attempted to set the onLoad of a movie clip without success. I've heard the problem is that (when I set the onload in the frame) the onLoad time has already happened. I also heard that somewhere there was a tutorial on this site but I never could find it. Anyway here is my current code and If someone could tell me what to do with it I'd be grateful.


ActionScript Code:
dotOnLoad = function () {//onload stuff}dotOnFrame = function () {//onenterframe stuff}f1.onLoad = dotOnLoad;               // no '()' for onloads I thinkf1.onEnterFrame = dotOnFrame;


Hope you can help.

View Replies !    View Related
XML.onLoad And Other XML Function Questions
Goal: load XML data (it parses automatically), parse through the XML tree and assign the values to an array of my choosing for access later in the movie.

Problem: I can load the XML data, but the only time I can access the XML functions, i.e. XML.firstChild, or XML.getChildNodes(), is when I am within an XML.onLoad function.

Example:
--
var XMLdata:XML = new XML();
XMLdata.ignoreWhite=true;
XMLdata.onLoad = function() {
trace(XMLdata.firstChild); // returns the first child
}
XMLdata.load("scripts/mls_data.xml");

Shouldn't I be able to call these XML function and properties from anywhere? not just within the XML.onLoad function? I look at other people's scripts and they do it, but I can't?


I created a function that parses through the data and puts it into an array. And that works well if I say
XMLdata.onLoad = my_array_funtion();

But the problem is, if I do it that way I can't get the array out of the function. I can't return the value because the function is being called from an onLoad event and the return value of the function isn't assigned to a variable. So the array I create is worthless.

And there is no way to call the function, and have the XML.functions, i.e. XML.firstChild, to work outside of an XML.onLoad event. Is there? Please tell me there is a way.

In other attempts:
I tried assigning the array to a global variable, but evidently you can't modify _globals within a function.

Ultimately, I need this array because later in the script I use the data on the fly, and I want instant access to it.

Any ideas?

View Replies !    View Related
XML.onLoad And Other XML Function Questions
Goal: load XML data (it parses automatically), parse through the XML tree and assign the values to an array of my choosing for access later in the movie.

Problem: I can load the XML data, but the only time I can access the XML functions, i.e. XML.firstChild, or XML.getChildNodes(), is when I am within an XML.onLoad function.

Example:
--
var XMLdata:XML = new XML();
XMLdata.ignoreWhite=true;
XMLdata.onLoad = function() {
trace(XMLdata.firstChild); // returns the first child
}
XMLdata.load("scripts/mls_data.xml");

Shouldn't I be able to call these XML function and properties from anywhere? not just within the XML.onLoad function? I look at other people's scripts and they do it, but I can't?


I created a function that parses through the data and puts it into an array. And that works well if I say
XMLdata.onLoad = my_array_funtion();

But the problem is, if I do it that way I can't get the array out of the function. I can't return the value because the function is being called from an onLoad event and the return value of the function isn't assigned to a variable. So the array I create is worthless.

And there is no way to call the function, and have the XML.functions, i.e. XML.firstChild, to work outside of an XML.onLoad event. Is there? Please tell me there is a way.

In other attempts:
I tried assigning the array to a global variable, but evidently you can't modify _globals within a function.

Ultimately, I need this array because later in the script I use the data on the fly, and I want instant access to it.

Any ideas?

View Replies !    View Related
Can't Use Variable From Outside XML Onload Function
I am having trouble passing an array through a function, and then accessing the array from outside the function, here is my code:

ActionScript Code:
speechArray = new Array(); function loadXML(loaded) {      var arrayVar:Number = 0;      if (loaded) {           mainArray = new Array();           for (i=0; i<this.firstChild.childNodes[2].childNodes.length; i++) {                mainArray[i] = new Array();                for (j=0; j<this.firstChild.childNodes[2].childNodes[i].childNodes[0].childNodes.length; j++) {                     mainArray[i][j] = new Array(); for (k=0; k<this.firstChild.childNodes[2].childNodes[i].childNodes[0].childNodes[j].childNodes.length; k++) {mainArray[i][j][k] = new Speech(this.firstChild.childNodes[2].childNodes[i].childNodes[0].childNodes[j].childNodes[k].attributes.speaker, this.firstChild.childNodes[2].childNodes[i].childNodes[0].childNodes[j].childNodes[k].firstChild.nodeValue, i+1, j+1, {ra:100, rb:200, ga:100, gb:20, ba:100, bb:123, aa:100, ab:0}, 0, -100, 100, 200, 200);                          speechArray.splice(arrayVar, 0, mainArray[i][j][k]);                          arrayVar++;                     }                }           }      }      trace(speechArray[0].getspeaker()); } xmlData = new XML(); xmlData.ignoreWhite = true; xmlData.onLoad = loadXML; xmlData.load("roj-play.xml");




I can trace the Array from inside the loadXML function, but not outside it, which is what I want to do. I have read Senocular's XML specificIssues3 page, and tried the suggestions, but I am not sure which is the best one to use, and how exactly they apply to my specific problem. Any suggestions would be greatly appreciated.

Thanks!

View Replies !    View Related
Calling A Function Within A OnLoad
I'm trying to call a function with a onLoad function in a Class

Any reason why this doesn't work?

XML_var.onLoad = function(success) {
anotherFunction();
}

Thanks

View Replies !    View Related
OnLoad=function Problems
Several times I've attempted to set the onLoad of a movie clip without success. I've heard the problem is that (when I set the onload in the frame) the onLoad time has already happened. I also heard that somewhere there was a tutorial on this site but I never could find it. Anyway here is my current code and If someone could tell me what to do with it I'd be grateful.


ActionScript Code:
dotOnLoad = function () {//onload stuff}dotOnFrame = function () {//onenterframe stuff}f1.onLoad = dotOnLoad;               // no '()' for onloads I thinkf1.onEnterFrame = dotOnFrame;


Hope you can help.

View Replies !    View Related
XML.onLoad And Other XML Function Questions
Goal: load XML data (it parses automatically), parse through the XML tree and assign the values to an array of my choosing for access later in the movie.

Problem: I can load the XML data, but the only time I can access the XML functions, i.e. XML.firstChild, or XML.getChildNodes(), is when I am within an XML.onLoad function.

Example:
--
var XMLdata:XML = new XML();
XMLdata.ignoreWhite=true;
XMLdata.onLoad = function() {
trace(XMLdata.firstChild); // returns the first child
}
XMLdata.load("scripts/mls_data.xml");

Shouldn't I be able to call these XML function and properties from anywhere? not just within the XML.onLoad function? I look at other people's scripts and they do it, but I can't?


I created a function that parses through the data and puts it into an array. And that works well if I say
XMLdata.onLoad = my_array_funtion();

But the problem is, if I do it that way I can't get the array out of the function. I can't return the value because the function is being called from an onLoad event and the return value of the function isn't assigned to a variable. So the array I create is worthless.

And there is no way to call the function, and have the XML.functions, i.e. XML.firstChild, to work outside of an XML.onLoad event. Is there? Please tell me there is a way.

In other attempts:
I tried assigning the array to a global variable, but evidently you can't modify _globals within a function.

Ultimately, I need this array because later in the script I use the data on the fly, and I want instant access to it.

Any ideas?

View Replies !    View Related
Can't Get .onload Function To Work
here's my code

ActionScript Code:
Btest.loadMovie("images/photo1.jpg", 1);
Btest.onLoad = function() {
    trace("onLoad called");
};


Can anyone give any clues?

View Replies !    View Related
MyLoadVarsObj.onload(success) Function ?
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()

View Replies !    View Related
LoadableData.onLoad = Function(success){ ?
loadableData.onLoad = function(success){ DOESNT WORK???

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()

View Replies !    View Related
This.onLoad = Function() Vs. OnClipEvent(load)
I have tried this with varying results:

I have an MC -- I put the following code in frame 1:

this.onLoad = foo;
function foo() {
trace("foo");
}

...no output

then I try attcaching this code to the same MC

onClipEvent(load) {
trace("foo");
}

and I get foo in the output win?

what gives?

tx
brian

View Replies !    View Related
Want A Function To Fire Onetime Onload
onEnterFrame= function(){
statement
}

will fire over and over again.
How can i make a function fire one time when the page loads?

View Replies !    View Related
OnClipEvent(load) Or OnLoad=function()?
I was loading some jpegs into MC called "dropzone".

when I place directly on the "dropzone" this code:


Code:
onClipEvent (load) {
trace("loaded");
}
then it will trigger evrytime a new jpeg (or swf) is loaded into the dropzone.

but when I create a code:


Code:
_root.dropzone.onLoad = function (){
trace("loaded");
}
it will trigger only once when the flash is started, not when jpeg is loaded into the dropzone.

it's becase the code is "like inside" the dropzone and it will be erased when something is loaded there?

but how to do it then, when I wish to use the second declaration? (becaus I would have all code in one place, not located on any MC)

View Replies !    View Related
Call Function Outside Of A MCL Listener.onload
i have a movie clip loader object set up and want to call a function from a movieclip out side of the MCL see code below:

to call it normally just startloading(); would do it right? but if it is in a listener.onloadProgress can it be done?




Code:
var myMCL:MovieClipLoader = new MovieClipLoader();
var myListener:Object = new Object();
myMCL.addListener(myListener);

myListener.onLoadProgress = function(target_mc:MovieClip, loadedBytes:Number, totalBytes:Number) {
preload_mc.play(); // play the animation here

// this is the function i want to call from the preload_mc when it reaches a frame.
function startloading(){
trace("startloading called");
}
}
}

View Replies !    View Related
Avoiding 'onLoad=[type Function]'
Hi,

I have a dynamic text box that retrieves text from a PHP file that in turn retrieves text from a mySQL database. Sometimes the PHP file may necessarily display no text if the mySQL database is empty. However, when the dynamic text box in Flash tries to retrieve text from an empty PHP file the dynamic text box displays onLoad=[type Function]. Is there a way of making the dynamic text box display nothing in such circumstances?

I have attached the actionscript the dynamic text box uses to retrieve its text and also the PHP code used to retrieve text from the mySQL database.

Many, many thanks,

leao

Actionscript
code: path = "http://www.stpatrickscommunity.org/admin/text/landline.php";
lv = new LoadVars();
lv.onLoad = function(){
str = unescape(this);
str = str.split("=&onLoad=[type Function]").join("");
landline.html = true;
landline.htmlText = str;
};
lv.load(path);

PHP

PHP Code:



<?php
header('Content-type: text/html; charset=utf-8');
mysql_connect("mysql.myhosting.com","stpatri_user","password") or die(mysql_error());
mysql_select_db("stpatri_table") or die(mysql_error());
$result = mysql_query("SELECT * FROM text")
or die(mysql_error());  
$row = mysql_fetch_array( $result );
$str_encoded=urlencode($row['landline']);
echo "$str_encoded";
?>

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