Welcome, Guest. Please login or register.
Did you miss your activation email?
05/22/12, 18:05
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  General
| |-+  Flash 8 (Moderators: Jorge Solis, ..:: Mazhar Hasan ::.., Andresss)
| | |-+  How to load the swf file in php
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] 2 Print
Author Topic: How to load the swf file in php  (Read 2202 times)
cliffcc
Server what's that
*
Posts: 23


View Profile
« on: 12/12/10, 05:15 »

     I want to import the swf into php, beside using <embed> in html, any suggestions? I always update the content of swf, using the function <embed> has some problems.When i update the swf file. but html cannot be updated and refresh, still load the previous swf.file. Even i delete the swf.file. It still load the previous swf.file?
Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14600


View Profile
« Reply #1 on: 12/13/10, 06:36 »

This is because swf stay in browser cache. If you want to see the last version, just delete the cache. If you're in development stage, that's enought. If you think the swf itself will be changed in production, so users will suffer the same, then you probably should use an external preload that add randomnes to the load, something like this:

loadMovie("some.swf?"+Math.random*());

This force always to load new content, so the disavantage is that your swf takes some time to load allways

Jorge
Logged

cliffcc
Server what's that
*
Posts: 23


View Profile
« Reply #2 on: 12/13/10, 09:07 »

I want to use the preload fucntion, the code you suggest should be write into flash? How about html? I don't understand. Can you give me some example.
Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14600


View Profile
« Reply #3 on: 12/13/10, 09:27 »

Should be write into Flash ... i.e suppose I have a Main.swf, I use a preload.swf with this code (I ommit preload in sake of simplicity, but should be added)


holder = this.createEmptyMovieClip("holder", 1);
holder.loadMovie("Main.swf?"+Math.random());

