PHPJavascript

Web Development Guide – My Personal Library of Tutorials and Scripts

Dynamic Flash PHP – External file, images and scrollbar

August12

Download the working script.

Dynamic flash website with PHP to extract external data for text and images with Flash MX scrollbar.

I mostly get to develop sites with a lil of flash probably in the header++. The reasons being complete flash websites are not good for ranking, at times slow and there is a long debate on the topic. But the reason I try to avoid flash websites is because my flash, actionscript knowledge is real basic and the thought of creating dynamic flash websites with php and mysql sort of scares me. I mean I am great with PHP, MySQL but flash….

However, I recently am developing a tribute website for His Highness General Sheikh Mohammed, the Ruler of Dubai (which is such a big honor).   Now imagine such a big personality, can I make a website which has good functionality and ranking but a so so design. You know how flash makes the world look so beautiful, so I needed my website to look equally beautiful with all those attractive animations++ cuz come on imagine The Ruler of Dubai.

So I said I had to integrate flash with PHP and hence I created a new category “Flash” on my website. As I want my visitors to get the knowledge I would be gaining from this experience.

Flash Interface

At the moment I have my flash design from my designer (good but hectic to get a design out of him). Now I have to integrate the data. In this particular page I have two columns one for images and the other for text, and both the images and text are coming from an external file with a scrollbar.

(I know it looks a lil ugly, don’t worry my designer is gonna brush it up later with those cool animations and yeh yeh I know the white color background for the scrollbar that is the next issue I have to tackle)

dSo basically on the stage you�make three dynamic textboxes(100×60) on the left side and three on the right side (244×60). Name the three left boxes as img1, img2, img3 respectively and the right boxes txt1, txt2, txt3 respectively…. (If you get lost somewhere like don’t know how to name the boxes ++ please download the fla file attached with this webpage). And yeh make sure all the textboxes are ‘Multiline’.

Now select ‘frame1′ from timeline and press F9.

Copy Paste the following code:

loadText = new LoadVars();
loadText.load(”http://localhost/flash/ach.php”);
loadText.onLoad = function() {
img1.html=true;
txt1.html=true;
img2.html=true;
txt2.html=true;
img3.html=true;
txt3.html=true;

img1.htmlText = this.img1;
txt1.htmlText=this.txt1;
img2.htmlText = this.img2;
txt2.htmlText=this.txt2;
img3.htmlText = this.img3;
txt3.htmlText=this.txt3;

};

Note:

  • http://localhost/flash/ach.php is the actual path of the PHP file which will be created in the next step. So please make sure you type in the exact path of your php file.
  • img1.html=true; this statement enables html tags for the dynamic textbox “img1″. So now in the these textboxes you can add html formatting like <img>, <b>..
  • img1.htmlText=this.img1; this statement extracts the content of the “img1″ from the external file ach.php variable “img1″

Select all the textboxes convert into “symbol”=movieclip, name it “page1″ and tick on “linkage” – “Export for Actionscript”.

Delete this movieclip from the stage, remember it exists in the library.

PHP External File

Assuming you have PHP installed and running on your local webserver, if not click here to learn how to install PHP.

Open a new file in dreamweaver, notepad ++ copy paste the following code:

<?
print "&img1=<img src='dsf.jpg' />&txt1=<font color='#F0D24F'>Dubai Summer Festival</font> <br>The Festival was shaped under the committed leadership of His Highness General Sheikh Mohammed bin Rashid Al Maktoum.&img2=<img src='burjalarab1.jpg' />&txt2=<font color='#F0D24F'>Burj Al Arab</font> <br>The Tower of the Arabs is Sheikh Mohammed's boldest projects. The world's tallest hotel symbolizing Dubai's rapid growth.&img3=<img src='palm.jpg' />&txt3=<font color='#F0D24F'>Palm Island</font> <br>The most stunning project commissioned under Sheikh Mohammed. Three artificial islands in the shape of palm trees astonishing our minds.";
?>

and save as “ach.php”

Note:

  • Make sure not to have any spaces in between the code.
  • & is used to declare one variables after another
  • “img1″, “txt1″…. declaring the values for the variables in flash file

Add Scrollbar

Obviously I will be having more than three entries, due to which I need a scrollbar. We will use Flash MX build in scrollbar.

Go to “window” – “components” – drag and drop “scrollpane”

Scrollpane Settings

  • Scroll content: page1
  • Horizontal scroll: false
  • Vertical scroll: true

Cntl + Enter = Should work

If it is not working download the original fla file and compare it with yours to find any errors. And last but not the least if the scrollbar is giving problems just copy paste the scrollbar from library of the original fla.

posted under Flash, PHP

Email will not be published

Website example

Your Comment:

 

12,831 spam comments
blocked by
Akismet