Make your suggestion for the next Flash!

Hi, this message is for all Flash Users.
We’re collecting feedbacks and improvements, to turn subsequently to
Macromedia Flash Team, in order to obtain a wished list from who like you
use the program.
This operation has the sole scope to improve the development flash
enviroment and to adapt the software more to the requirements of the
customers.
You can propose new functionalities and improvements on those already
existing, trying to concentrate on aspects not too much general but on
detailed features lists that in your opinion lack or that you found
low-efficient for your daily job.

All messages should be sent to: flashwishlist@riadev.com

For example, some my suggestions:
– Improvements with XPath functionallity
– Regular expression implementation
– Make components smaller!
– Make a REAL try/catch implementation, expecially for runtime env

Strange issue with Flash Updater 7.2

I got this very strange behavior (let me say BUG) with the new flash updated version 7.2, and which drove me crazy for a while!

Create a new document, settings set to flash player 7 and AS2.
Create in the document a movieclip with exporting settings, export for ActionScript, and give the name “mc”. Delete the movieclip from the timeline.
try the code:

depth = _root.getNextHighestDepth()
trace(depth);
_root.attachMovie('mc','mc',depth)
mc.onRelease = function(){
this.removeMovieClip();
}

you will get a “0” in the trace output and once click on the movieclip, this will disappear.

NOW.
Drag a component on the stage, for example the tree component, and then delete it from the timeline. This is just in order to have it into the library.
Test the movie again.

I get in the trace output the value of “1048576” and the movieclip does not disappear now!

incredible!

XP Service Pack 2 and Flash…

Microsoft is introducing new Service Pack 2 for Windows XP users. ( more info at microsoft page )

This update should increase Internet Explorer’s security features. Also Macromedia seems have worked to support changes will arrive with this new service pack and provide a page with some FAQ about issue could happens after SP2 has been installed.
for example:
Flash Player content does not appear after a Windows Update
SWF files prompt a message when played back locally

read all the informations at http://www.macromedia.com/support/service/servicepack2.html

Flash Updater 7.2 available now!

Flash 7.2Version 7.2 of Macromedia Flash MX 2004 and Flash MX Professional 2004 is now available with improvements in performance, stability and documentation.

What’s changed?
* Faster initial launch time
* Compile times up to twice as fast
* More than 400 additional code examples
* Additional documentation on working with components
* Over 100 bug fixes. Read the details in the release notes.

The updater is available for the English version of Flash only, it seems others language we have to wait till end of summer.

Also a new class has been added: mx.utils.Delegate
and here a sample of usage:

import mx.utils.Delegate;
myDataGrid.addEventListener("change",Delegate.create(this,onMyDataGridChange));
myComboBox.addEventListener("change",Delegate.create(this,onMyComboBoxChange));
function onMyDataGridChange(eventObj:Object):Void{	trace("myDataGrid change event fired");}

function onMyComboBoxChange(eventObj:Object):Void{	trace("myComboBox change event fired");}

Flash remoting for python

Yesterday I received an email form Vsevolod ILyushchenko announcing me the alpha version of Flash remoting for python!
http://simonf.com/amfpython/. There are also many examples here: http://simonf.com/amfpython/code.html

Second update: Serializer Class 2.1
There is a bug fixing with in special chars lenght, thanks to Rainer Becker. The new mxp file is available on the sourceforge site.

Last thing. I’ve just uploaded an example which Daniel Tavelli send me.
An example of Xpath usage in flash mx 2004 using the xfactorstudio xpath class for ActionScript

PEAR::SWF updating… read and modify swf with PHP

I’ve just begun to modify the old PHP class flashHeader. Now using the PEAR::File class for a better file I/O processes.
Basically now, other than returning all the main information from an swf file, such as the bg color, framerate, player version, compression, protection used, movie size.., it allows to modify some of those parameters.
For example it can change the framerate, background, protection… I’m also working in order to allows the class modify some other swf tags in runtime..
Working example

Here the source file

<?php
// include the PEAR package
require “File/File_SWF.php”;
$flash = new SWF(“source.swf”);
if(
$flash->is_valid()){
$stat = $flash->stat(); // this give all the info
// and also..
$fps = $flash->getFrameRate();
$size = $flash->getMovieSize();
$bg = $flash->getBackgroundColor();
$prot = $flash->getProtected();
$compr = $flash->getCompression();
$version = $flash->getVersion();

// they can be changed…
$flash->setFrameRate(60);
$flash->setProtected(1);
$flash->setBackgroundColor(51,51,204);
$flash->setCompression(1);

// and write a new file…
$flash->write(“./new_one.swf”,1);
}
?>

Ho to get bytesTotal from a dynamic generated content in PHP

Think you want to load from Flash some dynamically generated images from PHP (maybe using GD..), or also some else dynamic content..
Think at this simple code:

/**** MovieClip Loader listener ****/
loaderListener = {
	onLoadStart : function(){
		trace('load started!');
		trace(" ----------------------------------- ")
	},
	onLoadProgress : function(target, bLoaded, bTotal){
		trace(bLoaded + "/" + bTotal)
	},
	onLoadComplete : function(target){
		trace(" ----------------------------------- ")
		trace("complete: " + target.getBytesTotal());
		trace(" ----------------------------------- ")
	}
}

// I just add the rand variable to prevent caching...
movie_path = "http://local/ob_start.php?file=C:/DSCF0182.JPG&rand=" + new Date().getTime()
var mcLoader = new MovieClipLoader()
mcLoader.loadClip(movie_path, loader)
mcLoader.addListener( loaderListener )

Now, if your PHP code is written in this way (just a image copy and resize using the GD 2.x library):