This will force to load allways a new version of Main, and should be running in a server (locally gives you an error that Main.swf?0.4354354328437 doesn't exists)

Jorge
Logged

cliffcc
Server what's that
*
Posts: 23


View Profile
« Reply #4 on: 12/20/10, 20:06 »

I have try your method, it seem not work! Nothing can be loaded!
I give you the code, what is the error?

My second question is  "undefind" is shown in html, but not shown in swf?

php:



<?php

include("design/header4.php");


?>


<html>
<head>
<title> </title>
</head>

<body>
<object width="425" height="355">
<param name="movie" value="X.swf"></param>
<embed width="600" height="400" bgcolor="#000000" src="store/X/X.swf"</embed>

</object>

</body>

</html>


flash:

// here is a reference to this timeline
var here = this

// create an object to store the variables
varReceiver = new LoadVars();

// now the target path is to the server, because it's a php file
varReceiver.load("abc.txt");
// when the variables finish loading
//trigger something
varReceiver.onLoad = function() {
      
   // show some text in a text field
   // using the loaded variables
   createTextField("a_txt", 1, 130, 100, 5, 5);
   a_txt.autoSize = true;
   a_txt.border = true;
   a_txt.text = this.text1;
   
   createTextField("b_txt",2,210,100,5,5);
   b_txt.autoSize = true;
   b_txt.border = true;
   b_txt.text = this.text2;
   
   createTextField("c_txt", 3, 290, 100, 5, 5);
   c_txt.autoSize = true;
   c_txt.border = true;
   c_txt.text = this.text3;
   
      
   createTextField("d_txt", 4, 370, 100, 5, 5);
   d_txt.autoSize = true;
   d_txt.border = true;
   d_txt.text = this.text4;
      
   createTextField("e_txt", 5, 130, 226, 5, 5);
   e_txt.autoSize = true;
   e_txt.border = true;
   e_txt.text = this.text5;
      
   createTextField("f_txt", 6, 210, 226, 5, 5);
   f_txt.autoSize = true;
   f_txt.border = true;
   f_txt.text = this.text6;
      
   createTextField("g_txt", 7, 290, 226, 5, 5);
   g_txt.autoSize = true;
   g_txt.border = true;
   g_txt.text = this.text7;
      
   createTextField("h_txt", 8, 370, 226, 5, 5);
   h_txt.autoSize = true;
   h_txt.border = true;
   h_txt.text = this.text8;
      
   createTextField("i_txt", 9, 130, 325, 5, 5);
   i_txt.autoSize = true;
   i_txt.border = true;
   i_txt.text = this.text9;
      
   createTextField("j_txt", 10, 210, 325, 5, 5);
   j_txt.autoSize = true;
   j_txt.border = true;
   j_txt.text = this.text10;
   
   createTextField("k_txt", 11, 290, 325, 5, 5);
   k_txt.autoSize = true;
   k_txt.border = true;
   k_txt.text = this.text11;
   
   createTextField("l_txt", 12, 370, 325, 5, 5);
   l_txt.autoSize = true;
   l_txt.border = true;
   l_txt.text = this.text12;
         
};


//Create LoadVars object and load file
myData = new LoadVars()
//myData.load("anastasio.asp") //asp line
myData.load("pic.txt") //php line
myData.ref = this
//Fetch data
myData.onLoad = function(succes){
   if(succes){
      for(var i=1; i<this.cant; i++){
         this.ref["holder_mc"+i].loadMovie(this["Image"+i])

      }
   } else trace("Error loading data")
}

stop()

setInterval(b1_buttonpress, 0.1 * 1000);

//settings
var speed:Number = 1;

// sizeWindow(target movieclip, new width, new height)
function sizeWindow(target:MovieClip, newW:Number, newH:Number):Void
{
   //save inputed data on the target clip
   target.endX = newW;
   target.endY = newH;
   target.speed = speed;
   
   //add onEnterFrame to the target movieclip to do our task over and over
   target.onEnterFrame = function() {
      //calculate new width:
      //end width - current width * speed
      this._width += (this.endX-this._width)*this.speed;
      this._height += (this.endY-this._height)*this.speed;
      
      //check if resizing finished
      if (Math.floor(this._width) == Math.floor(this.endX))
      {
         //done resizing, delete onEnterFrame to speed up performance
         delete this.onEnterFrame;
      }
   };
}
//temporary buttons
b1.onRelease =b1_buttonpress;

function b1_buttonpress(){
    sizeWindow(holder_mc1, 55,60);
   sizeWindow(holder_mc2, 55,60);
   sizeWindow(holder_mc3, 55,60);
   sizeWindow(holder_mc4, 55,60);
   sizeWindow(holder_mc5, 55,60);
   sizeWindow(holder_mc6, 55,60);
   sizeWindow(holder_mc7, 55,60);
   sizeWindow(holder_mc8, 55,60);
   sizeWindow(holder_mc9, 55,60);
   sizeWindow(holder_mc10, 55,60);
   sizeWindow(holder_mc11, 55,60);
   sizeWindow(holder_mc12, 55,60);
}


« Last Edit: 12/20/10, 20:21 by cliffcc » Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6175


View Profile WWW Email
« Reply #5 on: 12/21/10, 01:43 »

is it possible zou are not calling the html via server, but rather from file system?

Even if the html file is located on your computer, you have to use http://localhost... to display its contents.

HTML-fiel and SWF-File have to reside at the same domain.
Logged

happy flashing
Cool
Ronald
cliffcc
Server what's that
*
Posts: 23


View Profile
« Reply #6 on: 12/21/10, 08:56 »

I dun understand. I think it is the problem of code? (I have successfully load it before,but now not  work!                                                                                                                      


Since i have tried to save as html file and then loaded in the desktop, it generated the same result as i run in php!  Huh     But i still want to run those code in server!!! Anyone can help me?     
Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6175


View Profile WWW Email
« Reply #7 on: 12/21/10, 09:15 »

If you call the php file, what do you get?

Sorry, i confused you.
I did not mean you to change the file sufix.
php is just generating html - so i've been talking about html.

But, if you run this stuff on you local computer, what I assume, you cannot open the php file out of the filesystem.

Supposing you are running a php capable server (like apache, or IIS with php extension) you have to open the file via http://localhost/path to File/filename.php

Otherwise the php will not be executed.
« Last Edit: 12/21/10, 09:19 by Ronald Wernecke » Logged

happy flashing
Cool
Ronald
cliffcc
Server what's that
*
Posts: 23


View Profile
« Reply #8 on: 12/22/10, 06:39 »

Yes. Of course, i load the php via the server by using  http://localhost/........!   The question is i cannot load the swf successfully!
Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6175


View Profile WWW Email
« Reply #9 on: 12/22/10, 07:14 »

what error message do you receive?
did you use charles to analyze the communication?
are you sure about the path?
« Last Edit: 12/22/10, 07:15 by Ronald Wernecke » Logged

happy flashing
Cool
Ronald
cliffcc
Server what's that
*
Posts: 23


View Profile
« Reply #10 on: 12/22/10, 08:32 »

I try this path (http://localhost/store/X/X.swf), loaded sccessfully. The texts and pictures in swf can be all shown.

But I try this path (http://localhost/X.php) which embed the X.swf, the texts are shown as "undefined", there are no pictures shown! Any idea!  Thanks!
Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6175


View Profile WWW Email
« Reply #11 on: 12/22/10, 09:54 »

the problem seams to be in the path, how how you address it.

If you address the swf file relativly, it should look like "./store/X/X.swf" inside of the generated html code in your php file.

to be on the save side, you can embed this: "http://localhost/store/X/X.swf"
Logged

happy flashing
Cool
Ronald
cliffcc
Server what's that
*
Posts: 23


View Profile
« Reply #12 on: 12/23/10, 08:32 »

Thanks!  I have tried all method, the problem still exist!  Huh
Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6175


View Profile WWW Email
« Reply #13 on: 12/23/10, 09:02 »

Did you start charles?
What does charles report?
I the machine, you are running it on, based on windows?
Logged

happy flashing
Cool
Ronald
cliffcc
Server what's that
*
Posts: 23


View Profile
« Reply #14 on: 12/23/10, 09:30 »

sorry  i don't know what is charles?
Logged
Pages: [1] 2 Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!