note 85573 added to class.swfaction
| From: | jon at nux dot co dot uk | Date: | Sat, 06 Sep 2008 16:26:26 +0000 |
| Subject: | note 85573 added to class.swfaction | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-144192@lists.php.net to get a copy of this message | ||
A little story that may help some others - part 1
Upgrading from:
I have used ming for several years now for injecting variables into flash, usually for menus. In a
recent move to a new server all the ming/php stopped working. Ming was working and properly
installed but the variables just weren't apparent within the flash movie.
The old server is running:
ming-0.2a_1 LGPL'ed Flash 4/5 movie output library with many languages
php4-ming-4.4.1_1 The ming shared extension for php
The new one is running:
ming-0.3.0_3 LGPL'ed Flash 4/5 movie output library with many languages
php5-ming-5.2.6_1 The ming shared extension for php
So the way I have always done this is to put all my data together in php, and then put it into an
array/variable in Flash. I then create a movie clip and load my movie.swf (made by hand in flash)
into the movieclip.
I know there are now cleaner ways of getting data loaded into Flash (even directly from Flash
without ming) but as I have many many movies out there using ming it is far easier to change a few
lines of php to get them working again than change every flash movie.
So anyhow, here is the code:
<?php
$m = new SWFMovie();
$m->setRate(30.000000);
$m->setDimension(480, 400);
$m->setBackground(0xff, 0xff, 0xff);
$m->add(new SWFAction('
myvar = "variable to pass to flash";
LoadMovie("/flash_file_created_by_hand.swf", "mc");
');
/* -- make movie clip 'mc' that we will load flash_file_created_by_hand.swf into -- */
$s1 = new SWFSprite(); /* (1 frames) */
$s1->nextFrame(); /* (end of sprite frame 0) */
$i1 = $m->add($s1);
$i1->setName('mc');
$m->nextFrame(); /* (end of frame 0) */
header('Content-type: application/x-shockwave-flash');
$m->output();
?>
So what stopped working. Well this took me a while to work out, and even know I am not 100% sure but
I can tell you what does work and how I got there.
Firstly I needed some more debugging, and so installing the flash debug player http://www.adobe.com/support/flashplayer/downloads.html
and 'Flash Tracer' https://addons.mozilla.org/en-US/firefox/addon/3469
enabled me to see trace output of the ming movie and my loaded movie
(flash_file_created_by_hand.swf). If you don't already know then this is worth knowing about.
I had to play around a bit to get the debug player to write its log file, but it is worth it.
Make sure you have the write settings when you publish your movie otherwise you will not be able to
see the trace output.
So now I can see trace... well I used to this run a few checks to see for instance if the movie clip
was there :
$s1->add(new SWFAction('
trace ("location of movie clip is: " + this._target);
');
and so I played around.. and I could see that the movie clip 'mc' was being created and
that the movie flash_file_created_by_hand.swf was being loaded into it but well not much else. So I
still coudn't see what was happening to the data. I currently suspect that the loadMovie was
loading the movie into level0 or _root rather than into /mc (_root.mc) as thus wiping out the ming
vabiables.. but I can't be sure. Given that the trace of the target etc happens before the
loadmovie function I think this is entirely possible.
Anyhow, I thought I may aswell try to do this a differt way.. that is create the movieclip from
actionsript rather than with php/ming.. ie:
$m->add(new SWFAction('
this.createEmptyMovieClip("mc", 999);
');
instead of:
/* -- make movie clip 'mc' that we will load flash_file_created_by_hand.swf into -- */
$s1 = new SWFSprite(); /* (1 frames) */
$s1->nextFrame(); /* (end of sprite frame 0) */
$i1 = $m->add($s1);
$i1->setName('mc');
$m->nextFrame(); /* (end of frame 0) */
----
Server IP: 87.124.35.190
Probable Submitter: 84.92.194.66
----
Manual Page -- http://www.php.net/manual/en/class.swfaction.php
Edit -- https://master.php.net/note/edit/85573
Del: integrated -- https://master.php.net/note/delete/85573/integrated
Del: useless -- https://master.php.net/note/delete/85573/useless
Del: bad code -- https://master.php.net/note/delete/85573/bad+code
Del: spam -- https://master.php.net/note/delete/85573/spam
Del: non-english -- https://master.php.net/note/delete/85573/non-english
Del: in docs -- https://master.php.net/note/delete/85573/in+docs
Del: other reasons-- https://master.php.net/note/delete/85573
Reject -- https://master.php.net/note/reject/85573
Search -- https://master.php.net/manage/user-notes.php