?
Solved

loadVariablesNum - capture response "Error opening URL"

Posted on 2003-03-12
12
Medium Priority
?
326 Views
Last Modified: 2008-02-01
Hi I need to know if there is a way that I can capture the response caused by loadVariablesNum if an external file it is looking for doesn't exist.

When run using test movie within flash the error "Error opening URL: http://..." is displayed when the requested file is missing. I am wondering if there is a way to 'listen' for this response, and if it occurs, redirect the user to another page where an error can be displayed.



0
Comment
Question by:mickydunks
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
  • 2
12 Comments
 
LVL 6

Expert Comment

by:henryww
ID: 8126631
do u have MX?

if so u can use the LoadVars object and there is properties to do the onLoad = call back function which will tell to if the load is success or not.

if not ... and u have to use loadVariablesNum ... i can't think of any better way than just simply loop the frames until u get the something within a fixed time if not assume the link is broken or not existing ...

hope this helps.

cheers
0
 
LVL 22

Expert Comment

by:rascalpants
ID: 8129925
"When run using test movie within flash the error "Error opening URL: http://..." is displayed when the requested file is missing."

just so you know, you will always get this error, because you are not connected to a server when testing a movie in flash...


when you are on a server, you should just use an if...then check to see if a particular variable has been loaded...

if the variable has not been loaded, then do something else...  you can assume that after a second or two the info should have all been loaded, so just use a looping movieclip to load the variables and perform your if...then check there as well...  

// in the first frame of the looping movieclip

loadVariablesNumb("page.asp", 0");



// in the second frame of the looping movieclip

if(variable ==""){
  gotoAndPlay(1);
  _root.n++
    if(_root.n==12){
       // go to other page
    }
} else {
  //do something here
}


just make sure you have set the variable "n" to 0 in the root of the movie in the first frame.


this should work just fine


rp






0
 
LVL 6

Expert Comment

by:henryww
ID: 8130439
OnClipEvent(data)
{
... your code here... when data arrive ...

}


but then again ... as said early and rp's comment as well, u have to do or loop or set a time limit if nothing happens assume the load fail. MX can do the load success fail detection with loadVars ... so u may consider upgrading ... :)

cheers
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 22

Expert Comment

by:rascalpants
ID: 8130514
big H, the loadVars King...

long live the king :)


rp
0
 
LVL 6

Expert Comment

by:henryww
ID: 8130557
HA HA HA HA ... i like LoadVars so much u know ...
and u notice too ...
it is so much better than the loadVariable or anything ...
one of the best feature in MX, in my opinion ...

don't u like it?

HA HA HA LOL
0
 
LVL 22

Expert Comment

by:rascalpants
ID: 8130701
I have actually never taken the time to learn about it...

I am sure it is God's gift to web design, but I just don't want to pack more information in my brain...


rp
0
 
LVL 1

Author Comment

by:mickydunks
ID: 8132018
Thanks guys,

I am already looping through and waiting for the variable to load - as you suggested RP, but if the file doesn't exist - it won't process the loop at all - when you use loadVariablesNum() it checks for the files existance first, and then reads in what's contained in that file - if the file doesn't exist at all - the error I reported above is given. And by the way - I don't always get the error when running off line as the main file in question is a jsp file - so I am running Tomcat and referring to http://localhost/

Henry, can u give me some more details as to how I can achieve this error reporting using FlashMX's loadVars - I do have MX, and I know of the loadVars method, but wasn't real sure how to get the error if one is thrown.

Thanks

md
0
 
LVL 22

Expert Comment

by:rascalpants
ID: 8132332
I think you do this:

myNewVariable = new LoadVar();
myNewVariable.load("page.asp");
myNewVariable.loaded = function (success){
     if (success){
          //do something
     } else {
          //do something
     }


any ideas on a better way to do this Henry?

rp
0
 
LVL 1

Author Comment

by:mickydunks
ID: 8132537
Ok... at the moment - I am loading these 4 files from within the one frame - and then looping thru until the variables contained in each one exists - (they need to be separate pages for the ease of updating as they contain html data which needs to be easily modified)

loadVariablesNum(page1DataFile,0,"POST");
loadVariablesNum(page2DataFile,0,"POST");
loadVariablesNum(page3DataFile,0,"POST");
loadVariablesNum(page4DataFile,0,"POST");


whilst we're on the LoadVars subject - how can I load all four of these and use the LoadVars.getBytesLoaded method to show how long it is taking to load?? Is there any way I can do it for all four as a group - or do I need to have a counter type thing for each individual file
0
 
LVL 6

Accepted Solution

by:
henryww earned 400 total points
ID: 8134570
close ...


myNewVariable = new LoadVar();
myNewVariable.load("page.asp");

// here should be onLoad
myNewVariable.onLoad = function (success){
    if (success){
         //do something
    } else {
         //do something
    }
}

// to access the variables.
myNewVariable.variableNames ... etc

0
 
LVL 22

Expert Comment

by:rascalpants
ID: 8136289
Henry,

I am trying to update an old file that uses loadVariablesNum() and loads in about 20 rows of variables from a database...  how can I use loadVar() but have then load into the _root of the movie instead of the object?

the reason I ask, is because I am having problems just referencing the object in the dynamic text boxes...


so if I use the above code:

myNewVariable = new LoadVar();
myNewVariable.load("page.asp");

myNewVariable.onLoad = function (success){
   if (success){
        //do something
   } else {
        //do something
   }
}

myNewVariable.row1


is there a way to do what I want, without changeing all of my code to reference myNewVariable.variableName instead of _root.variableName ?


rp


0
 
LVL 6

Expert Comment

by:henryww
ID: 8136488
yes ...

use sendAndLoad instead then u can specify the target ...
myLoadVars.sendAndLoad(url, targetObject[,method])

send nothing .... but it still loads ...
and set the target to _root

cheers
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question