Simple Slideshow: LoadVars, Undefined Trace...scope Issue?
I'm making a simple slideshow (Flash MX 2004 V7.2).
I'm using LoadVars to access an outside text document to get the number of slides used in the slideshow (path: vars/slideInfo.txt, totalFrames=4).
Now I KNOW this is elementary, and I know it is something I'M doing/not doing, but I can't get my slideshow to recognize: totalFrames=4 (unless I hardcode it in!).
Using trace I get "undefined" everywhere in my code except within my .onLoad function statement which traces the number correctly: 4 (or whatever I change it to).
From hours of internet searching I think this may be a scope issue. I've tried adding additional code to fix this (my last efforts reflected below). Still I can't get the number of slides out of this function to be used by the rest of the slideshow.
Will someone please point out what I'm doing wrong (I know I'll feel stupid but I'll still appreciate it!)?
Thanks!
Trace Output from below code:
undefined undefined 4
4
Code:
var totalFrames:Number; var slideInfoLV:LoadVars = new LoadVars(); var totalFrames:Number; trace(totalFrames); //output: undefined slideInfoLV.onLoad = function(success:Boolean) { if (success) { slideCounter(); trace(this.totalFrames); //output: 4 totalFrames = this.totalFrames; trace(totalFrames); //output: 4 } else { frameNum.text = "error"; } }; slideInfoLV.load("vars/slideInfo.txt"); trace(totalFrames); //output: undefined
FlashKit > Flash Help > Flash Newbies
Posted on: 01-31-2006, 04:12 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
- Asfunction LoadVars:Scope Issue?
- (scope Issue) Should Be Simple, Brain Hurts.
- [flash8] Is This An Issue With Scope? No, Not Bad Breath, The Other Kind Of Scope
- Why Does My Trace Come Up UNDEFINED
- Trace(this) Is Undefined. How Is That Possible
- [AS1][loadVars] Scope Trouble With LoadVars
- [AS1][loadVars] Scope Trouble With LoadVars
- Undefined In Trace Window
- Undefined In Trace Window
- Why Am I Getting Undefined On Trace Command
- Trace(this._parent) == Undefined?
- For XML Lovers... How To Trace Invisible Values, Nulls And Undefined...
- Can Anyone Spot My Mistake Here, My Trace Coming Back Undefined, But Looks Perfect?
- Scope In Loadvars
- Can't Get LoadVars To Work... Neither Trace()?
- Scope Trouble With LoadVars
- Scope Trouble With LoadVars
- LoadVars Scope Problem
- LoadVars Scope POST
- Scope Trouble With LoadVars
- Scope Trouble With LoadVars
- LoadVars Scope Problems
- LoadVars Gives An Undefined
- Loadvars Undefined
- LoadVars + Php = Undefined
- LoadVars + PHP = Undefined.. Over And Over Again
- Variable Scope Problem With LoadVars()
- Loadvars As Class Member Scope
- LoadVars Within Class Scope Problems
- LoadVars.loaded Always Undefined
- [F8] LoadVars == Undefined ? [RESOLVED]
- LoadVars Returns Undefined
- Scope In Object Class File Using LoadVars - Help
- LoadVars/Targeting Problem . ..undefined
- Global Arrays In LoadVars Undefined
- Sending Data With Loadvars To Php , Undefined
- LoadVars = Success, But My Vars Are Undefined?
- LoadVars = Success, But My Vars Are Undefined?
- Slideshow Error 'undefined'
- Problem Sending Variable With LoadVars.send (scope Perhaps?)
- Slideshow With FUse / Error 'undefined'
- Can't Exchange Values Of Variables. Trace Returns "undefined" ?
- Made Functions Using For Loop, Trace Returns Undefined When Running Functions?
- Can't Exchange Values Of Variables. Trace Returns "undefined" ?
- Scope Issue
- Is This A Scope Issue Or Something Else ?
- [F8] Scope Issue
- [Q] AS2 And The Scope Issue...
- Scope Issue
Asfunction LoadVars:Scope Issue?
I'm trying to call a function from a text file loadVars
Code:
&<a href="asfunction:myFunction">American Association</a></p>
in my flash I have the following:
Code:
myFunction = function(totrace) {
trace("foobar");
}
function setupText() {
var spot = every.textHolder.createTextField("dt", 0, 0, 0, 514, 396);
spot.type = "dynamic";
spot.html = true;
spot.autoSize = "right";
spot.embedFonts = true;
spot.multiline = true;
spot.wordWrap = true;
spot.styleSheet = myCss.styleSet;
//////
var spot2 = drive.textHolder.createTextField("dt", 0, 0, 0, 514, 396);
spot2.type = "dynamic";
spot2.html = true;
spot2.autoSize = "right";
spot2.embedFonts = true;
spot2.multiline = true;
spot2.wordWrap = true;
spot2.styleSheet = myCss.styleSet;
loadText();
}
function loadText() {
whyText = new LoadVars();
whyText.onLoad = function() {
every.textHolder.dt.htmlText = whyText.everyText;
drive.textHolder.dt.htmlText = whyText.driveText;
};
whyText.load("whyText.txt");
}
and the asfunction is not calling the myFunction.
Any suggestions? I have tried just testing regular urls and javascript alerts...but no jive.
Could it be a scope issue, or perhaps something else.
Holla back.
Davidissimo
(scope Issue) Should Be Simple, Brain Hurts.
i'm trying to pass the "i" looping variable into the last function in this code (the button on release function)
for some reason I can't figger it out...(keeps loading the value from the last xml node) help!
Code:
stop();
//create new loadVars object to call PHP file and new XML object to hold results)
var loadModels = new loadVars();
var models_xml = new XML();
models_xml.ignoreWhite=true;
//set variables for thumbnail spacing
var columns=7;
var thumb_spacing = 135;
//set .onLoad function for when xml loads
models_xml.onLoad = function (success)
{
if (success)
{trace(this);
trace(this.status);
//create an array from main childnodes
totalModels = models_xml.firstChild.childNodes;
//loop through childnodes of array
for (var i=0; i<totalModels.length; i++) {
//attach clips for each model node
item = _root.holder.attachMovie("thumbClip", "thumbClip" + i, i);
item._x = (i%columns)*85;
item._y = Math.floor(i/columns)*thumb_spacing;
//assign variables to xml attributes
var firstName = totalModels[i].attributes.First_Name;
var ModelWire = totalModels[i].attributes.Modelwire
var lastName = totalModels[i].attributes.Last_Name;
var thumbToLoad = totalModels[i].attributes.Filename;
//item.thumbHolder.loadMovie(thumbToLoad);
item.largeviewtoload=largeviewtoload;
item.thumbFirstName.text=firstName;
item.thumbLastName.text=lastName;
//create a function for thumbnail button THIS IS THE PROBLEM!
item.ThumbButton.onRelease=function(){
_root.detailsClip.gotoAndPlay("in");
_root.holder._alpha=20;
_root.detailsClip.firstName = totalModels;
_root.detailsClip.lastName = lastName;
_root.detailsClip.ModelWire = ModelWire;
}}}}
//trigger loadvars/xmlload
loadModels.sendAndLoad("http://www.yyyyyy.com/test/models.php", models_xml);
[flash8] Is This An Issue With Scope? No, Not Bad Breath, The Other Kind Of Scope
I feel like such an idiot. This *should* have been a really simple operation and it's turned into an hour-long issue. I've been trying to migrate from putting my button code on buttons and move the code onto the timeline instead. However in this instance it no workie . The following code, specified for cancelMC affects every other button in this scene as if I'd written the code with(this){.
If someone would please just scan this code, and/or look at the picture and tell me what key ingredient I am missing I would really appreciate it:
ActionScript Code:
with(this.cancelMC){ onRollOver = function(){ this.ExplainMC.gotoAndStop("cancel"); } onRollOut = function(){ this.ExplainMC.gotoAndStop("void"); } onRelease = onReleaseOutside = function(){ _root.searchPanelMC.gotoAndStop(15); gotoAndStop("user"); } }
the code is on the timeline and so is the button (cancelMC). However, the code is on the first frame and the button exists on multiple frames thereafter. Does this matter? Does that put the button outside the scope of the code? I tried an onEnterFrame to no effect.
Why Does My Trace Come Up UNDEFINED
This is my code, can someone tell me how to reference the mc called
zmSlider so I can trace it and it doesn't come up undefined?
thankx
var isDown;
var myListener = new Object(this.viewport);
myListener.onMouseDown = function(){
isDown = true;
}
myListener.onMouseUp = function()
{
isDown = false;
}
myListener.onMouseMove = function()
{
trace(this.zmSlider._x);
if (isDown) {
this._parent.viewport._xscale += 150;
this._parent.viewport._yscale += 150;
}
}
Mouse.addListener(myListener);
Trace(this) Is Undefined. How Is That Possible
I have trace(this) inside of a function. The function of on _level0 | _root | maintime. The function is called via a setInterval.
trace(this) traces undefined. How is this possible? I believe the problem has to do with the setInterval. However "this" is a reserved key word. How can it be undefined?
ActionScript Code:
function myFunc() {
trace(this);
}
handle = setInterval(myFunc, 500);
[AS1][loadVars] Scope Trouble With LoadVars
Hi everybody,
I'm new on this server !
Is there a way to attach a file to my thread ?
You would find enclosed a ".zip" file in wich there's a ".fla" file, a ".txt" file and 6 ".jpg" images.
Frame 1 of the FLA only has a "Preload" class/constructor found on another site and works well.
Frame 2 launches the graphic interface construction.
The file "externalVar.txt" has one variable "maxVin" with a value of 6.
I would like to know WHY i can't acces this variable from outside of the loadVars object's scope (i would better say from outside of its ".onLoad" methode scope).
In fact, when i trace my variable "maxVinNum" from outside of this function, flash player return "undefined". Even if i declare "maxVinNum" on the _root (_root.maxVinNum).
For information, at the start of frame 2, i have let an instruction in comment :
//var maxVinNum = 6;
When we activate this instruction, then the variable is directely declared and everything works well. This test allow us to verify that scripts are not bugged.
Here is the script of frame 2, some of you may understand quickly what's wrong :
//var maxVinNum = 6;
var vignetteVars = new LoadVars();
vignetteVars.onLoad = function(ok) {
if (ok) {
trace(this.loaded);
maxVinNum = this.maxVin;
trace("maxVinNum = " + maxVinNum);
}
};
vignetteVars.load("externalVar.txt");
//
function buildArray (arrayLength) {
FileArray = new Array();
for (var i=0; i<maxVinNum; i++){
FileArray.push ("v_"+(i+1)+".jpg");
}
trace("FileArray : " + FileArray);
};
//
function buildSlide(){
vinKern = 1;
preloadSlide = new Preloader(load_indicator);
for (var i=0;i<FileArray.length;i++){
//Construction du slide
slide.vignette.duplicateMovieClip("vignette"+i,i);
slide["vignette"+i]._x += i*(slide.vignette._width + vinKern);
// ajoute à la file du preloader
preloadSlide.insert(FileArray[i], this.slide["vignette"+i].conteneur, i,"","","okload");
}
slide.vignette._visible=0;
};
buildArray(maxVinNum);
buildSlide()
stop();
I hope my english is not too bad, and my explaination not too long and understable.
thanks a lot for your help !
[AS1][loadVars] Scope Trouble With LoadVars
Hi everybody,
I'm new on this server !
Is there a way to attach a file to my thread ?
You would find enclosed a ".zip" file in wich there's a ".fla" file, a ".txt" file and 6 ".jpg" images.
Frame 1 of the FLA only has a "Preload" class/constructor found on another site and works well.
Frame 2 launches the graphic interface construction.
The file "externalVar.txt" has one variable "maxVin" with a value of 6.
I would like to know WHY i can't acces this variable from outside of the loadVars object's scope (i would better say from outside of its ".onLoad" methode scope).
In fact, when i trace my variable "maxVinNum" from outside of this function, flash player return "undefined". Even if i declare "maxVinNum" on the _root (_root.maxVinNum).
For information, at the start of frame 2, i have let an instruction in comment :
//var maxVinNum = 6;
When we activate this instruction, then the variable is directely declared and everything works well. This test allow us to verify that scripts are not bugged.
Here is the script of frame 2, some of you may understand quickly what's wrong :
//var maxVinNum = 6;
var vignetteVars = new LoadVars();
vignetteVars.onLoad = function(ok) {
if (ok) {
trace(this.loaded);
maxVinNum = this.maxVin;
trace("maxVinNum = " + maxVinNum);
}
};
vignetteVars.load("externalVar.txt");
//
function buildArray (arrayLength) {
FileArray = new Array();
for (var i=0; i<maxVinNum; i++){
FileArray.push ("v_"+(i+1)+".jpg");
}
trace("FileArray : " + FileArray);
};
//
function buildSlide(){
vinKern = 1;
preloadSlide = new Preloader(load_indicator);
for (var i=0;i<FileArray.length;i++){
//Construction du slide
slide.vignette.duplicateMovieClip("vignette"+i,i);
slide["vignette"+i]._x += i*(slide.vignette._width + vinKern);
// ajoute à la file du preloader
preloadSlide.insert(FileArray[i], this.slide["vignette"+i].conteneur, i,"","","okload");
}
slide.vignette._visible=0;
};
buildArray(maxVinNum);
buildSlide()
stop();
I hope my english is not too bad, and my explaination not too long and understandable.
thanks a lot for your help !
Undefined In Trace Window
This is the code to generate a random 6 digit number on frame 1
-------------------------------------
_root.rannumber = random(500000)+1;
if (_root.rannumber<10) {
_root.rannumber = "00000"+_root.rannumber;
}
if (_root.rannumber>9 && _root.rannumber<100) {
_root.rannumber = "0000"+_root.rannumber;
}
if (_root.rannumber>99 && _root.rannumber<1000) {
_root.rannumber = "000"+_root.rannumber;
}
if (_root.rannumber>999 && _root.rannumber<10000) {
_root.rannumber = "00"+_root.rannumber;
}
if (_root.rannumber>9999 && _root.rannumber<100000) {
_root.rannumber = "0"+_root.rannumber;
}
-----------------------------------------------------
on frame 2 i have this code for getting the variable length
---------------------------------------------------------
_root.tmp=_root.rannumber.length;
trace(_root.tmp);
My trace window keeps saying 'undefined' why?
Anyone help?
Thx
Undefined In Trace Window
This is the code to generate a random 6 digit number on frame 1
-------------------------------------
_root.rannumber = random(500000)+1;
if (_root.rannumber<10) {
_root.rannumber = "00000"+_root.rannumber;
}
if (_root.rannumber>9 && _root.rannumber<100) {
_root.rannumber = "0000"+_root.rannumber;
}
if (_root.rannumber>99 && _root.rannumber<1000) {
_root.rannumber = "000"+_root.rannumber;
}
if (_root.rannumber>999 && _root.rannumber<10000) {
_root.rannumber = "00"+_root.rannumber;
}
if (_root.rannumber>9999 && _root.rannumber<100000) {
_root.rannumber = "0"+_root.rannumber;
}
-----------------------------------------------------
on frame 2 i have this code for getting the variable length
---------------------------------------------------------
_root.tmp=_root.rannumber.length;
trace(_root.tmp);
My trace window keeps saying 'undefined' why?
Anyone help?
Why Am I Getting Undefined On Trace Command
I am getting undefined from my second trace command, yet i dont know why. My linkage identifier is NRX, the movie clip name is NRXcar. I am trying to attach a movie clip from library to stage, here is code:
Code:
trace(this);
var depth = this.getNextHighestDepth();
var io = {_x: 100, _y: 1, _visible: true}
this.attachMovie("NRX", "NRX1", 5, io);
trace(this.NRX1);
Trace(this._parent) == Undefined?
yet another question for the "loading jpegs into flash" theme. i've reviewed a lot of the recent threads on this topic, but nobody seems to have the problem i've run into...
i have a moviclip (bigImage) into which i'm loading a jpeg with loadMovie. it loads well enough, and the clip has this attached to it:
onClipEvent (data) {
trace("done loading");
}
so i know when the images are done loading. all well and good until i try to do something useful with the data event, like throw together a loading bar.
if i put something like
_root.BigImageIsLoaded = TRUE ;
into there, and elsewhere trace _root.BigImageIsLoaded, i get nothing. in fact, it seems that i can't address anything outside the clip itself with the data clipevent. for instance
trace(this);
returns the correctly pathed reference to the bigImage clip.
trace(this._parent);
returns "undefined"
undefined? what the huh?
For XML Lovers... How To Trace Invisible Values, Nulls And Undefined...
I am trying to add a new story into an XML file that holds stories... and save it using php. Everything looks preety clear and simple but I cannot trace a single value of the xml file. I don't know why...
The XML file...
Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<noticias>
<noticia fecha="14/04/2005">
<titulo>Nave rusa tripulada se acopla sin problemas a la Estación Espacial Internacional</titulo>
<mensaje>Moscú (dpa) - La nave rusa Soyuz, con tres tripulantes a bordo, se acopló hoy automáticamente sin problemas a la Estación Espacial Internacional (ISS) a las 02:20 GMT del domingo, informó hoy el centro de control de vuelo ruso cerca de Moscú.</mensaje>
</noticia>
<noticia fecha="25/02/2005">
<titulo>Finaliza estado de excepción pero crece descontento</titulo>
<mensaje>Luego de que el presidente de Ecuador, Lucio Gutiérrez, levantara el estado de emergencia decretado en Quito el viernes, las multitudinarias protestas en dicha ciudad exigiendo la dimisión del mandatario empezaron a extenderse a otras regiones y amenazan con abarcar todo el país.</mensaje>
</noticia>
<noticia fecha="10/01/2005">
<titulo>Intel pronostica que banda ancha en celulares empezará en 2006</titulo>
<mensaje>La nueva tecnología inalámbrica de banda ancha WiMax está empezando a recibir la atención de los operadores de telefonía fija y móvil, pero aún tardará varios años hasta que sea utilizada por un mercado masivo de consumidores, anunció Intel.</mensaje>
</noticia>
</noticias>
The code:
Code:
import mx.utils.Delegate;
//Permite caracteres tradicionales como letras con tilde la ñ, etc.
System.useCodepage = true;
// Init vars
var estado:String = "";
var newXML:XML = new XML();
var previousXML:XML = new XML();
var replyXML:XML = new XML();
previousXML.load("../data/noticias.xml");
previousXML.onLoad = Delegate.create( this, onLoadXMLFile );
function onLoadXMLFile( status )
{
if( status )
{
orderXMLData();
}
else
{
estado = "Error abriendo fichero...";
}
}
function orderXMLData()
{
estado = "Revisando fichero...";
ignoreWhite = true;
//create the nodes
var noticia:XMLNode = newXML.createElement("noticia");
var titulo:XMLNode = newXML.createElement("titulo");
var mensaje:XMLNode = newXML.createElement("mensaje");
//place the nodes in the XML tree
newXML.appendChild(noticia);
noticia.appendChild(titulo);
noticia.appendChild(mensaje);
//add the fecha
noticia.attributes.fecha = fechaField.text;
// create two XML text nodes
var textTitulo:XMLNode = newXML.createTextNode(tituloField.text);
var textMensaje:XMLNode = newXML.createTextNode(noticiaField.text);
//add the titulo and noticia
titulo.appendChild(textTitulo);
mensaje.appendChild(textMensaje);
//insert the previous news in the XML file
for( var i = 0; i < previousXML.childNodes.length; i++ )
{
var noticia2 = previousXML.childNodes[i];
var titulo2 = previousXML.childNodes[i].firstChild.firstChild.nodeValue;
var mensaje2 = previousXML.childNodes[i].firstChild.nextSibling.firstChild.nodeValue;
trace( titulo2 );
newXML.appendChild(noticia2);
noticia2.appendChild(titulo2);
noticia2.appendChild(mensaje2);
}
trace( previousXML.firstChild.childNodes.length );
newXML.contentType = "text/xml";
//replyXML.onLoad = onReplyXML;
//newXML.sendAndLoad("guardar_noticia.php", replyXML);
}
function onReplyXML( success:Boolean )
{
if( success )
{
estado = "Noticia insertada!";
tituloField.text = "";
noticiaField.text = "";
delete newXML;
delete previousXML;
delete replyXML;
}
else
{
estado = "Error de conexión...";
}
}
Can Anyone Spot My Mistake Here, My Trace Coming Back Undefined, But Looks Perfect?
I am having some trouble and I cannot put my finger on it, coming back undefined, but all looks perfect! no?
my xml
ActionScript Code:
<clients> <client> <image>1.jpg</image> </client></clients>
my flash actionscript
ActionScript Code:
clientXML = new XML();clientXML.ignoreWhite = true;clientXML.load("client.xml");//has the xml loadedclientXML.onLoad = function(success) { if (success) { xmlNode = this.firstChild; total = xmlNode.childNodes.length; for (i=0; i<total; i++) { //xml retrieval image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue; } firstXML(); }}//FIRST XMLfunction firstXML() { trace(image[0]); };
Scope In Loadvars
Last edited by AntonioVP : 2004-03-24 at 17:36.
Hello,
I'm loading this string into flash
&filephpname=building1.jpg,BH_Sword_Pose_medium.jpg,Building2.jpg,tinker_medium.jpg,flower_orange.jpg,flower_pink.jpg,flower_purple.jpg,flower_red.jpg ,flower_yellow.jpg,&total=9&isfin=1&
I am using standard loadvars I think:
_global.filephpname = null;
_global.isfin=0;
lvl_url = "http://www.nyclightwave.com/dtreats/b.php";
filesloaded = new LoadVars();
filesloaded.load(lvl_url);
filesloaded.onLoad = function(success) {
if (success == true) {
this.temp = this.filephpname.split(",");
trace("calling function success");
trace("isfin in function: "+_global.isfin);
trace("total: "+this.total);
trace("filenames: "+this.filephpname);
}
};
Now the result in the trace statement works inside the loadvars function, but not outside of it, anybody know why?
here is the result of the output window:
calling function success
isfin in function: 0
total: 9
filenames: building1.jpg,BH_Sword_Pose_medium.jpg,Building2.jpg,tinker_medium.jpg,flower_orange.jpg,flower_pink.jpg,flower_purple.jpg,flower_red.jpg,flower_yello w.jpg,
(note the below are in trace statements in frame 2)
isfin : 0
filenamesoutside.
temp:
pic array:
Note that the isfin is is 0 outside the function. (so is this a problem of local variables vs global variables.)
Is there a way to transfer the data to global variables? I tried that, it didn't seem to work.
I tried _level0.filephpname, _root.filephpname, adding in to the above function _global.filename=this.filephpname and still can't access it.
Anybody know why.
I hope I wrote the problem clear enough.
VitoVOnAntwon
Can't Get LoadVars To Work... Neither Trace()?
hey,
I've been getting a few weird problems when using flash mx on osx (6,0,79 player version), which are leaving me wondering whether I have a badly installed copy of mx.
I'm using the following code to load vars from a php script that publishes my flash movie, but it doesn't work... on top of it, trace() messages don't appear when testing the movie on the browser, making it real hard to debug this...
Code:
urlVars = new LoadVars();
urlVars.load('absolute/path/to/script.php?var=value');
if(urlVars.loaded) {
trace('urlvars loaded');
trace(urlVars.var);
} else {
trace('couldn't load var');
}
and here is the php code:
Code:
<?
echo "var=" . $_REQUEST['var'];
?>
there's also another mistery issue which I'm pursuing on another thread, related to not being to read a loaded xml tree... I'm just about to reinstall flash altogether
thanks in advance for any comments
Scope Trouble With LoadVars
[AS1][loadVars] Scope trouble with loadVars !
Hi everybody,
I'm new on this server !
You will find enclosed a ".zip" file in wich there's a ".fla" file, a ".txt" file and 6 ".jpg" images.
Frame 1 of the FLA only has a "Preload" class/constructor found on another site and works well.
Frame 2 launches the graphic interface construction.
The file "externalVar.txt" has one variable "maxVin" with a value of 6.
I would like to know WHY i can't acces this variable from outside of the loadVars object's scope (i would better say from outside of its ".onLoad" methode scope).
In fact, when i trace my variable "maxVinNum" from outside of this function, flash player return "undefined". Even if i declare "maxVinNum" on the _root (_root.maxVinNum).
For information, at the start of frame 2, i have let an instruction in comment :
//var maxVinNum = 6;
When we activate this instruction, then the variable is directely declared and everything works well. This test allow us to verify that scripts are not bugged.
Here is the script of frame 2, some of you may understand quickly what's wrong :
//var maxVinNum = 6;
var vignetteVars = new LoadVars();
vignetteVars.onLoad = function(ok) {
if (ok) {
trace(this.loaded);
maxVinNum = this.maxVin;
trace("maxVinNum = " + maxVinNum);
}
};
vignetteVars.load("externalVar.txt");
//
function buildArray (arrayLength) {
FileArray = new Array();
for (var i=0; i<maxVinNum; i++){
FileArray.push ("v_"+(i+1)+".jpg");
}
trace("FileArray : " + FileArray);
};
//
function buildSlide(){
vinKern = 1;
preloadSlide = new Preloader(load_indicator);
for (var i=0;i<FileArray.length;i++){
//Construction du slide
slide.vignette.duplicateMovieClip("vignette"+i,i);
slide["vignette"+i]._x += i*(slide.vignette._width + vinKern);
// ajoute à la file du preloader
preloadSlide.insert(FileArray[i], this.slide["vignette"+i].conteneur, i,"","","okload");
}
slide.vignette._visible=0;
};
buildArray(maxVinNum);
buildSlide()
stop();
I hope my english is not too bad, and my explaination not too long and understable.
thanks a lot for your help !
Scope Trouble With LoadVars
[AS1][loadVars] Scope trouble with loadVars !
Hi everybody,
I'm new on this server !
You will find enclosed a ".zip" file in wich there's a ".fla" file, a ".txt" file and 6 ".jpg" images.
Frame 1 of the FLA only has a "Preload" class/constructor found on another site and works well.
Frame 2 launches the graphic interface construction.
The file "externalVar.txt" has one variable "maxVin" with a value of 6.
I would like to know WHY i can't acces this variable from outside of the loadVars object's scope (i would better say from outside of its ".onLoad" methode scope).
In fact, when i trace my variable "maxVinNum" from outside of this function, flash player return "undefined". Even if i declare "maxVinNum" on the _root (_root.maxVinNum).
For information, at the start of frame 2, i have let an instruction in comment :
//var maxVinNum = 6;
When we activate this instruction, then the variable is directely declared and everything works well. This test allow us to verify that scripts are not bugged.
Here is the script of frame 2, some of you may understand quickly what's wrong :
//var maxVinNum = 6;
var vignetteVars = new LoadVars();
vignetteVars.onLoad = function(ok) {
if (ok) {
trace(this.loaded);
maxVinNum = this.maxVin;
trace("maxVinNum = " + maxVinNum);
}
};
vignetteVars.load("externalVar.txt");
//
function buildArray (arrayLength) {
FileArray = new Array();
for (var i=0; i<maxVinNum; i++){
FileArray.push ("v_"+(i+1)+".jpg");
}
trace("FileArray : " + FileArray);
};
//
function buildSlide(){
vinKern = 1;
preloadSlide = new Preloader(load_indicator);
for (var i=0;i<FileArray.length;i++){
//Construction du slide
slide.vignette.duplicateMovieClip("vignette"+i,i);
slide["vignette"+i]._x += i*(slide.vignette._width + vinKern);
// ajoute à la file du preloader
preloadSlide.insert(FileArray[i], this.slide["vignette"+i].conteneur, i,"","","okload");
}
slide.vignette._visible=0;
};
buildArray(maxVinNum);
buildSlide()
stop();
I hope my english is not too bad, and my explaination not too long and understable.
thanks a lot for your help !
LoadVars Scope Problem
Hello.. My first time in a long time.
I've written a fairly standard piece of code using loadVars on the first frame of a movie clip:
function newSquares () {
...
}
var changeSquares = new LoadVars();
changeSquares.onLoad = newSquares;
changeSquares.load("calendardata.php");
Everything works just peachy until I try to refer to this code from outside the timeline. I need a button to do a sendAndLoad from a different MC.
I've tried:
making changeSquares global.
declaring changeSquares elsewhere and changing the path to the function.
declaring the function elsewhere and changing the paths within.
I'm sortof at my wits end. Any ideas would be appreciated.
LoadVars Scope POST
Hi all
If Im using funcion to send vars with "POST" does it send all crap what I have in this level?
ActionScript Code:
function submitContact() {
//define object to hold result
result_lv = new LoadVars();
//Define object to hold vars
cc_lv = new LoadVars();
//Attach vars to object
cc_lv.me_name = txName.text;
cc_lv.me_subject = txSubject.text;
cc_lv.to_email = mcToEmail.txEmail.text;
cc_lv.me_email = txUemail.text;
cc_lv.me_msg = txMessage.text;
//Send vars to script
cc_lv.sendAndLoad(path2php + "contact.php", result_lv, "POST");
result_lv.onLoad = function(success) {
if (success) {
//on the last line of the php script put
// echo "&retval=1&";
if (result_lv.retval.length > 0) {
gotoAndStop(8);
} else {
//incase of error trace what has been sent back
trace("ERROR:" + newline + unescape(result_lv));
}
}
};
}
Scope Trouble With LoadVars
[AS1][loadVars] Scope trouble with loadVars !
Hi everybody,
I'm new on this server !
You will find enclosed a ".zip" file in wich there's a ".fla" file, a ".txt" file and 6 ".jpg" images.
Frame 1 of the FLA only has a "Preload" class/constructor found on another site and works well.
Frame 2 launches the graphic interface construction.
The file "externalVar.txt" has one variable "maxVin" with a value of 6.
I would like to know WHY i can't acces this variable from outside of the loadVars object's scope (i would better say from outside of its ".onLoad" methode scope).
In fact, when i trace my variable "maxVinNum" from outside of this function, flash player return "undefined". Even if i declare "maxVinNum" on the _root (_root.maxVinNum).
For information, at the start of frame 2, i have let an instruction in comment :
//var maxVinNum = 6;
When we activate this instruction, then the variable is directely declared and everything works well. This test allow us to verify that scripts are not bugged.
Here is the script of frame 2, some of you may understand quickly what's wrong :
ActionScript Code:
//var maxVinNum = 6;var vignetteVars = new LoadVars();vignetteVars.onLoad = function(ok) { if (ok) { trace(this.loaded); maxVinNum = this.maxVin; trace("maxVinNum = " + maxVinNum); }};vignetteVars.load("externalVar.txt");//function buildArray (arrayLength) { FileArray = new Array(); for (var i=0; i<maxVinNum; i++){ FileArray.push ("v_"+(i+1)+".jpg"); } trace("FileArray : " + FileArray);};//function buildSlide(){ vinKern = 1; preloadSlide = new Preloader(load_indicator); for (var i=0;i<FileArray.length;i++){ //Construction du slide slide.vignette.duplicateMovieClip("vignette"+i,i); slide["vignette"+i]._x += i*(slide.vignette._width + vinKern); // ajoute à la file du preloader preloadSlide.insert(FileArray[i], this.slide["vignette"+i].conteneur, i,"","","okload"); } slide.vignette._visible=0;};buildArray(maxVinNum);buildSlide()stop();
I hope my english is not too bad, and my explaination not too long and understable.
thanks a lot for your help !
Scope Trouble With LoadVars
[AS1][loadVars] Scope trouble with loadVars !
Hi everybody,
I'm new on this server !
You will find enclosed a ".zip" file in wich there's a ".fla" file, a ".txt" file and 6 ".jpg" images.
Frame 1 of the FLA only has a "Preload" class/constructor found on another site and works well.
Frame 2 launches the graphic interface construction.
The file "externalVar.txt" has one variable "maxVin" with a value of 6.
I would like to know WHY i can't acces this variable from outside of the loadVars object's scope (i would better say from outside of its ".onLoad" methode scope).
In fact, when i trace my variable "maxVinNum" from outside of this function, flash player return "undefined". Even if i declare "maxVinNum" on the _root (_root.maxVinNum).
For information, at the start of frame 2, i have let an instruction in comment :
//var maxVinNum = 6;
When we activate this instruction, then the variable is directely declared and everything works well. This test allow us to verify that scripts are not bugged.
Here is the script of frame 2, some of you may understand quickly what's wrong :
ActionScript Code:
//var maxVinNum = 6;var vignetteVars = new LoadVars();vignetteVars.onLoad = function(ok) { if (ok) { trace(this.loaded); maxVinNum = this.maxVin; trace("maxVinNum = " + maxVinNum); }};vignetteVars.load("externalVar.txt");//function buildArray (arrayLength) { FileArray = new Array(); for (var i=0; i<maxVinNum; i++){ FileArray.push ("v_"+(i+1)+".jpg"); } trace("FileArray : " + FileArray);};//function buildSlide(){ vinKern = 1; preloadSlide = new Preloader(load_indicator); for (var i=0;i<FileArray.length;i++){ //Construction du slide slide.vignette.duplicateMovieClip("vignette"+i,i); slide["vignette"+i]._x += i*(slide.vignette._width + vinKern); // ajoute à la file du preloader preloadSlide.insert(FileArray[i], this.slide["vignette"+i].conteneur, i,"","","okload"); } slide.vignette._visible=0;};buildArray(maxVinNum);buildSlide()stop();
I hope my english is not too bad, and my explaination not too long and understable.
thanks a lot for your help !
LoadVars Scope Problems
Hello,
I have code similar to the following:
Code:
var requestURI:String = "http://ad.adserver.net/ad/5";
_global.clickTagURI = "http://ad.adserver.net/jump/5";
var request_lv:LoadVars = new LoadVars();
var response_lv:LoadVars = new LoadVars();
response_lv.onLoad = function(worked:Boolean) {
if (worked) {
attachMovie("clickThroughMc", "clickThrough_mc", getNextHighestDepth());
clickThrough_mc.onRelease = function() {
getURL(_global.clickTagURI, "_blank");
};
}
}
request_lv.sendAndLoad(requestURI, response_lv, "GET");
I need access to the "clickTagURI" variable inside the clickThrough_mc.onRelease event handler. I'm currently trying to access it as a global variable, but to no avail. I've also tried attaching it as a property of the response_lv object, and also have tried passing it as a second parameter to the response_lv.onLoad handler, but these attempts were unsuccessful as well. Does anyone have any suggestions as to the best way to go about doing this? Thanks.
-aaron.chandler-
LoadVars Gives An Undefined
Hi there,
because I am no 'AS-wizard' my wisdom came to an end...
I tried to load text from an external txt file into the textfield with the LoadVars ...
but I only get an 'undefined'....
I have no clue whats wrong...anyone can help??
thats the AS:
import caurina.transitions.Tweener;
//set the alpha to 0
scroller_mc._alpha = 0;
//fade the textfield in
Tweener.addTween(scroller_mc, {_alpha:100, time:3, delay:2.5});
//--------------LoadVarsAS goes here-------to load the contentTXT-----------
var myLV:LoadVars = new LoadVars();
myLV.onLoad = function (success:Boolean) {
if (success) {
scroller_mc.txt_mc.text_txt.htmlText = myLV.links;
trace("jaja");
} else {
scroller_mc.txt_mc.text_txt.text = "Sorry!There has been an error in loading the text."
}
}
//---------load the text
myLV.load("links.txt");
the external text starts with "links=........"
and I use sharedFonts
Hope someone can help
Thanks a lot
Loadvars Undefined
No matter what I do,
myData = new LoadVars();
myData.onLoad = function() {
Success = true
};
myData.load("params.txt");
when I test this movie in the flash player all run ok,
but embedded in a html page, tested in a server all the parameters are undefined. can anyone help me please????
LoadVars + Php = Undefined
This should be a rather simple thing to do. Server is running, files are in my htdocs folder.
but it just reports undefined. Any thoughts?
Code:
var cat = new LoadVars
function printOut(success){
frankencat.text = cat.id;
}
cat.load("test.php");
cat.onLoad = printOut();
PHP Code:
<?php print "id=lalalalalalalalalalallalalalalalalalalalalalalalalalalala";?>
LoadVars + PHP = Undefined.. Over And Over Again
First off, I'm no idiot. Wanted to make that statement before acting like one...
PHP Code:
PHP Code:
<?php
echo "score1=1";
?>
Actionscript:
Code:
var score:LoadVars = new LoadVars();
score.load("score.php");
score.onLoad = function() {
trace(this.score1); // displays 'undefined'
};
I tried 11 actionscript examples from the actionscript Bible, PHP for Flash and from numerous websites. I copy/paste code and yet.... nothing works.
I'm using Flash MX 2004.
How is this possible?
Variable Scope Problem With LoadVars()
Can anyone tell me why the trace for var1 works ok but the trace for var2 displays "undefined".
It seems that a varibale has to be declared and used within the onLoad function or it wont work.
my text file (textfile.txt)is as follows:
var1=Variable1&var2=Variable2
loadedVars = new LoadVars();
loadedVars.onLoad = function(success) {
if (success) {
trace(loadedVars.var1);
} else {
trace("Error loading file");
}
};
trace(loadedVars.var2);
loadedVars.load("textfile.txt");
Output for above code:
Undefined
Variable1
Loadvars As Class Member Scope
Hi all,
I've declared a class that has a loadvars member and an overloaded function for onLoad. the class also has a different string members. How do I access those members from onLoad??
Code:
class Base{
var m_sConfigFile:String;
var m_aElements:Array;
var m_tfStatus:TextField;
var m_lvInitVars:LoadVars;
function Base(){
}
////////////////////////////////////////////////////////////////////////////////////
function Init(Configs:String):Boolean{
//init text status
m_tfStatus=_root.createTextField("Status",_root.getNextHighestDepth(), 0, 0, 200, 200);
m_tfStatus.autoSize="left";
m_tfStatus.border=true;
m_tfStatus.text="Status";
if(Configs.length==0||arguments.length==0){
m_tfStatus.text="No init file";
return false;
}
else{
m_tfStatus.text="Loading:"+Configs;
m_lvInitVars = new LoadVars();
m_lvInitVars.onLoad=_onLoadInit;
m_lvInitVars.load(Configs);
m_lv
trace(m_lvInitVars._parent);
return true;
}
}
////////////////////////////////////////////////////////////////////////////////////
function _onLoadInit(success:Boolean){
if(success){
m_tfStatus.text="LOAD COMPLETE";
}
else{
m_tfStatus.text="LOAD INCOMPLETE";
}
};
////////////////////////////////////////////////////////////////////////////////////
}
LoadVars Within Class Scope Problems
Code:
class Forum{
// private var
private var forumPodTarget:MovieClip;
private var forumServerDataSend:LoadVars;
private var forumServerDataReceive:LoadVars;
// constructor
public function Forum(__forumPodTarget:MovieClip) {
forumPodTarget = __forumPodTarget;
forumServerDataSend = new LoadVars();
}
// public methods
public function loadForumData(){
var to = this;
forumServerDataReceive.onLoad = to.parseForumData;
forumServerDataSend.sendAndLoad("http://localhost/tsuma/vicsntrix/php/ViewBoard.php", forumServerDataReceive, "POST");
}
public function doOtherStuff(){
}
// private methods
public function parseForumData(){
var to = this;
// with or without the to, the "doOtherStuff" does not get called unless I refrence the full scope.
doOtherStuff()
}
}
The onLoad handler is activating the parseForumData method. But the doOtherStuff method is not being fired. I can get around this by referening the function using the full path to the object. But this is bad code.
LoadVars.loaded Always Undefined
Hi there,
I have:
Code:
lv = new LoadVars();
lv.pageIndex = pageIndex;
lv.sendAndLoad("List_NewsStories.aspx", result_lv, "GET");
trace("loaded: " + lv.loaded);
And it always outputs 'undefined' even in the onLoad handler.
Any ideas?
[F8] LoadVars == Undefined ? [RESOLVED]
Hi,
I've got a LoadVars object that has issues with one of its parameters. This is for a dynamic image gallery that's mostly complete. All of my code works fine, except for when I put the php script I'm calling on my web server. Then one (and only one) of my variables comes back as undefined.
Here's the code:
Code:
var picVars:LoadVars = new LoadVars();
var gall:String = "gallery1";
picVars.onLoad = function(success){
if (success){
parseFiles(picVars.returnFiles,picVars.widths,picVars.heights);
trace(returnFiles); // returns "undefined"
trace(widths); // returns a string of numbers
trace(heights); // returns a string of numbers
}
else{
error = "ERROR WITH LOADVARS";
}
};
picVars.load("../getImages.php?gall=" + gall);
So as you can see, all but one of my LoadVars variables returns the correct data. picVars.returnFiles traces as undefined. And as I said, it works fine when I run it locally.
Also, if I navigate directly to my script, PHP prints the correct data, so it's not a server-side issue. The proper string it returns is:
returnFiles=8.jpg|9.jpg|1.jpg|2.jpg|3.jpg|5.jpg|6. jpg|7.jpg|4.jpg|&widths=47|47|39|39|40|24|48|40|53 |&heights=36|36|36|36|36|36|36|36|36|
Just a big string of image names and dimensions.
This is especially puzzling since "success" is obviously coming back as true. Anyone have any ideas?
LoadVars Returns Undefined
en.txt:
introHead=Headline here.&introBody=Body copy here.
The Flash 8 Stage:
- Text Field instance named "head_txt"
- Text Field instance named "body_txt"
- Both set to Dynamic
The ActionScript:
Code:
// default language //
loadText("en");
// load all site text from file //
function loadText(language:String) {
siteText = new LoadVars();
siteText.load(language + ".txt")
}
// populate headline and body copy text fields for this page //
function populatePage(pageName:String) {
siteText.onLoad = function() {
head_txt.text = siteText.pageName + "Head";
body_txt.text = siteText.pageName + "Body";
}
}
populatePage("intro");
stop();
Since I'm using "pageName" twice, it seems obvious to declare it as a variable and have the function dynamically retreive it. But it's not working. The text being displayed in those two boxes returns as "undefinedHead" and "undefinedBody" instead of the real content from the text file. This does work, however:
Code:
head_txt.text = siteText.introHead;
body_txt.text = siteText.introBody;
i.e., if I "hard code" it, it works fine. But as a variable, it doesn't.
Other random piece of info: if I declare the LoadVars with strict data typing it doesn't load the text file at all:
Code:
var siteText:LoadVars = new LoadVars();
I'm guessing it's scope-related, but I've run out of ideas. Any thoughts?
Scope In Object Class File Using LoadVars - Help
Hi guys,
please help, i'm pulling my hair out!! i can't seem to get my head around scopes within a class file i've tried to create..
the aim of the class file is to go and retrieve a news article form a mysql database and store data such as "headline" and "textBody" etc in it so that i can then display it in a dynamic text box later in the movie file.
here is the code on the flash file creating the flash:
Code:
import as.*
trace("step 1");
var testING:newsArticle = new newsArticle(3);
trace ("step 2");
trace ("head = "+testING.headLine + " &id = "+testING.aID);
here is the actual class file newsArticle.as...
Code:
import mx.utils.Delegate;
class as.newsArticle {
var aID:Number;
var table:String = "sales_headlines";
var returnPage;
var graphic:String = "";
var headLine:String;
var bodyText:String = "";
var mainText:String = "";
var catID:Number = 0;
var displayAsNews:Number = 0;
var articleDate;
var $loader:LoadVars;
var $url:String = "http://www.xyz.com/flash/getdata.php";
var thisObj;
function newsArticle($id) {
//----------------------------------------------
// article is being created so go to the
// database and get all the details
//----------------------------------------------
aID = $id;
var thisObj:newsArticle;
_global.thisObj = this;
init();
execute();
trace ("sweet "+headLine);
} // end of constructor
function init () : Void {
$loader = new LoadVars();
$loader.onLoad = Delegate.create (this, onLoad2);
}
function execute () : Void {
$loader.load($url);
}
function onLoad2 (success:Boolean) : Void {
if(success) {
_global.thisObj.headLine = $loader.headline0;
trace ("ok ----- "+headLine);
} else {
trace ("bad !");
}
}
} // end of class file
and finally here is the trace output..
Code:
step 1
sweet undefined
step 2
head = undefined &id = 3
ok ----- The world's first 100Mbps Hotel Internet Pipe
Please can anyone advice on what the heck i'm doing wrong??? I want to be able to call "testING.headLine" anywhere in my movie file.. how do i make it a global object? and how do i populate the class variables so they can be accessed from the .fla file.... the aID works but not the headLine arrghhh!
Thanks in advance for any advice...
LoadVars/Targeting Problem . ..undefined
I am building a site in which there is a container file that loads multiple swfs. Those loaded swfs, then load other swfs into them. Once that third level of swfs is loaded, I am loading txt files into the interface. swf(_root) > swf(2) > swf(3) > txtfile.
The LoadVars script that I am using loads perfectly when I test that specific swf individually, but once I script it to load into the various levels, I get an undefined error.
Here is the script without considering the levels:
var loadVarText = new LoadVars();
LoadVarText.load("botero.txt");
loadVarText.onLoad = function() {
scroller.html = true;
scroller.htmlText = this.var1
}
Here is the script considering the levels:
var loadVarText = new LoadVars();
LoadVarText.load("botero.txt");
loadVarText.onLoad = function() {
_root.sections.loader.scroller.html = true;
_root.sections.loader.scroller.htmlText = this.var1
}
If anyone has had this problem and has found a fix, please help!!!
thanks. tonofmun
Global Arrays In LoadVars Undefined
Heellp... I have read all the threads I could find on this topic, but now I've gotta give up.
The question is simple, but the answer isn't... or so it seems.
How can I make the arrays, defined in mycode accessible outside the loadVars object??? The arrays stays local no matter what I do. When I access data in the arrays inside the loadVars object it works okay, but ouside they are "undefined"....!
I have tried using the _global property in every thinkable way, but it does not work.... and now I am completely lost!
What I am trying to do is to build up a poll, importing data from a mysql database. The data import goes fine, and the comboboxes and dynamic text fields in Flash are filled with the data from the database, but, I need the arrays for calculating percantages and totals for when the user clicks submit,
Check out my work in progress here (it's in Danish):
http://www.andand.dk/ulydige_db/ulydige_poll.swf
Here's the code:
var var_loader = new LoadVars();
var var_saver = new LoadVars();
var_loader.onLoad = function(success){
if (success){
var headline_array:Array = this.headline.split("~");
var sp1_array:Array = this.sp1.split("~");
var sp2_array:Array = this.sp2.split("~");
var sp3_array:Array = this.sp3.split("~");
var sp4_array:Array = this.sp4.split("~");
var sp5_array:Array = this.sp5.split("~");
var sp6_array:Array = this.sp6.split("~");
var sp7_array:Array = this.sp7.split("~");
var sv1_array:Array = this.sv1.split("~");
var sv2_array:Array = this.sv2.split("~");
var sv3_array:Array = this.sv3.split("~");
var sv4_array:Array = this.sv4.split("~");
var sv5_array:Array = this.sv5.split("~");
var sv6_array:Array = this.sv6.split("~");
var sv7_array:Array = this.sv7.split("~");
spørgsmål.sp1.text = headline_array[0];
spørgsmål.sv1_1.label = sp1_array[0];
spørgsmål.sv1_2.label = sp1_array[1];
spørgsmål.sp2.text = headline_array[1];
spørgsmål.sv2.dataProvider = sp2_array;
spørgsmål.sp3.text = headline_array[2];
spørgsmål.sv3.dataProvider = sp3_array;
spørgsmål.sp4.text = headline_array[3];
spørgsmål.sv4.dataProvider = sp4_array;
spørgsmål.sp5.text = headline_array[4];
spørgsmål.sv5.dataProvider = sp5_array;
spørgsmål.sp6.text = headline_array[5];
spørgsmål.sv6.dataProvider = sp6_array;
spørgsmål.sp7.text = headline_array[6];
spørgsmål.sv7.dataProvider = sp7_array;
spørgsmål._visible = true;}
else {
_parent.tekst.text = "data could not be read...";}}
var_loader.load("ulydige_poll.php");}
Sending Data With Loadvars To Php , Undefined
Hi,
I've looked around on the net and can't get an answer to my problem..
I need to send data from my flash to php.
here's the code from my flash file
on (press) {
dataSender = new LoadVars();
dataSender.nom = nom.text;
dataSender.prenom = prenom.text;
dataSender.email = email.text;
dataSender.send("../update.php","_self","POST");
trace( dataSender.toString() );
}
they come up undefined in my php file.
Also, when I load my swf with the url http://www.avocadotraiteur.com/fr/swf/intranet.swf the submit buton works, but when the swf is loaded through another swf when you click on submit nothings happens any idea?
Http://www.avocadotraiteur.com click on french then intranet in the bottom menu to see the difference
thank you so much in advance..
LoadVars = Success, But My Vars Are Undefined?
Hello all!
I've been working with LoadVars a lot recently and like it very much so. However, I have encountered a new problem. As always, I have searched through a bunch of threads to no avail; if this is a repeated question, please trout slap me and I'll apologize! Anywho -
I have this array that already works in my Flash project:
ActionScript Code:
angles = [0, 35, 100, 72, 72, 81];
Now I want to pull those numbers in the array from a changing PHP program. To start, I'm using a test file:
PHP Code:
&p1=0&p2=35&p3=100&p4=72&p5=72&p6=81
Then I have actions like this right before I need those pulled in:
ActionScript Code:
lv = new LoadVars();lv.onLoad = function(success){if(success){p1 = this.p1;p2 = this.p2;p3 = this.p3;p4 = this.p4;p5 = this.p5;p6 = this.p6;trace(p1); //returns a zero}}lv.load("myStupidTextFile.txt");trace(p1); //returns 'undefined'
How do I get those variables to register outside of the loadVars? There has to be a way, right??!!
LoadVars = Success, But My Vars Are Undefined?
Hello all!
I've been working with LoadVars a lot recently and like it very much so. However, I have encountered a new problem. As always, I have searched through a bunch of threads to no avail; if this is a repeated question, please trout slap me and I'll apologize! Anywho -
I have this array that already works in my Flash project:
ActionScript Code:
angles = [0, 35, 100, 72, 72, 81];
Now I want to pull those numbers in the array from a changing PHP program. To start, I'm using a test file:
PHP Code:
&p1=0&p2=35&p3=100&p4=72&p5=72&p6=81
Then I have actions like this right before I need those pulled in:
ActionScript Code:
lv = new LoadVars();lv.onLoad = function(success){if(success){p1 = this.p1;p2 = this.p2;p3 = this.p3;p4 = this.p4;p5 = this.p5;p6 = this.p6;trace(p1); //returns a zero}}lv.load("myStupidTextFile.txt");trace(p1); //returns 'undefined'
How do I get those variables to register outside of the loadVars? There has to be a way, right??!!
Slideshow Error 'undefined'
Can anyone tell me what I am doing wrong with this code... When I run it it keeps saying 'undefined'...
Code:
import com.mosesSupposes.fuse.*;
ZigoEngine.register(Fuse, PennerEasing);
for (i=1;i<11;i++) {
var tmpClip:MovieClip = eval ("Pic" + i)
tmpClip.loadMovie("images/"+i+".jpg")
}
// Start the slideshow on a setInterval
var slideShowTimer:Number = setInterval(nextImage, 5000);
var counter:Number = 0;
// The workhorse function, gets called by setInterval, and should run every 5 seconds.
function nextImage():Void {
var img:MovieClip = images[counter % 3];
img.swapDepths(counter);
trace(img.getDepth());
img._alpha = 0;
img._visible = true;
img.alphaTo(100, 2, "easeOutSine", null, {func:cleanUpPrevious, args:[(counter-1) % 3]});
counter++;
}
// A function to be used in the tween callback to make the image that was just covered up invisible.
function cleanUpPrevious(image:Number):Void {
images[image]._visible = false;
}
// Show first image immediately.
nextImage();
Problem Sending Variable With LoadVars.send (scope Perhaps?)
I think I'm probably missing something obvious, but I'd be very grateful for any assistance!
I currently have the following code in a movie clip:
var my_lv:LoadVars = new LoadVars();
my_lv.overall_score=_root.overall_score;
my_lv.send("score.php", "_blank", "GET");
(ultimately I'll want to send the variable without opening a popup window, just doing it this way for now so I can see what is -or is not!- going on)
The problem is that sending this variable results in undefined:
score.php?overall%5Fscore=undefined (URL loaded)
If on the other hand I use the AS code:
var my_lv:LoadVars = new LoadVars();
my_lv.overall_score="88888"; //arbitrary number
my_lv.send("score.php", "_blank", "GET");
it all works perfectly.
_root.overall_score is definitely defined in the movie, it's successfully displayed in a text box in the same frame as this code appears.
Hopefully someone can point me in the right direction!
Many thanks,
Andrew
Slideshow With FUse / Error 'undefined'
Hi,
Am just starting to get into both Flash and Fuse and wanted to create a small slideshow... But when I run it in the output window I get 'undefinied' if anyone has any ideas would be much appreciated!
Code:
import com.mosesSupposes.fuse.*;
ZigoEngine.register(Fuse, PennerEasing);
for (i=1;i<11;i++) {
var tmpClip:MovieClip = eval ("Pic" + i)
tmpClip.loadMovie("images/"+i+".jpg")
}
// Start the slideshow on a setInterval
var slideShowTimer:Number = setInterval(nextImage, 5000);
var counter:Number = 0;
// The workhorse function, gets called by setInterval, and should run every 5 seconds.
function nextImage():Void {
var img:MovieClip = images[counter % 3];
img.swapDepths(counter);
trace(img.getDepth());
img._alpha = 0;
img._visible = true;
img.alphaTo(100, 2, "easeOutSine", null, {func:cleanUpPrevious, args:[(counter-1) % 3]});
counter++;
}
// A function to be used in the tween callback to make the image that was just covered up invisible.
function cleanUpPrevious(image:Number):Void {
images[image]._visible = false;
}
// Show first image immediately.
nextImage();
Can't Exchange Values Of Variables. Trace Returns "undefined" ?
Hai,
I'm trying to pass the value of a variable in to another but tracing that value returns "undefined"
This is what i do:
1 Im loading the values from an external .txt file. in the .txt file it says...
&customer1=blahblah
2 A textfield in Flash with the var: value "customer1" shows the externally loaded value....blahblah. So this is good
3 When I try to pass the value "blahblah" to another variable it returns "undefined" ??
test = customer1;
Also tried:
test = eval(customer1);
I'm definitly doing something wrong here. can't be that hard?!?
Can somebody help me?
Thanks,
Marc
Can't Exchange Values Of Variables. Trace Returns "undefined" ?
Hai,
I'm trying to pass the value of a variable in to another but tracing that value returns "undefined"
This is what i do:
1 Im loading the values from an external .txt file. in the .txt file it says...
&customer1=blahblah
2 A textfield in Flash with the var: value "customer1" shows the externally loaded value....blahblah. So this is good
3 When I try to pass the value "blahblah" to another variable it returns "undefined" ??
test = customer1;
Also tried:
test = eval(customer1);
I'm definitly doing something wrong here. can't be that hard?!?
Can somebody help me?
Thanks,
Marc
Scope Issue
if i create an onLoad function for an MC in it's parent MC and call a function in the onLoad that exists in the child, how do I reference that funciton...here's the set up
two MC's: A, B
in A I write:
//
function init() {
foo()
}
B.onLoad = init;
in B I write:
//
function foo() {
trace("init");
}
since foos is defined in B, should I call it like so B.foo or as is?
tx
Is This A Scope Issue Or Something Else ?
Here is the setup:
On my timeline, I have a movie clip called item1_mc that contains a button. On the button inside this movie clip is the following code:
Code:
on (press)
{
_parent.itemDragged(_name);
}
on (release, releaseOutside)
{
_parent.itemDropped(_name);
}
On my timeline, I have a movie clip called target1_mc. On my timeline, I also have the following functions:
Code:
function itemDragged(itemClip)
{
//start drag of the itemClip in question
startDrag(itemClip, false);
}
function itemDropped(itemClip)
{
stopDrag();
//call checkDrop() function for current itemClip
checkDrop(itemClip);
}
function checkDrop(itemClip)
{
if (target1_mc.hitTest(itemClip))
{
trace("succesful drop");
}
}
WHY doesn't this work and trace succesful drop when I run my movie and drag and drop item1_mc onto target1_mc ???.
HOWEVER, it does work if I hard-code the checkDrop function like so:
Code:
function checkDrop(itemClip)
{
if (target1_mc.hitTest(item1_mc))
{
trace("succesful drop");
}
}
Can anyone please assist me here.
Thanks.
[F8] Scope Issue
I've build a Array (DataListArray) and want the Array elements be able to be accessed outside the function they where created in.
The only way I can get it to work is if i do everything within the parseXMLData function.
Can sombody please help?
Thanks!
Code:
//create a new XML object
var outputXml = new XML();
//create varible for xml file url (xml url needs to be on same server)
var outputXmlUrl:String = "xmlDocs/testData1.xml";
//ignore whitespace in the file
outputXml.ignoreWhite = true;
//load the xml file
outputXml.load(outputXmlUrl);
//call the parseXMLData function when the XML file is loaded
outputXml.onLoad = parseXMLData;
//make sure the data is loaded and usable
function parseXMLData(success:Boolean):Void {
if (success && this.status == 0) {
var DataListArray = new Array();
var DataListArray = this.firstChild.childNodes;
// populate Array ( every XML <data> Node is a new array element)
trace(DataListArray);
} else {
trace("Problem loading XML data");
trace("The error code is "+this.status);
}
}
// assign values to text fields
com2servTcp_txt = DataListArray[0].firstChild.firstChild.nodeValue;
com2servUpd_txt = DataListArray[1].firstChild.firstChild.nodeValue;
lineLat_txt = DataListArray[5].firstChild.firstChild.nodeValue;
lineJit_txt = DataListArray[6].firstChild.firstChild.nodeValue;
linePac_txt = DataListArray[7].firstChild.firstChild.nodeValue;
com2clTcp_txt = DataListArray[2].firstChild.firstChild.nodeValue;
com2clUpd_txt = DataListArray[3].firstChild.firstChild.nodeValue;
sipFirewall_txt = DataListArray[4].firstChild.firstChild.nodeValue;
** edit ** Please use [code] or [php] tags for displaying code.
[Q] AS2 And The Scope Issue...
I am sure this is a scope problem...
Let's say that I have these three lines of code in the main timeline... It creates three variable just fine...
ActionScript Code:
var aaa:String = "Some String";
var bbb:Number = 100;
var ccc:Boolean = true;
Now, I want to tidy up my codes abit more, so I am using a function to wrap those lines up...
ActionScript Code:
function init()
{
trace("Function init...");
var aaa:String = "Some String";
var bbb:Number = 100;
var ccc:Boolean = true;
}
init();
Well... The problem with that code is that 'var' creates the functions as a local variable to the init() function and is not accessible from any other function...
What I can do is to get rid of all the AS2 notations and create function like this, which I have been using all the time, but that defeats the purpose of using AS2...
ActionScript Code:
function init()
{
trace("Function init...");
aaa = "Some String";
bbb = 100;
ccc = true;
}
init();
So... What's the best way of doing all this in AS2??? (I am not working on the Class stuff on this...)
Scope Issue
Hi all,
I'm currently having difficulties passing a variable from within a function.
Let say i have the following in frame 1:
Code:
#include "pmpakContacts.as"
stop();
In the include file i have a function:
Code:
//handle server response
this.getContacts_Result = function(result)
{
if(result)
{
contact_user_details = result[0];
var totalHolderHeight = 0;
for (var j = 0; j<contact_user_details['pm_user_id'].length; j++) {
createEmptyMovieClip("holder", this.getNextHighestDepth());
contactDetails_mc = holder.attachMovie("dynamic_id", "newClip_mc"+j, j);
contactDetails_mc.user_id = contact_user_details['pm_user_id'][j]
contactDetails_mc._x = 0
contactDetails_mc._y = j*90
contactDetails_mc.full_name_txt.text = contact_user_details['pm_first_name'][j];
contactDetails_mc.email_txt.text = contact_user_details['pm_email'][j];
totalHolderHeight += contactDetails_mc._height+14;
}
trace(totalHolderHeight);
} // end result
}
Towards the end of the function if i trace the following:
Code:
trace(totalHolderHeight);
i successfully paas the accumlated value for totalHolderHeight.
Remembering that this is called from frame 1 how can i call/trace this variable back to frame 1. eg.
Code:
#include "pmpakContacts.as"
trace(totalHolderHeight);
stop();
Currently i'm getting undefined.
Cheers
|