OnLoad Not Working
The onLoad method will not work with this[num]. How else can I tell it to only make a new mc once the last one has loaded?
ActionScript Code: num = 0;loadMC();function loadMC() { if (loc == "URL") { this.createEmptyMovieClip(num, this.getNextHighestDepth()); this[num].loadMovie(path); } else if (loc == "library") { this.attachMovie(path, num, this.getNextHighestDepth()); } this[num]._xscale = this[num]._xscale/(this._xscale/100); this[num]._yscale = this[num]._yscale/(this._yscale/100); if (dup == "horizontal") { this[num]._x = this[num-1]._width+this[num-1]._x; } else if (dup == "vertical") { this[num]._y = this[num-1]._height+this[num-1]._y; }}this[num].onLoad = function() { if (tMark._width>this[num]._x & tMark._height>this[num]._y) { num += 1; loadMC(); } else { tMark.unloadMovie(); }};
ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 03-03-2007, 01:24 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
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 Not Working
okay so: in my class I want to load a bunch of info from a server (that works) and then loadMovie (a picture path loaded via the server). The problem is that it is never loaded in time so it ends up just trying to do loadMovie (undefined). Here is my code, what can I do to fix this?
Code:
class DispModule {
public var atts:Array;
public var loader:LoadVars;
private var ID:Number;
private var Status:String;
public function DispModule(mod_ID, num) {
this.ID = mod_ID;
this.atts = new Array();
this.loader = new LoadVars();
this.loader.ID = this.ID;
trace(this.loader.ID);
this.loader.sendAndLoad("http://ip+port/ModuleInfo.asp", loader, "POST");
this.loader.onLoad = function(succ:Boolean) {
if (succ) {
drawPic(num);
}
};
}
private function drawPic(num) {
trace("drawing: "+this.loader.image);
_level0["pic"+num].loadMovie(this.loader.image);
}
}
OnLoad Not Working NewEventmodel
hi there
somehow is the onLoad event not working
i have:
_root.theMovie.onLoad = function(){ this.var = something;}
but the var is not initializing.
can someone tell me why?
thx a lot
MyMovieClip.onLoad = NOT WORKING
I have a movie clip on my stage called "displayMC", on the first frame I place the following
Code:
displayMC.onLoad = function(){
this.nextLetter = 0;
trace("Next Letter is " add this.nextLetter);
};
I get NOTHING in the output window and when I try to use the value in an onEnterFrame it is undefined so the code continues to execute well after the desired effect has taken place.
What's strange (at least to me) is that if I change the onLoad to onEnterFrame, the trace executes and shows in the output window.
<font color = "red">EVEN MORE STRANGLY, </font>if I select the movie clip and attach the code in the old way
Code:
onClipEvent(load){
nextLetter = 0;
trace("Next Letter is " add this.nextLetter);
}
That works.
Can anyone see what I am doing wrong?
_visible Not Working Onload
ok..I am able to create several empty movie clips and draw into them, but when i try and make them not visible by means of _visible = false, it doesn't seem to work, but when there is a user action (button press) they all decide to start working.
//some code may not be right,b/c im doing from memory.
//this happens onload()
for (i=0;i<5;i++){
with(_root.createEmptyMovieClip(["movie" + i],(i+1))){
lineStyle(1,0xff0000,100);
moveTo(0,0);
lineTo(10,0);
lineTo(10,10);
lineTo(0,10);
lineTo(0,0);
_visible = false;
}
//this doesn't work all are visible....but this does work...
on(release){
for(i=0;i<5;i++){
_root["movie" + i]._visible = false;
}
}
//after that MC press....it works fine!!!!
this has baffled me.....thanks for the help!!!!!
-norie40
MovieClip.onLoad - Not Working?
Hi,
I want something to happen staright after my movie clip is loaded.
For some reason when I use the following in the timeline of the clip it doesnt work
Code:
this.onLoad = function(){
trace("Yes Iam Loaded");
}
Im sure Ive had this working many times before but for the life of me I dont know why it doesnt work now. Any ideas?
Problem With OnLoad Not Working ?
I cant get the following very simple code to work, not sure what is wrong.?
The following example defines a function for the onLoad method that sends a trace action to the Output window:
myMovieClip.onLoad = function () {
trace ("onLoad called");
};
I have basicly copied this, but it wont fire the trace window, it does when I use alternative code, that attaches to the movie clip. For example
OnClipEvent(load)
{
trace("Loaded");
};
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!
LoadMovie OnLoad Not Working
I've got a button that loads an image into a container called myloader.
I'm using this actionscript:
ActionScript Code:
on (release){ _root.myloader.loadMovie("2.jpg");_root.myloader.onLoad = function(success) {trace ("loaded");}}
The image loads but nothing traces in the output - whats going wrong?
Onload Event Not Working With Preloader
Three files are included below, a data txt file and two flash files.
LoadVarsProblem.zip
In the one without the preloader the .onload event of an object works but in the one with the preloader it doesn't.
I really need that onload event so i can pause the movie before creating objects dynamically from the variables in the data file.
Does anyone have any ideas how to fix this, because i'm really stumped and running out of time
Loaded - OnLoad - GetBytesLoaded Not Working
I've tried this several ways and I'm not finding any success!
I'm creating an exe & buring it to a CD w/ an autostart .inf. All the mp3's are pulled in & mapped via an xml. The audio is skipping in places.
I'd LIKE to wait until the audio has loaded until I start playing it. I was thinking that streaming was my problem and _soundbuftime value settings only made it worse....
// CODE -------------------------------------------------------
// xml file is loaded above this - I haven't included that code
narrationSnd = newSlideNode.attributes.NARRSND;
createEmptyMovieClip("audioClip", 1);
narrSnd = new Sound(eval("audioClip"));
narrSnd.loadSound(narrationSnd, false);
if (narrSnd.loaded == false){
for (i=0;1<10;i++){
progress_bar._visible = true;
narrSnd.start();
}
}
else
{
progress_bar._visible = false;
narrSnd.start();
}
//------------------------------
When I trace the narrSnd.loaded out it's undefined, narrSnd.getBytesLoaded always equals narrSnd.getBytesTotal!! It looks like it's loading the sound but it randomly stutters & skips. Anyone have problems with this or might have something else I could try?
OnLoad Not Working For Clip Using LoadMovie
The 'hold' movieClip is created using the createEmptyMovieClip command. Using the code below, the movie gets loaded but the onLoad function doesn't execute. Any ideas?
this.createEmptyMovieClip("hold",0);
hold.onLoad = function() {
trace("onLoad");
advanceQueue();
};
function startQueue() {
loadMovie(loadQueue[qIndex], "hold");
}
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>
OnLoad Event Handler Not Working
I have a movie clip on the stage called MyObject. This is the actionscript on the root:
Code:
MyObject.onLoad = function () {
trace("I'm on the root!");
};
Why won't this work?
Now if I put this actionscript on the object while leaving the above actionscript on the root, they both fire:
Code:
onClipEvent(load) {
trace("I'm on the object!");
}
Thanks.
Selfminded
OnLoad Fix Not Working In My Funky Editor
Hi,
Trying to load in Jpegs dynamically for a site editor I'm building. However, even with the onLoad fix, my onLoad code just doesn't work.
The onLoad seems to be firing too fast - if I try tracing out the image width/height in the onLoad function, I just get 0.
Any help gratefully received!
ActionScript Code:
for (var i = 0; i<this.firstChild.childNodes.length; i++) {
fileName = this.firstChild.childNodes[i].attributes.name;
library.masked.attachMovie("blank", "loader_"+i, i);
library.masked["loader_"+i]._x = newX;
library.masked["loader_"+i]._y = newY;
newX += 70;
if (newX >= 140){
newX = 0;
newY += 70;
}
library.masked["loader_"+i].createEmptyMovieClip('holder', 1);
library.masked["loader_"+i].holder.loadMovie("../images_lib"+fileName);
library.masked["loader_"+i].holder.onData = function(){};
library.masked["loader_"+i].holder.onLoad = function(){
this._height = 60/this._width*this._height;
this._width = 60;
};
}
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.
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!
Question: On OnLoad From External File Not Working
im trying to load some variables from an external file into a movie clip and it is not working. everything else works, except loading the variables.
code:-------------------
au.onLoad = function(){
origX = this._x;
origY = this._y;
trace(origX);
trace(origY);
}
and when i place this code directly into the movie clip:
onClipEvent(load){
origX = this._x;
origY = this._y;
trace(origX);
trace(origY);
}
it works fine. can anyone help me out?
Sound.onLoad Not Working Inside Class Help
i've tested this code outside my class, and inside my class. it only works outside of it...
ActionScript Code:
mySound = new Sound(myMP3);
mySound.loadSound("music/1.mp3", true);
mySound.onLoad = function()
{
trace(mySound.duration);
}
when its inside the class the duration just comes up as undefined!
I'm really stuck here! I'm writing a music player class that is working really well, but getting the position and duration don't seem to be so easy...
I attached the FLA and class file. you will need to edit this code to test it...
ActionScript Code:
mp.addSong("music/1.mp3", "Hitch Hiker Psychopath");
mp.addSong("music/2.mp3", "My Song");
mp.addSong("music/3.mp3", "Their Song");
mp.addSong("music/4.mp3", "Wanna grow old with you");
just change the first arguments for those to be links to real mp3s you have somewhere.
please help!
LoadMovie Not Working Inside XmlData.onLoad()
I'm successfully reading in values from an XML file which I would like to use to load images. I have no trouble loading the images if i assign the URL strings in the frame's actionscript manually. however, if i attempt it from the xmlData.onLoad() function, nothing seems to happen.
//works
sCoverImageURL_1 = "http://www.google.com/intl/en_ALL/images/logo.gif";
loadMovie(sCoverImageURL_1,"mvSwapCover1");
//doesn't
function loadXML(loaded) {
if (loaded) {
.....misc XML loading, works
loadMovie(sCoverImageURL_1,"mvSwapCover1");
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("five.xml");
_root.onLoad Not Working In Firefox, Suggestions?
Hey, all. I have a very, very simple thing in Flash that just will NOT work in Firefox and it's driving me nuts. On the very first frame of the root, I have the following code:
Code:
this.onLoad = function() {
_root.createTextField("test1_txt", 10000, 0, 0, 300, 100);
test1_txt.text = "WORK!!!";
}
Simple, right? Yet, it won't work on Firefox.
I don't know what the problem is. Thing is, I've used "this.onLoad" many-a-times in Flash and got it to work in Firefox.
It works in IE, by the way.
Is there something I'm doing terribly wrong here? Might there be a setting that I need to get the above code to work?
I wrote a bit of a hack to get around the problem I'm having:
Code:
this.onEnterFrame = function() {
if (_root.getBytesTotal() == _root.getBytesLoaded()) {
foo();
}
}
function foo() {
delete this.onEnterFrame;
_root.createTextField("test1_txt", 10000, 0, 0, 300, 100);
test1_txt.text = "WORK!!!";
}
This works all right but again, it's a hack, and I'd rather avoid using a hack like this.
Thanks in advance.
_root.onLoad Not Working In Firefox, Suggestions?
Hey, all. I have a very, very simple thing in Flash that just will NOT work in Firefox and it's driving me nuts. On the very first frame of the root, I have the following code:
Code:
this.onLoad = function() {
_root.createTextField("test1_txt", 10000, 0, 0, 300, 100);
test1_txt.text = "WORK!!!";
}
Simple, right? Yet, it won't work on Firefox.
I don't know what the problem is. Thing is, I've used "this.onLoad" many-a-times in Flash and got it to work in Firefox.
It works in IE, by the way.
Is there something I'm doing terribly wrong here? Might there be a setting that I need to get the above code to work?
I wrote a bit of a hack to get around the problem I'm having:
Code:
this.onEnterFrame = function() {
if (_root.getBytesTotal() == _root.getBytesLoaded()) {
foo();
}
}
function foo() {
delete this.onEnterFrame;
_root.createTextField("test1_txt", 10000, 0, 0, 300, 100);
test1_txt.text = "WORK!!!";
}
This works all right but again, it's a hack, and I'd rather avoid using a hack like this.
Thanks in advance.
MyVars.onLoad = Function(success) Working In Test Movie?
I have a little problem that's bugging me with the onLoad check for success when running my movie through Test Movie.
Firstly here's the actionscript on my submit screen:
Code:
myProfile.onLoad = function(success){
if (success){
gotoAndPlay("end");
status_txt.text = "Submitted";
}else{
gotoAndPlay("end");
status_txt.text="Not Submitted";
}
};
stop();
submit_btn.onRelease = function(){
myProfile.sendAndLoad("submitprofile.asp", myProfile, "POST");
};
I set up a LoadVars called myProfile and I have it posting the variables stored throughout the application to an asp page that links to an access database using sendAndLoad.
I have the onLoad testing if myProfile has been successful and going to next scene and displaying a 'Submitted' in a text field and if not successful going to the same screen but displaying 'Not Submitted' in the text field.
So when I run my movie through test movie it displays 'Submitted' even though I know that the loading of the data into the database is unsuccessful... Or has it?
There's no data in the database so why is this function's status true rather than false?
It works perfectly ok on localhost and web server and displays not submitted if I purposefully put an error in the variables.
HELP!
Anyone know what the reason is for this? As I say, it works fine on web server when running on the index.htm and accessing the asp page to database.
Cheers
G
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.
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.
|