OnLoad Events...
I know this question has been asked about 10000 times, but about onload events, they are usually asynchronous.
I like alot of people are still baffled by how to make use of these onLoad events properly. Can anyone post an example of containing an XML parser within a class, then show an example of how to tell when its loaded.
I know how to load XML and get the data into other classes with it, but im baffled on how im supposed to know when its loaded, as i pretty much need to wait until all my onLoad events are complete, and i dont know how to do it.
I tried putting in booleans to signify when the class had loaded, but when i did a while() loop to see when the booleans were set to true it just locks up, which is fair enough...
So what is the CORRECT way to check when something is loaded, and when i say check if its loaded i mean an external function from a class that can tell other classes when its loaded and when to carry on doing events based off the external data loaded...
ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 07-25-2006, 10:40 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
OnLoad Events.
Hi Again
I fixed all the problems, but now I found another one.
How can I call the following events when my flash is opened ?
Code:
var ends:Number=(currentFrame);
fmcontroller.btn_pp.btn_play.visible = false
fmcontroller.btn_prev.gotoAndStop(2);
fmcontroller.btn_next.gotoAndStop(1);
stop();
I just added these 5 lines at the beginning of my script and it works in most browsers. But some browsers " For example camino in MAC" ignore the whole thing. Do I have to create an evenhandler or a onload or something ?
Thanx.
Martin
Dynamic OnLoad Events
My goal is to dynamically create MCs and then attach the onLoad clipevent to them. Here is an example of how I'm attempting to do this:
foo = _root.createEmptyMovieClip("bar",1);
foo.onLoad = function(){
trace(this);
}
This isn't working when other clipEvents work (onEnterFrame works fine). Any feedback or pointers to resources is appreciated.
Odd Thing Happens With Onload Events
As I was advised in another thread, I have to check onload events in my clip. I tried to...and I get something a little weird (I know those weird things are due to my programming, but the problem is I don't know where)
I have 4 movieClips (clip1 to clip4), images are loaded in each one, with delay between each loading.
1st : I get a blinking on already loaded image while another one is just displaying
2nd : I tried to check onload events with :
ActionScript Code:
clip1.onLoad = function () {
trace ("clip1 loaded");
};
As I got no results ; I tried to check the event with the other way :
onClipEvent(load){
trace("clip1 loaded");
}
Then it worked, but I don't know why It hadn't worked with the first method
3rd :
It worked...ok , but each time an image is loaded in an other movieClip (clip2 to clip4) , I get "clip1 loaded"...I don't understand !
Thanks
OnData And OnLoad Events
FLASH MX 2004 Professional
I'm having some problems with the onData event handler:
I have a movieclip called symbol_mc in the _root. In the first frame I use the following code:
symbol_mc.loadMovie("anim.swf");
and if I write the following code in the symbol_mc MovieClip everything works fine:
onClipEvent(data){
trace("movie has been loaded");
}
Now I need to use this code:
symbol_mc.onData=function(){
trace("movie has been loaded");
};
symbol_mc.loadMovie("anim.swf");
instead of the previous code, but it is not working. I went to the flash panel and I found the same example, but it says the following:
"This handler can be used only with movie clips for which you have a symbol in the library that is associated with a class."
But I tried everything, i used a linkage name, I associated the movieclip with the MovieClip Class, I associated the class with a Custom class I created that extents the MovieClip class but non of this works, please help.
The same happens with the onLoad event.
Register Classes - Mc Events Vs Button Events
I'm experimenting with register classes today, and wasn't careful typing the code with only button events for my custom movie clip class.
First I wrote
Code:
CustomClass.prototype.onMouseDown = function(){
this.gotoAndStop("blue");
}// end onMouseDown
Then all the mc-buttons in my movie went to the blue state. (.fla provided)
When I realised the error, I corrected it, and now it works.
I just don't understand what happened.
Do Movie Clip events turn out to be class methods (don't know what to call it in Java script, only used to Java), while button events stay instance events??
Hope somebody have the time - it's not about life and death, but it would be really nice to know how these things work.
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.
Respond To Mouse Events Inside A Movieclip That Has Mouse Events...
I have a main MC that has a couple of mouse events associated with it (onPress mainly). There are also MC's inside this main MC that have Mouse events associated to them (onPress, onMouseMove, onRelease). The child MCs don't seem to get the mouse events (which makes sense, the parent is taking over the event)...how can I make this work? I don't want to have to delete and recreate the event handlers like 900 times as its not efficient...there has to be a better way.
Can Events Trigger Other Events?
Hello brothers and sisters of the Nets most helpful community!
I am going insane in the membrane trying to get my custom cursor to work in my scene. I have successfully completed many tutorials about how to do this in AS3 (the danielmclaren.net solution was particularly helpful) and have scoured this forum a bit for info, and (gasp) also read through a bunch of stuff on live docs. But, alas, I cannot understand why I cannot get the custom mouse (cursor) to work in my file. It works like a charm until I try hammering it into my scene.
I believe that the problem has something to do with with too many events being fired off at the same time and (possibly) my not removing them at opportune times. Or, maybe my coding style is not so elegant? Anyway, the FLA (with easy-to-read structure and commenting) can be downloaded here since I am not certain which part of my code is causing the custom cursor not to work. With all the comments, it should not be too difficult (I hope) to see what it is I am trying to do.
Any feedback would, as always, be most appreciated.
Download_FLA
Regards,
-john
OnLoad Help
I'm having problems pausing the execution of code until my onLoad function is finished.
test = new XML();
test.onLoad = onTest;
test.load("auction.xml");
//i want it to pause here until the onLoad is complete.
print(x)
function onTest(){
//bunch of stuff ...
x = something;
}
If anybody can think of an easy, clean solution. That'd be great. Thanks,
Lloyd
OnLoad In Mx
hi
i'm just getting my head round the mx actionscript style - can't see why this code isn't working
if (total>0) {
pageNum++;
var pageName = "holder"+pageNum;
createEmptyMovieClip(pageName, 1);
var tag = eval("holder"+pageNum);
tag.onLoad = function() {
trace("onLoad is working");
};
tag.onEnterFrame = function() {
this._x++;
};
}
the onEnterFrame works fine... but onLoad does not
it's probably something obvious but i just can't see it
thanks for your help
XML.ONLOAD
I've some problems with Xml.OnLoad sentence.
When I use function without parameters I do:
XMLPrincipal=new XML();
XMLPrincipal.ignoreWhite=1;
XMLPrincipal.load(fitxerXML);
XMLPrincipal.onLoad=InicialitzarED ;
and this executes correctly...
But, I've added a parameter to InicialitzarED function...and when I do:
param1="A";
XMLPrincipal=new XML();
XMLPrincipal.ignoreWhite=1;
XMLPrincipal.load(fitxerXML);
XMLPrincipal.onLoad=InicialitzarED (param1) ;
it's executed InicialitarED(param1) just in moment that I assign to XMLPrincipal.onLoad !! And no waits for the xml...
Somebody can help me ??
THANK'S!!
B
Re-using OnLoad
I have loaded a php script through the code below then I am trying to re-use it to reload a different php script through it to load more variables. The problem comes with trying to put the new information through onload. It doesn't go through only the old information stays. I thought that if the varLoader was set to null it delete any info in it.
Code:
this.varLoader=null
this.varLoader = new LoadVars();
if (this.stopCache == true) {
this.varLoader.load(this.phpDirInfoPath+"?=noCache"+getTime());
} else {
this.varLoader.load(this.phpDirInfoPath);
}
var cB = this;
this.varLoader.onLoad = function() {
var phpString = cB.varLoader.files;
_root.crap="poo"+this.phpVarIncrease
.....>>>>> the code continues
Thought just occured do i have to unload the this.varLoader variable to get it to function to onLoad again?
OOP And XML.onLoad
I'm trying to develop an understanding of OOP in Flash, and have encountered a problem with accessing an object's parameters from within an object method called using "onLoad". Here is an example that works, only I wish to make the hard-coded reference in processQuizXML() relative, like "this.question01 = ...", only I understand that "this" won't refer to objMyQuestion, but rather the XML object. I don't know of any "_parent" expression that would work with code instead of movieclips. Any ideas on how to rewrite the line preceding the trace() so it will change objMyQuestion.question01 without naming it explicitly?
Code:
DataContainer = function() {
this.question01;
this.question02;
// etc.
}
DataContainer.prototype.loadXML = function(){
quizXML = new XML();
quizXML.ignoreWhite=true;
quizXML.onLoad = this.processQuizXML;
quizXML.load("quiz.xml");
}
DataContainer.prototype.processQuizXML = function(){
// here's the hard-coded reference
objMyQuestion.question01 = this.firstChild.firstChild.nodeValue;
trace(objMyQuestion.question01);
}
objMyQuestion = new DataContainer();
objMyQuestion.loadXML();
The "quiz.xml" it refers to is simply this:
Code:
<?xml version="1.0" encoding="iso-8859-1" ?>
<ques>Have you ever heard the story about the dog and the dancing monkeys?</ques>
OnLoad Help
Hi,
I have a start.swf file. It contains just one mc, the "placeholder.mc". What I would like to do is: when the "placeholder_mc" is loaded it should automatically load the next swf movie to the level 1.
This is my AS:
placeholder_mc.onLoad = function()
{
loadMovieNum("engint.swf", 1);
};
This small movie just loops, but does not load engint.swf.
What is wrong?
Thanks,
B.
How Do We Use OnLoad?
I want to use movieClip.onLoad to detect if an external swf is loaded into a movie clip or not. That was what I did:
I put an empty movie clip on stage, named "container", in the first frame of the movie clip, I put this script:
this.onLoad = function() {
trace("A");
}
And there is a button, i put this script:
on (release) {
loadMovie("test2.swf", "_root.container");
}
Now the movie is loaded, but there is no trace output. Anything wrong with my script?
OnLoad<whatever>
i'm loading several images from an array and are creating a different loader and listener for each image within a for-loop.
Problem is that is only the last loaded image kicks in any of the onload-functions...hope anyone can clarify matters..code looks something like this
when i look in the debugger all the listeners are being created, but only when the last image loads are any of the onload-functions activated
function loadImages(imageName, nr){
var clip = new Array(nr);
for(var i=1; i<nr+1; i++){
clip[i] = _root.createEmptyMovieClip(mcName+i, 5000+i);
imgLoad[i] = new MovieClipLoader();
loadListen[i] = new Object();
loadListen[i].onLoadError= function(){
//some code
}
loadListen[i].onLoadInit = function(clip) {
//some code
}
loadListen[i].onLoadProgress = function(clip, bytesLoaded, bytesTotal){
//some code
}
loadListen[i].onLoadComplete = function (){
//some code
}
imgLoad[i].addListener(loadListen[i]);
imgLoad[i].loadClip(imageName[i], clip[i]);
}
}
OnLoad ?
Hey all,
i searched for this and the first 10 replies yeilded no real answer.
Ok why does this work
mc.onEnterFrame = function (){
trace ("hi");
}
but this dont
mc.onLoad = function (){
trace ("hi");
}
I have always used onClipEvent (load) to set stuff, but im trying new stuff from the main timeline and i need to initialize speed etc but i cant.
Why is that?
OnLoad Help
Hello
I am working on a gallery and am building this in Flash 8.
I have a simple thumbnail functionality, and basically I want the first image in my sequence to appear when the page loads.
Can anyone help me out?
At the moment whilst I am querying this I only have 5 large pics and 5 thumbs. I want the first pic to be there on load as well as the applyBorder function to the relevant thumb. But I am aware this is not a movieclip.
In this gallery I also have next and previous buttons which you will see from my code. So once this first image has loaded and the thumb is highlighted by its border, i want to be able to click the next button to scroll thru the thumbs. Cos at the moment when the page loads you need to click on a thumb to start the whole process. I want both options available to the user onload (the previous button will not be visible of course on load as you can go back when at the start of the gallery).
The code is below:
_global.imgIndex = null;
_global.numImages = 5;
//
prevBtn.onRelease = function(){
if (_global.imgIndex > 1){
_global.imgIndex--;
}
applyBorder();
getImage();
}
//
nextBtn.onRelease = function(){
if (_global.imgIndex < _global.numImages){
_global.imgIndex++;
}
applyBorder();
getImage();
}
//
thumbWin.thumb1.onRelease = function(){
resetImgWin();
_global.imgIndex = 1;
applyBorder();
getImage();
}
//
thumbWin.thumb2.onRelease = function(){
resetImgWin();
_global.imgIndex = 2;
applyBorder();
getImage();
}
//
thumbWin.thumb3.onRelease = function(){
resetImgWin();
_global.imgIndex = 3;
applyBorder();
getImage();
}
//
thumbWin.thumb4.onRelease = function(){
resetImgWin();
_global.imgIndex = 4;
applyBorder();
getImage();
}
//
thumbWin.thumb5.onRelease = function(){
resetImgWin();
_global.imgIndex = 5;
applyBorder();
getImage();
}
//
function resetImgWin() {
for(var i = 1; i < _global.numImages; i++){
var img = imgWin['image'+ i];
img.removeMovieClip();
}
}
//
function applyBorder(){
for(var i = 1; i < _global.numImages + 1; i++){
thumbWin[ "thumb" + i ].thumbimageBorder.removeMovieClip();
}
thumbWin[ "thumb" + _global.imgIndex ].attachMovie('thumbimageBorder', 'thumbimageBorder', this.getNextHighestDepth());
}
//
function getImage() {
resetImgWin();
imgWin.attachMovie('image'+_global.imgIndex, 'image'+_global.imgIndex, 5);
}
Onload Help
Hey Everybody,
I have a webpage that is slow loading. On the page there is a Flash Movie. It is a very simple fade in on a picture.
What I need help with is what are and where to put the onload commands.
Here is the code for the Flash.
<BODY BGCOLOR="white" style="margin:0 0 1px 0; height:100%">
<TABLE width="987" border="0" CELLPADDING="0" CELLSPACING="0" align="center">
<tr>
<td>
<DIV ID="CTRDIV" style="position:absolute; padding: 0px; height:100%; width: 987px">
<DIV ID="SWFOBJ7D8301E112503E2" STYLE=" position:absolute; top:397px; left:23px; width:486px; height:567px; z-index:0;">
<object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000"codebase="http://active.macromedia.com/flash4/cabs/swflash.cab#version=4,0,0,0"id="Contact US.swf" width="486" height="567">
<param name="movie" value="_RefFiles/Contact US.swf">
<param name="quality" value="best">
<param name="loop" value="false">
<param name="wmode" value="transparent">
<embed name="Contact US" src="_RefFiles/Contact US.swf" quality="best" loop="false" wmode="transparent" width="486" height="567" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">
</embed>
</object>
I hope someone can help!!
Thanks
Help With OnLoad
First of all, hello everyone! Been lurking these forums for the past month or so, but this is my first post.
I have been trying to load a text (and unformatted HTML in raw format) file into a textbox. I am using the following code:
Code:
textData_lv = new LoadVars ();
textData_lv.o = this;
textData_lv.onData = function (rawData) {
trace(rawData);
this.o.display_txt.text = "Data is: " + rawData +" END DATA";
}
display_txt.htmlText = "<b>Loading...</b>";
textData_lv.load ("http://www.google.com");
When I go to File->Publish Preview->Flash or if I publish the swf and run it from my desktop, it works fine, and the output is:
Data is: <html><head><meta http-equiv="content-type" content="text/html; charset=ISO-8859- AND SO ON
However, if I upload this swf onto the web, or if I go to File->Publish Preview->HTML, all I get in my text box is:
Data is: END DATA
as if the page didnt even load! Does anyone know what the problem could be? Is it a crossdomain issue? Thanks!
XML -- Onload?
Hey, I am using the it it.sephiroth.XML2Object to get data from an xml page. Is there a way to have my actionscript do something once all the xml is loaded. Kinda like xml.onLoad or something? Thanks, Dvl
OnLoad Help
Hello
I am working on a simple gallery and am building this in Flash 8.
I have a simple thumbnail functionality, and basically I want the first image in my sequence to appear when the page loads.
Can anyone help me out?
At the moment whilst I am querying this I only have 5 large pics and 5 thumbs. I want the first pic to be there on load as well as the applyBorder function to the relevant thumb. But I am aware this is not a movieclip.
In this gallery I also have next and previous buttons which you will see from my code. So once this first image has loaded and the thumb is highlighted by its border, i want to be able to click the next button to scroll thru the thumbs. Cos at the moment when the page loads you need to click on a thumb to start the whole process. I want both options available to the user onload (the previous button will not be visible of course on load as you can go back when at the start of the gallery).
The code is below:
_global.imgIndex = null;
_global.numImages = 5;
//
prevBtn.onRelease = function(){
if (_global.imgIndex > 1){
_global.imgIndex--;
}
applyBorder();
getImage();
}
//
nextBtn.onRelease = function(){
if (_global.imgIndex < _global.numImages){
_global.imgIndex++;
}
applyBorder();
getImage();
}
//
thumbWin.thumb1.onRelease = function(){
resetImgWin();
_global.imgIndex = 1;
applyBorder();
getImage();
}
//
thumbWin.thumb2.onRelease = function(){
resetImgWin();
_global.imgIndex = 2;
applyBorder();
getImage();
}
//
thumbWin.thumb3.onRelease = function(){
resetImgWin();
_global.imgIndex = 3;
applyBorder();
getImage();
}
//
thumbWin.thumb4.onRelease = function(){
resetImgWin();
_global.imgIndex = 4;
applyBorder();
getImage();
}
//
thumbWin.thumb5.onRelease = function(){
resetImgWin();
_global.imgIndex = 5;
applyBorder();
getImage();
}
//
function resetImgWin() {
for(var i = 1; i < _global.numImages; i++){
var img = imgWin['image'+ i];
img.removeMovieClip();
}
}
//
function applyBorder(){
for(var i = 1; i < _global.numImages + 1; i++){
thumbWin[ "thumb" + i ].thumbimageBorder.removeMovieClip();
}
thumbWin[ "thumb" + _global.imgIndex ].attachMovie('thumbimageBorder', 'thumbimageBorder', this.getNextHighestDepth());
}
//
function getImage() {
resetImgWin();
imgWin.attachMovie('image'+_global.imgIndex, 'image'+_global.imgIndex, 5);
}
This.onLoad
hi guys,
i managed to do,
ActionScript Code:
mc.onEnterFrame = function () {
//blah blah blah
}
but now i need to do it for onLoad...
i tried
ActionScript Code:
mc.onLoad = function () {
//fsjdf
}
but no luck
OnLoad :(
oh this is annoying, I know the problem... i think :s
basically when the flash movie recieves a value it runs a function that contacts mysql to pull off some values.
The problem being is that the code sends a request to mysql and continues the function and then ends the function before mysql can respond and therefore the,
ActionScript Code:
loadObj.onLoad = function (success) {
}
simply cannot respond.
now I tried putting just the onLoad function into root, so it could pickup the response at any time but it seems whenever it tries to call this function the current url changes and goes to th
PHP Code:
e phpscript.php?user=til
and php says it failed, which it shouldnt.
I maybe wrong but its the only thing I can spot, but the most annoying thing is how do i solve it?
Xml.onLoad = // Please Help
Hi all,
please help this function.
ActionScript Code:
my_xml.onLoad = function (success)
{
If (success)
{
parseXML; // this function not same frame, how to call this function?
}
}
// this function not same frame
function parseXML ()
{}
Thank You ALL
Help With OnLoad
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 thetween 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 thetween continuously. I need it to play oncethe frame loads and only once. I tried using the movieclip.onLoad function but it's not working for me. What am I doing wrong? Here is the code that I'm using...
Attach 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();
Using Onload And XML
Hi, I have a project where I load XML, SWF and image files into my MAIN.swf. This makes my project dynamic and easy to work with, but it only works now and again and is NOT consistant. If it fails I don't get an error even though I've put some error reporters in and it only takes a Ctrl shift refresh to work!!!
The other point I must make is that the MAIN.swf is duplicated in different folders picking up the correct stuff that is relative to it. When I test each individual MAIN.swf I have to refresh to get the right imformation! again it only takes a refresh to work.
I'm not a AS guru but have got experience in other coding lanuages. I'm lost here, please help if you can.
Thanks in advance.
Simon.
OnLoad?
hello -
ive managed to create a loop that loads some xml and images,
but im struggling with creating an 'onLoad' type event for this line of code --- R1item.image_holder.loadMovie(R2photoURL[j]);
so when then the R2photoURL[j] is finally loaded an event will occur.
could someone point me in the right direction
what should i be using?
thanks,
anton.
Attach Code
var butterList:XML = new XML();
butterList.ignoreWhite = true;
var R1photoURL:Array = new Array();
var R1caption1:Array = new Array();
var R1caption2:Array = new Array();
var R2photoURL:Array = new Array();
var R2caption1:Array = new Array();
var R2caption2:Array = new Array();
butterList.onLoad = function(success) {
trace ("it worked!")
_global.R1 = this.firstChild.firstChild.childNodes
for (i=0; i < R1.length; i++) {
R1photoURL.push (R1[i].attributes.URL);
R1caption1.push (R1[i].attributes.caption1);
R1caption2.push (R1[i].attributes.caption2);
}
_global.R2 = this.firstChild.firstChild.nextSibling.childNodes
for (i=0; i < R2.length; i++) {
R2photoURL.push (R2[i].attributes.URL);
R2caption1.push (R2[i].attributes.caption1);
R2caption2.push (R2[i].attributes.caption2);
}
trace (R2.length)
j = 0;
while (j < R2.length)
{
trace (R2caption2[j])
R1item = _root.contentSpace.row1.attachMovie ("row1_holder","row1_holder" + j, j + 88);
R1item.caption2.text = R2caption2[j];
R1item.image_holder.loadMovie(R2photoURL[j]);
R1item._y = R1item._y + j * 495;
++j;
};
}
butterList.load("http://www.antonnazarko.com/butter/butter.xml");
Just Need A Little Help With OnLoad
Okay everything is works fine nothing problem ...send value,save value in dtbase...only my problem ..(maybe not a big problem)...how to echo from php so that user know sometimes their process saving dt into dtbase are not working...because currently..it will show in flash the saving process are success eventhough it's fail...so actually the process in php page I think..because in flash everything is okay...so I really need help on that..or some guide would be great...
PHP Code:
<?
$dbhost = "localhost";
$dbusername = "root";
$dbpassword = "";
$dbname = "ecard";
$db = mysql_connect($dbhost, $dbusername, $dbpassword);
mysql_select_db($dbname, $db) or die("ERROR: Cannot connect to the database");
if (!get_magic_quotes_gpc()) {
foreach($_POST as $key=>$value) {
$temp = addslashes($value);
$_POST[$key] = $temp;
}
}
$query = 'INSERT INTO customizecard (customization,username,whattime)
VALUES ("'.$_POST['userediting'].'","'.$_POST['usr_name'].'",now())';
$proceedSQL = mysql_query($query) or die(mysql_error());
//for success saving process it 's okay and show ok in flash..
//the problem is for failing process is still show success it's okay eventhough I put the else in php...
if(success==true){
$somemessage = 'your data has been save into database';
echo '&message='.urlencode( $somemessage );
}
//else{
// $somemessage = 'problem occure';
// echo '&message='.urlencode( $somemessage );
//}
?>
and this is as in flash..
ActionScript Code:
var receiveVars:LoadVars = new LoadVars();receiveVars.onLoad = loadstatus;function loadstatus(success:Boolean){ if(success){//for success it's okay only for fail process can get status from php info.text = this.message; }else{ info.text = "this.message"; }}
anyhelp would be appreciated...
tq again...
Help With XML.onLoad()
I've been wrestling with this for approximately 8 hours now with no luck.
I have an XML object, which, after being loaded with an external XML file, I would like to traverse through and place values from the XML file into an array. When the traversing is complete I need to fire an event so that the rest of the program can continue.
The problem is that the onLoad seems to be firing before the XML file is actually loaded. I've worked up some sample code that demonstrates what is happening.
XMLReaderTest class
Code:
import mx.events.EventDispatcher
class XMLReaderTest {
private var myArray:Array;
private var xmlObj:XML;
function XMLReaderTest() {
this.xmlObj = new XML();
this.xmlObj.ignoreWhite = true;
this.myArray = new Array();
mx.events.EventDispatcher.initialize(this);
}
function dispatchEvent() {};
function addEventListener() {};
function removeEventListener() {};
function readXML(xmlFile:String):Void{
this.xmlObj.onLoad = loadArray();
this.xmlObj.load(xmlFile);
}
function loadArray(){
var eventObject:Object = {target:this, type:'arrayLoaded'};
var temp = new Array();
temp = this.xmlObj.childNodes[0].childNodes;
//remove any disabled items
for (var p = 0; p<temp.length; ++p) {
if (temp[p].attributes["enabled"].toString() == "false") {
temp.splice(p, 1);
}
}
//add to array
for(var i=0; i<temp.length; i++){
var myVal = temp[i].childNodes[0].firstChild.nodeValue.toString();
this.myArray.push(myVal);
}
dispatchEvent(eventObject);
}
}
Main Timeline:
Code:
var myXMLReader = new XMLReaderTest();
var myListnerObj:Object = new Object;
myListnerObj.arrayLoaded = function(evtObj) {
trace("The array is loaded.");
}
myXMLReader.addEventListener("arrayLoaded",myListnerObj);
myXMLReader.readXML("mytest.xml");
and the XML file (myTest.xml):
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<myTest>
<anItem>
<value>1</value>
</anItem>
<anItem>
<value>3</value>
</anItem>
<anItem>
<value>2</value>
</anItem>
</myTest>
Does anyone have any idea why this is happening, or how I can fix it? I really appreciate all the help I can get.
Thanks,
adam
OnLoad Help
Hi,
I have a start.swf file. It contains just one mc, the "placeholder.mc". What I would like to do is: when the "placeholder_mc" is loaded it should automatically load the next swf movie to the level 1.
This is my AS:
placeholder_mc.onLoad = function()
{
loadMovieNum("engint.swf", 1);
};
This small movie just loops, but does not load engint.swf.
What is wrong?
Thanks,
B.
Help With XML.onLoad() In AS2
I've been wrestling with this for approximately 8 hours now with no luck.
I have an XML object, which, after being loaded with an external XML file, I would like to traverse through and place values from the XML file into an array. When the traversing is complete I need to fire an event so that the rest of the program can continue.
The problem is that the onLoad seems to be firing before the XML file is actually loaded. I've worked up some sample code that demonstrates what is happening.
XMLReaderTest class
Code:
import mx.events.EventDispatcher
class XMLReaderTest {
private var myArray:Array;
private var xmlObj:XML;
function XMLReaderTest() {
this.xmlObj = new XML();
this.xmlObj.ignoreWhite = true;
this.myArray = new Array();
mx.events.EventDispatcher.initialize(this);
}
function dispatchEvent() {};
function addEventListener() {};
function removeEventListener() {};
function readXML(xmlFile:String):Void{
this.xmlObj.onLoad = loadArray();
this.xmlObj.load(xmlFile);
}
function loadArray(){
var eventObject:Object = {target:this, type:'arrayLoaded'};
var temp = new Array();
temp = this.xmlObj.childNodes[0].childNodes;
//remove any disabled items
for (var p = 0; p<temp.length; ++p) {
if (temp[p].attributes["enabled"].toString() == "false") {
temp.splice(p, 1);
}
}
//add to array
for(var i=0; i<temp.length; i++){
var myVal = temp[i].childNodes[0].firstChild.nodeValue.toString();
this.myArray.push(myVal);
}
dispatchEvent(eventObject);
}
}
Main Timeline:
Code:
var myXMLReader = new XMLReaderTest();
var myListnerObj:Object = new Object;
myListnerObj.arrayLoaded = function(evtObj) {
trace("The array is loaded.");
}
myXMLReader.addEventListener("arrayLoaded",myListnerObj);
myXMLReader.readXML("mytest.xml");
and the XML file (myTest.xml):
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<myTest>
<anItem>
<value>1</value>
</anItem>
<anItem>
<value>3</value>
</anItem>
<anItem>
<value>2</value>
</anItem>
</myTest>
Does anyone have any idea why this is happening, or how I can fix it? I really appreciate all the help I can get.
Thanks,
adam
OnLoad
Can anyone tell me if the following will work. I dont have access to a dialup connection at the moment (aaah) so its hard to test.
loadit = loadMovie("no1.swf", "myclip");
loadit.onLoad(moveon());
function moveon() {
gotoAndPlay(2);
}
also will it work for images as well as movie clips i.e.
loadit = loadMovie("no1.jpg", "myclip");
thanks.
OnLoad
my MovieClip.onLoad function only works on _root and only happens ounce
how can i fix that
OOP And XML.onLoad
I'm trying to develop an understanding of OOP in Flash, and have encountered a problem with accessing an object's parameters from within an object method called using "onLoad". Here is an example that works, only I wish to make the hard-coded reference in processQuizXML() relative, like "this.question01 = ...", only I understand that "this" won't refer to objMyQuestion, but rather the XML object. I don't know of any "_parent" expression that would work with code instead of movieclips. Any ideas on how to rewrite the line preceding the trace() so it will change objMyQuestion.question01 without naming it explicitly?
ActionScript Code:
DataContainer = function() {
this.question01;
this.question02;
// etc.
}
DataContainer.prototype.loadXML = function(){
quizXML = new XML();
quizXML.ignoreWhite=true;
quizXML.onLoad = this.processQuizXML;
quizXML.load("quiz.xml");
}
DataContainer.prototype.processQuizXML = function(){
// here's the hard-coded reference
objMyQuestion.question01 = this.firstChild.firstChild.nodeValue;
trace(objMyQuestion.question01);
}
objMyQuestion = new DataContainer();
objMyQuestion.loadXML();
The "quiz.xml" it refers to is simply this:
Code:
<?xml version="1.0" encoding="iso-8859-1" ?>
<ques>Have you ever heard the story about the dog and the dancing monkeys?</ques>
Onload Url
Im trying to create it so that on load of my movie a popup window will open to a location i specify... ive tried using onLoad and GetURL, but im not a flash expert, could anyone help me or tell me how i do this?
Onload Scroller To Go Way Down
help!!!!!!!!!!!
Heres the thing I made a flash and php application and I need the scroller to go way down when it loads so the user will see the last message posted if you know of anybody that can help me please let me know here's the link to the page.
http://ion5.sixthlight.com
Thank You
Onload Problem
Hi chaps this is really pissing me off now,
I have this code (below which basically tells different things in a MC to start) trouble is it doesnt work. If i change the onClipEvent (load) to onClipEvent (mousemove) then it works fine, but it will just not work using enter frame!
whats even worse is that it actually stops the MC from being displayed!
All of the targets are inside the MC which i am using these actions with...
any ideas?
Code:
onClipEvent (load) {
tellTarget ("_root.sound.eq.load") {
gotoAndPlay ("play");
}
tellTarget ("_root.sound.eq") {
gotoAndPlay ("eqstart");
}
_root.sound.eq:status = "play";
gotoAndStop ("on");
tellTarget ("_root.sound.scroll") {
playing = "Darren Round - Forward Thinking";
gotoAndPlay (1);
}
}
OnLoad Or Ill Cut Off My Hands
Ok, witts end was a long time back and now that I am aproching insanity..... I am trying to use the new MX onload call back functions...
Hopefully someone can explain to my soft brain how I get these suposed time savers to work...
_root.stop();
// dog is a mlcip
_root.dog.onLoad= function(){
trace("I am gonna break something");
_root.play();}
_root.dog.loadMovie("navtext.swf",1);
I've tried about a billion different combinations and the moveie never loads.. and yes it's in the same directory.
I have tried all I can come upp with....Flash gods where are you... tell me I am stoopid, I don't care just help my pathetic week mind.... Humbly LunaPero
ps. I've had a few other developers not be able to figure this one out either........
Reverse Onload
Fighting for A few day's allready with the following prob;
I have loaded a movieclip into the stage with the action LoadMovie embeded into a button, so far ok, but in a different button I put the same action for a different MC to end up on the same spot as the previous one. Now my conundrum> how do I get the movieclip that is allready on the main stage to reverse it's animation BEFORE it gets replaced by the movieclip that i load in by the LoadMovie action....So i want the clip to first reverse the animation exactley on the moment that I give the command to replace it for a different one...can somebody please show me how???
OnLoad For Objects
I need to replace the following code so that it does not refer to an external xml file but instead to an internal xml object.
Code:
var myXML = new XML();
myXML.onLoad = myOnLoad;
// code for button which loads file
on (release) {
myXML.load (xmlFile)
}
// xmlFile refers to an external XML file.
Is there a way to 'load' an xml object so the onLoad function works?
OnLoad Jpeg?
in my movie i want users to click on a thumbnail which will dynamically load a fullsize jpeg into the movie -- and i would like to have it so that once the swf knows the size (dimensions W x H)of the jpeg, it can size a "matte" around it. but the image needs to be loaded before it tries to set the sizes, etc.
i'm just getting familiar with the "onLoad" action in MX. is it possible to use the onLoad on an imported jpeg? if so, do i target the jpeg itself? the MC it's loaded into?
here's an ex of the code currently. i'm married to none of it, except the loadMovie part.
Code:
loadMovie ( /:currentImage, "destination");
destination.onLoad = function () {
trace ("onLoad called");
gotoAndPlay("AdjustMax");
} ;
any help, or direction to a tutorial would be greatly appreciated. thanks,
JWT
OnLoad/onData
Tring to write a dynamic image display for any dimension jpg file.
Code i have written is as follows.
var depth=0
var i=0
createEmptyMovieClip("ImageHolder",depth)
this.onMouseDown=function()
{
loadImage()
}
function loadImage()
{
i++
Mov="Images/Image"+i+".jpg"
ImageHolder.loadMovie(Mov)
ImageHolder.onLoad=checkSize();
}
function checkSize ()
{
trace(ImageHolder._width)
//resize code to go here
ImageHolder._x=0
ImageHolder._y=0
}
loadImage()
this loads OK but the onLoad Event is triggered immediately rather than after Loading of the Image. As i want to change th properties of the ImageHolder Movieclip depending on its new dimensions this is causing a bit of a problem.
Has anyone had any problems with the .onLoad event and solved it, or can see any mistakes i am making.
Any help appreciated
Xml Data Not Available After OnLoad
I am loading an XML file into a movieclip. The problem I am having is that the data is not immediately available after the onLoad function has completed. If I do a trace within the onLoad function, I can see my data just fine, but once I am out of the onLoad function, the data is not there. Here is sample code to illustrate:
pic_array = new array();
pic_xml = new XML();
pic_xml.parentObj = this;
pic_xml.ignoreWhite = true;
pic_xml.onLoad = function(success){
if(success){
root = pic_xml.firstChild;
for(var i = 0; i < root.childNodes.length; i++)
{
with(root.childNodes[i]){
this.parentObj.pic_array.push(new PicData(attributes.image,
attributes.bodycode,
attributes.description,
attributes.price,
attributes.count));
}
}
trace(this.parentObj.pic_array[0].image);
}
else
trace("Error opening xml file");
}
pic_xml.load("picdata.xml");
trace(pic_array[0].image);
Caching With Onload
from a button, how is it possible to check if swf files have been cached and if not to load them?
OnLoad W/scenes
I am having a heck of a time. Does the 'onLoad' event take place at Scene 1, Frame 1 regardless of placement (ie, scene 2 frame 1?). When I test the "scene", I get totally different results as when I test "Movie". I read somewhere here that it's not recommended to have more than one scene, true?
Forgot to add that testing "scenes" is just a time saver, rather than testing the whole movie
MovieClip.onload
I have been working with the slides.fla from the archive. It is a movie that dynamically loads .jpgs using an XML data file to point to the pictures.
But I noticed that getting info on the currently loaded .jpg is delayed by one picture.
If we are viewing picture 2 after viewing picture 1 and we use
tbytes = targetClip.getBytesTotal();
the value of tbytes is the size of picture 1.
I am certain that this has something to do with getting the info before the new picture is actually loaded.
I tried to use
targetClip.onload = function() {
trace(" finished loading");
}
but that never responds.
Is targetClip really a MovieClip object?
If I delay the request for total bytes by two or three frames, the info is correct, but this is not a reliable method for a slow modem.
any solutions from the gurus?
OnLoad Not Working
Hi everyone,
I have the same problem as Mat who has explained it well. I've searched all over the net for an answer but no one seems to know. Any help would be appreciated.
Alvin
Hi all,
I've posted on this matter before but to no avail - I've looked at all the info in the groups for onLoad but none of them answer this question. My problem is that when I load an external swf file and give it an onLoad function, the function fires, but does not work properly for several reasons.
For example, if I want to pass some variables to the movie clip using the onLoad function, they don't get set. If I want to fire a function that is within the MC, it doesn't seem to exist.
It's as if the movie clip hasn't actually instatiated even though the onLoad event has been triggered. This is a HUGE problem for me and I would love some help on the matter, it's seems such a strange problem but one I hope can be solved. I have played around with similar functions and found that waiting a few seconds actually solves the problem - but I can't do that! I need to use onLoad! Why is onLoad fired when it's not actually instantiated?
An example of how my code works:
_root.attachMovie("emptyClip","myClip",0);
myClip.onLoad = clipOnLoad;
myClip.loadMovie("external.swf");
function clipOnLoad(){
this.myVariable = "test";
this.myFunction();
}
Thanks for your help folks...
Mat
--------------------------------------------------------------------------------
Onload And Html
I have a sliced fireworks image which I have exported as html and opened in dreamweaver. Part of the image is an swf file. It all works fine but I don't want the swf file to start playing until all the jpeg and gifs have loaded.
I understand that I might be able to use the onload action to do this but I don't know how to get the swf file to communicate with the html file so it knows when all of the rest has loaded and can start playing.
cheers!
|