<?php
// Get the required image from GET
$image = $_GET['file'];$size = getimagesize($image);
// create an empty image and copy the original
$dst_img = imagecreatetruecolor($size[0]/4, $size[1]/4);
$src_img = imagecreatefromjpeg($image);
// resize image
imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, $size[0]/4, $size[1]/4, $size[0], $size[1]);
// start output content
header("Content-type: image/jpeg");
// display the image
imagejpeg($dst_img, "", 80);
?>

You will be noticed that the bytesTotal variable in flash is always ‘0’!
This could be a problem if you want to use any kind of graphic preloader for this such of things…
However with some little more code it’s always possible to get in flash (and not only from flash) the exact content bytes lenght.
Try now this:

<?php
// Turn on output buffering
ob_start();
// Get the required image from GET
$image = $_GET['file'];
$size = getimagesize($image);
// create an empty image and copy the original
$dst_img = imagecreatetruecolor($size[0]/4, $size[1]/4);
$src_img = imagecreatefromjpeg($image);
// resize image
imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, $size[0]/4, $size[1]/4, $size[0], $size[1]);
// start output content
header("Content-type: image/jpeg");
// display the image
imagejpeg($dst_img, "", 80);
// send the content lenght to output
header("Content-Length: ". ob_get_length());
// flush the output
ob_end_flush();
?>

wxPython and Flash, first test


Today I make the first test integrating a Flash movie into a python application and using a communication between the two applications using FSCommand and the flashvars.
The result (surprendent easy) it’s a simple movie which enables text files saving in the local computer (through a prompt dialog window), but it has already opened my mind to future real cool applications 😉

This is the python code, the core part it’s the “wx.lib.flashwin” import, which enable to use Flash ActiveX in a python frame

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import wx, sys, os
import string, codecs
from wx.lib.flashwin import FlashWindow
from wx.lib.flashwin import EVT_FSCommand
#----------------------------------------

class TestPanel(wx.Panel):
    def __init__(self, parent, base, swf):
        wx.Panel.__init__(self, parent, -1)
        self.base = base
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.flash = FlashWindow(self, style=wx.SUNKEN_BORDER)   
        dlg = wx.MessageDialog(self, "This will work only under Windows!","Warning!",wx.OK | wx.ICON_INFORMATION)
        dlg.Center()
        dlg.ShowModal()        
        wx.BeginBusyCursor()
        try:
            self.flash.LoadMovie(0, swf)
        except:
            wx.MessageDialog(self, "could not load the swf file","Error",wx.OK | wx.ICON_ERROR).ShowModal()
            sys.exit(2)
        wx.EndBusyCursor()        
        self.flash.Stop()      
        self.flash.SetSize((self.flash.GetSize()[0],self.flash.GetSize()[1]))
        # sizer
        sizer.Add(self.flash, 1, wx.EXPAND)
        self.SetSizer(sizer)
        self.SetAutoLayout(True)
        sizer.Fit(self)
        sizer.SetSizeHints(self)        
        self.SetFlashOptions()
        self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy)
        self.Bind(EVT_FSCommand, self.CallMethod)
        
    def SetFlashOptions(self):
        self.flash.menu = False
        self.flash._set_FlashVars("data=Server started on " + sys.platform)
        self.flash.Play()
        
    def OnDestroy(self, evt):
        if self.flash:
            self.flash.Cleanup()
            self.flash = None

    # Called from Flash FSCommand
    def CallMethod(self, evt):
        try:
            arguments = string.split(evt.args,"###")
            filename = arguments[0]
            body = arguments[1]
            if filename == "" or body == "":
                wx.MessageDialog(self, "Please check data inserted", "An Error occurred", wx.OK | wx.ICON_INFORMATION).ShowModal()
            else:
                dlg = wx.FileDialog(self, "Save as..." , os.getcwd(), filename, "*.*", wx.SAVE | wx.OVERWRITE_PROMPT )
                if dlg.ShowModal() == wx.ID_OK:
                    try:
                        f = codecs.open(os.path.normpath(dlg.GetPath()), "w", "utf-8", "ignore")
                        f.write(codecs.utf_8_decode(codecs.BOM_UTF8)[0])
                        f.write(body)
                        f.close()
                        self.flash._set_FlashVars("data=Succesfully saved text file")
                    except:
                        wx.MessageDialog(self, "%s %s %s" % sys.exc_info(), "An Error occurred", wx.OK | wx.ICON_ERROR).ShowModal()
                        self.flash._set_FlashVars("data=%s %s %s" % sys.exc_info())
        except:
            wx.MessageDialog(self, "Please check data inserted","An Error occurred",wx.OK | wx.ICON_INFORMATION).ShowModal()
            self.flash._set_FlashVars("data=%s %s %s" % sys.exc_info())
#-------------------------------------------
if __name__ == '__main__':
    class TestFrame(wx.Frame):
        def __init__(self):
            wx.Frame.__init__(self, None, -1, "ActiveX -- Flash", size=(640, 480), style=wx.DEFAULT_FRAME_STYLE )
            base = os.path.normpath(os.path.abspath(os.path.dirname(sys.argv[0])))
            swf = os.path.normpath(os.path.join(base, "movie.swf"))
            self.tp = TestPanel(self, base, swf)
    app = wx.PySimpleApp()
    frame = TestFrame()
    frame.Center()
    frame.Show(True)    
    app.MainLoop()

the flash part is really easy. Two text field, one button and one line of code!:

on (click) {	fscommand("saveFile", this._parent.fnome.text + "###" + this._parent.ftesto.text)}

P.S. Moreover today I read in wxPython mailing list a coming new version of wxPython. I hope this will begin to fix varoius problems with Mac installation of SE|PY