


| category | articles | ||||
|
Adsense Adwords Article Blog CMS CSS Style Datacenter Design Graphics Flash Animation Internet Radio Messenger Programming Provider Search Engine Security Security Web SEF SEO Software Software Web |
Load Images In Flash From PHP This knowledges was getting from http://www.scriptplayground.com First, you have to download this file to make you quick to learn http://www.scriptplayground.com/article_files/Load-Images-In-Flash-From-PHP/loadImagesIntoFlash.zip Open the Actions Panel F9 and we will begin going through the code used in this example. You will first see a block of code and then it will be explained. function loadImage(id:Number) { This function will load in image, taking an id as an argument. We need to setup 2 loadVars objects. One to load the PHP and another to trap the result from the PHP. Next we have an onLoad function that is called when the PHP file is successfully loaded (this example does not account for errors). Inside this function is where you will find our loadClip() method which we will explain a little later on. Finally we have our sendAndLoad which calls the PHP, passes in the path and the object to store the response. var loadButtons:Array = new Array('loadBtn1','loadBtn2','loadBtn3','loadBtn4','loadBtn5','loadBtn6'); Most of that is straightforward. We have our array of buttons that we dragged to the stage. An empty movieclip where our loaded image will end up. Then we have 3 variables containing the site path, image path and php path. var mcLoader:MovieClipLoader = new MovieClipLoader(); Next we initialize a new MovieClipLoader and assign our listeners, so let's get started. mcLoadObj is an object that we attach our listener methods to. onLoadInit is called once the image is loaded and visible. addListener accepts one argument which is the object we used to attach our methods to. Finally for visual purposes we nudge the empty clip 10 pixels on both the X and Y axis. function loadInit(target:MovieClip) { A simple function that you can use to preform tasks now that the image is loaded. function assignButtons() { This function is semi-advanced and is only used to simplify the proces of assigning rollover, rollout and click events to our buttons. Basically it is an open-ended loop that runs through the loadButtons array and assigns our events as described a second ago. The loadImage function is called within the onRelease function to start the process of loading an image. assignButtons(); The last step on the Flash side is the magic line that calls the button assignment function. Next up, PHP Code Now that we have the Flash portion squared away let's move onto the PHP code. <?php This part is simple in the example, but you really should add a lot more security for a live application. We first grab the id from the url using the super variable $_GET. Then we assign a list of images that will match an id. The last step is to send back the image name to Flash from our image array by referencing the id we passed in. That is basically it for this tutorial. You should now have a fully working image loader that is getting the image name from a PHP file. Here is a live example use for loading images that I created. It takes this tutorial to a completely new level with dynamic reflections, multiple images and all input for the user to load in their own image. OTHER ARTICLES |
||||
| © 2001 - 2010 Tatamedia Solusindo | Link Partner: akomodasi.net, indoproduk.com, satria.com, idee-online.net, gptkk.org, maniak belanja, hotels68 | |||||