sendAndLoad don't work

  • ufcio
  • Newbie
  • Newbie
  • ufcio
  • Posts: 6

Post 3+ Months Ago

Hi, I've got problem with my action script. It should load data from php but it doesn't and i have no idea why.

My PHP file produce in output:
Code: [ Select ]
&min=img/photo.jpg&dsc=photo&pth=img/photo.jpg&typ=file&


And I create in flash movie with code like this

Code: [ Select ]
dsc = 0;
min = 0;
pth = 0;
typ = 0;
var myVars = new loadVars();
myVars.action = "get_box";
myVars.onLoad = load_1_done;
myVars.sendAndLoad("content.php", myVars, "POST");
function load_1_done(result)
{
    if(result)
    {
        dsc = myVars.dsc;
        min = myVars.min;
        pth = myVars.pth;
        typ = myVars.typ;
    }
    else
    {
        dsc = "error";
        min = "error";
        pth = "error";
        typ = "error";
    }
};
stop();
  1. dsc = 0;
  2. min = 0;
  3. pth = 0;
  4. typ = 0;
  5. var myVars = new loadVars();
  6. myVars.action = "get_box";
  7. myVars.onLoad = load_1_done;
  8. myVars.sendAndLoad("content.php", myVars, "POST");
  9. function load_1_done(result)
  10. {
  11.     if(result)
  12.     {
  13.         dsc = myVars.dsc;
  14.         min = myVars.min;
  15.         pth = myVars.pth;
  16.         typ = myVars.typ;
  17.     }
  18.     else
  19.     {
  20.         dsc = "error";
  21.         min = "error";
  22.         pth = "error";
  23.         typ = "error";
  24.     }
  25. };
  26. stop();


my variables dcs, min, pth and typ are displayed on screen all the time to check them out.

When i execute it i have zeros and then noting. When i run it in debug mode the variables are zeros and then loaded stuff shows up. I test it with full server path to content.php and no changes.

Read tons of manuals and forum posts about this but still have no idea whats wrong.
  • ufcio
  • Newbie
  • Newbie
  • ufcio
  • Posts: 6

Post 3+ Months Ago

Maybe that happens because it is placed in MC, problay if i put it onto top level movie it should work... but why it dont want to work in MC ?
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

Personally I use two loadVars() objects for sendAndLoad(), one for sending variables and one for reply variables. This is the first time i've seen anyone try to reuse the same object.

At first glance one reason your actions don't work could be that there is no place stated in myVars for the reply data.

try this,
Quote:
/* textbox variables */
dsc = 0;
min = 0;
pth = 0;
typ = 0;

/* object to store variables being sent */
myVars = new loadVars();
myVars.action = "get_box";
myVars.onLoad = load_1_done;

/* object to store variables being returned to flash */
returnVars = new LoadVars();
returnVars.dsc = "";
returnVars.min = "";
returnVars.pth = "";
returnVars.typ = "";

/* function to handle return of variables */
function load_1_done(result)
{
if(result)
{
dsc = returnVars.dsc;
min = returnVars.min;
pth = returnVars.pth;
typ = returnVars.typ;
}
else
{
dsc = "error";
min = "error";
pth = "error";
typ = "error";
}
};

/* sendAndLoad */
myVars.sendAndLoad("content.php", returnVars, "POST");
  • ufcio
  • Newbie
  • Newbie
  • ufcio
  • Posts: 6

Post 3+ Months Ago

Okey I checked it out.

It work when i changed in your code:
Code: [ Select ]
myVars.onLoad = load_1_done;

to:
Code: [ Select ]
returnVars.onLoad = load_1_done;


But there is still problem of other kind:
I have main movie that loads subsite movie with
Code: [ Select ]
unloadMovie("_root.dropsite");
loadMovie(what, "_root.dropsite");
  1. unloadMovie("_root.dropsite");
  2. loadMovie(what, "_root.dropsite");

The movie loads fine, after preloader movie starts to do its action
and then it try to use sendAndLoad in the same way how we done it and it works. Now it doesn't work. data is posted, no error returned, recieved vars are always zeros.

Can I use variable loading from php in movies that are loaded by another movies ?
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

[quote="ufcio"]Okey I checked it out.

It work when i changed in your code:
Code: [ Select ]
myVars.onLoad = load_1_done;

to:
Code: [ Select ]
returnVars.onLoad = load_1_done;


:oops:

As for the new problem, try wrapping the sendAndLoad() inside a function that gets called only after the movie has loaded completely.
  • ufcio
  • Newbie
  • Newbie
  • ufcio
  • Posts: 6

Post 3+ Months Ago

I know, it is loaded completely. So what's the point ?! :roll:
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

:scratchhead: ok, lets try it this way.

Can you post a link to your fla ? (assuming it's MX & NOT 2004)
  • ufcio
  • Newbie
  • Newbie
  • ufcio
  • Posts: 6

Post 3+ Months Ago

ok,

so here is the website i work on:
http://hires.net-kom.com.pl

and here you can download all site content:
http://hires.net-kom.com.pl/for_u/ready_site.zip

and the fla sources:
http://hires.net-kom.com.pl/for_u/fla_source.zip

you have such files:
- index.php - site index
- content.php - work with variables from/to movies
- swf <dir> - all swfs there
- img <dir> - all images there

ok, site is for one artist and it starts from site.swf
the menu shows up and then you can chose:
- info (info.swf) - some info loaded from php - works fine
- anim (anim.swf) - check above at *)
- photo (photo.swf) - same as anim but works on other path
- still (still.swf) - same as anim but works on other path
- mail (mail.sqf) - finished - just e-mail address

*) anim is most complicated of all that stuff. It should work as a browser for graphics that somebody will put in from administration panel. It works like this:
1) preload itself
2) show up background
3) set vars
4) send/upload data how many sites will be avilable
and show arrows for browsing
4b) there are 21 small boxes and each one sends (curent dir, type of work, site number, etc...) and loads from php data based on it, those can be folders or works, loads texts, urls and small photos.

anim works just fine when you load only this movie by (check at):
http://hires.net-kom.com.pl/test.php

but when it is loaded by site.swf it doesn't work.
:(
  • rynoe
  • Banned
  • Banned
  • User avatar
  • Posts: 17

Post 3+ Months Ago

You should use xml for this.
  • nicothezulu
  • Born
  • Born
  • User avatar
  • Posts: 2

Post 3+ Months Ago

Yepp, if anyone have this problem....
When the php script is not on same domain, you should use crossdomain.xml on that site.

Example for that xml:

<cross-domain-policy>
<allow-access-from domain="*"/>
</cross-domain-policy>



I have the same problem, and i am working on this solution. I will reply here if this works.
  • nicothezulu
  • Born
  • Born
  • User avatar
  • Posts: 2

Post 3+ Months Ago

Yes, thats the solution :)

Post Information

  • Total Posts in this topic: 11 posts
  • Users browsing this forum: No registered users and 5 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.