• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Embedding Flash in .app, Round Two
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Embedding Flash in .app, Round Two


  • Subject: Re: Embedding Flash in .app, Round Two
  • From: Michael Rothwell <email@hidden>
  • Date: Tue, 3 Jan 2006 20:11:35 -0500


Here's a trivial app that embeds the "Badger Badge Badger" flash movie.

http://www.rothwell.us/misc/swf.zip (352k, slow server)

Source:

http://www.rothwell.us/misc/swf-source.zip (2.4M, slow server)

It's simply a WebView, with this code in the application delegate:


-(void)awakeFromNib
{
NSString *path = [[NSBundle mainBundle] pathForResource:@"badger" ofType:@"swf"];


    NSData *flash = [NSData dataWithContentsOfFile:path];

    [[wv mainFrame] loadData:flash
                    MIMEType:@"application/x-shockwave-flash"
            textEncodingName:@"utf-8"
                     baseURL:nil];
}

Does the trick.

It does pop up a Flash warning about badger.swf wanting to phone home to http://www.weebls-stuff.com/addhit.php?name=badgers

Presumably your flash files won't do that.

-M


On Jan 3, 2006, at 6:54 PM, John Stiles wrote:

If you figure this out, let me know. I've always wanted a way to embed a Flash into an app that didn't suck :)

On Jan 3, 2006, at 1:31 PM, Rachel Blackman wrote:

As mentioned before, I have need to embed a Flash file in an app basically as an NSView subclass. Basically, I need to have on this class something akin to:

- (BOOL) initWithURL:(NSURL) urlToSWF;
- (NSString *) getFlashVariable:(NSString *) var;
- (NSString *) setFlashVariable:(NSString *) var toValue: (NSString *) val;


And a delegate which accepts fscommand calls from the Flash movie with:

  - (void) doFSCommand:(NSString *)command withArgs:(NSString *)args;

I tried using NSMovieView, and wrote a subclass which did all this. This embedded a number of Flash files quite nicely, including the basic Macromedia samples. Unfortunately, it doesn't seem to work quite right.

But with Quicktime 7 you cannot load Flash files containing alpha (and ours do) or which are compressed (and ours are). And while some sample files worked fine with setVariable and fscommand interaction using MCActionFilter stuff and FlashMediaSetFlashVariable, not all -- and not ours (with the alpha masking removed and compression off, of course) -- did.

It's not a Flash file problem, though: over on Windows XP, embedding the Flash ActiveX control in a window and loading one of the files on Windows works fine, both for playback and for interaction/communication with the ActiveScript code in the Flash file.

Now, being a Mac devotee, I'm certain there has to be a way to do this at least as cleanly. But NSMovieView clearly isn't going to cut it. I've gone back to looking at using WebView and just calling the Flash plugin, but it seems I'll have to do some serious black magic voodoo in order to have a WebView-derived class that will handle what I want to do cleanly. (Like rewriting temporary HTML files and loading them, and doing some really scary dynamic Javascript voodoo to do the set/get/fscommand stuff.)

So, again, I ask... anyone have any better ideas for me? I'm right now considering whether or not it would be possible to load the Flash plugin directly as if I /were/ Webkit, and interact with it that way. But at this point, I'll take anything: even just a better idea on how do to this with WebKit so that it's not evil. :)

--
Rachel 'Sparks' Blackman -- sysadmin, developer, mad scientist
"If it is not broken, give me five minutes to redesign it!"

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40blizzard.com


This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden

-- Michael Rothwell email@hidden



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Embedding Flash in .app, Round Two
      • From: Rachel Blackman <email@hidden>
References: 
 >Embedding Flash in .app, Round Two (From: Rachel Blackman <email@hidden>)
 >Re: Embedding Flash in .app, Round Two (From: John Stiles <email@hidden>)

  • Prev by Date: Re: Embedding Flash in .app, Round Two
  • Next by Date: Core Data Binding: Reading a binary image (TIFF)
  • Previous by thread: Re: Embedding Flash in .app, Round Two
  • Next by thread: Re: Embedding Flash in .app, Round Two
  • Index(es):
    • Date
    • Thread