Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Perl Flash

by hakkr (Chaplain)
on Mar 20, 2002 at 13:55 UTC ( #152975=perlquestion: print w/replies, xml ) Need Help??

hakkr has asked for the wisdom of the Perl Monks concerning the following question:

Can Perl change links that are embedded in Flash files? I am thinking that the links can be passed into the flash file with params. This would require editing the flash file to accept params though. Can you generate Flash on the fly with Perl ? Cheers

Replies are listed 'Best First'.
Re: Perl Flash
by cjf (Parson) on Mar 20, 2002 at 14:28 UTC

    I've been trying to do some work with .swf files lately as well, unfortunately I haven't had too much luck. I was reading through the SWF::Element docs earlier, the description goes like so:

    SWF::Element module handles SWF tags and any other sub elements to create, configure, clone, pack to bit strings, and unpack from bit strings.

    Then later (near the bottom of the documentation, under actions) it lists ACTIONRECORD::ActionGetURL which 'directs the player to get the specified URL.' I haven't tried working with this yet, but thought I'd mention it in case it was helpful.

Re: Perl Flash
by ropey (Hermit) on Mar 20, 2002 at 14:07 UTC
    To answer you first question, in theory you could read in the swf and modify particular parts of it, however you would need to know exactly what you were looking for, swfs are compressed so there won't be a simple link to regex. To be honest I would just modify the swf to receive its parameters, its the more sensible way to do it. As for your second question CPAN has several modules which create swf's on the fly check out <A HREF=http://search.cpan.org/doc/YSAS/SWF-File-0.08/File.pm">SWF-File-0.08/File.pm but you have to think about do you really want to generate a swf and why? Would it not be easier just to modify the swf to receive the inputs ? HTH
Re: Perl Flash
by dempa (Friar) on Mar 20, 2002 at 14:07 UTC
Re: Perl Flash
by IlyaM (Parson) on Mar 20, 2002 at 19:38 UTC
    Very long time ago I've wrote some Perl code which interfaced with Flash. Take all what I say with grain of salt because I almost forgot everything about it. I just can be wrong. Anyway following information could be useful.

    IIRC in Flash you can have variables which values can be obtained from external source: text file in very simple format:

    var1=value1 var2=value2
    When Flash file runs it can request this text file for values of variables from web server. Of course instead of text file you can have Perl CGI which generates text file on the fly.

    Now the question if you can use values of Flash variables in URLs. May be yes, may be not. If yes you can use Flash variables and Perl CGI to create urls on fly. If not, I'm sorry.

    --
    Ilya Martynov (http://martynov.org/)

      I know that this is quite a late reply, but I have just recently installed Flash 5 and have an answer to this question. IlyaM is definitely on the right track. Using a perl script to output the URLs to the swf file is the way to go.

      Example:

      First let's create the flash (swf) file:

      1. Create a new flash project.
      2. Select one of the shape tools (square, circle, etc) and draw a quick shape.
      3. Use the 'select tool' to select the shape and hit F8 (or go to Insert->Convert to Symbol) Select the button option and hit OK.
      4. Right-click this button on your stage and select 'Actions'. This is where ActionScript comes into play
      5. Click the right-pointing arrow at the top of the little 'Actions' window. Select the 'Expert Mode' option.
      6. Copy and paste the following code into the right-hand side textbox:

        on (release) { loadVariablesNum ("/path/to/script.pl", 0); getURL (address, "_blank"); }
      7. Make sure you replace "path/to/script.pl" to the path of the perl script.
      8. Note that the getURL() function is passed address and not "address". This is because address is the variable name we will send to flash via the perl script.

      Next up we have the perl script:

      1. Open your favorite script editor and enter the following code:

      #!/path/to/perl -w use strict; use URI::Escape; my $url = "http://www.yahoo.com"; print "Content-type: text/plain\n\naddress=$url";

      2. $url is the URL of the page you want flash to open when you click that button you created. Note that the script passes the url via the 'address' variable.

      There, you have something that works! Of course, this could be made much better by allowing the passing of multiple URLs to the flash file, but that can be homework ;)

Re: Perl Flash
by artist (Parson) on Mar 21, 2002 at 13:40 UTC

      I've written a fair amount of SVG. It's great in that it transforms doing graphics (which I am terrible at) into math and programming (which I am decent at). The problem is that almost no browsers will render it. You have to render it on the server.


      We are using here a powerful strategy of synthesis: wishful thinking. -- The Wizard Book

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://152975]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2022-12-06 14:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?