var flash = [[CPFlashView alloc] initWithFrame:CGRectMake(50, 50,
650, 450)];
[flash setFlashMovie:[CPFlashMovie flashMovieWithFile:"Resources/
sphere.swf"]];
[contentView addSubview:flash];
with the result of http://georama.com.au/caca/ ... I would now like to
get the handle of the swf, so that I can use ExternalInterface.
However a look at CPFlashView.j doesn't give any leads other than:
document["movie"]
which is undefined, so I think a name needs to be added in the embed.
Line 66 with a:
_DOMEmbedElement.name = "mySWF";
as a quick hack to test if it works. Before I go spelunking in the
bowels, any suggestions?
I'm already hacking on CPFlashMovie and CPFlashView, adding support
for params and flashvars. I'm not quite done yet, but you can check
out the recent changes in my fork on GitHub:
http://github.com/jross/cappuccino/tree/master
I can easily add support for a name element to embed, although I'd
like to be able to support conditional node creation (object or
embed), depending on the client. If anyone has any suggestions for
how best to do that conditional logic from within an AppKit class
(figuring out which browser/platform I'm on and which features are
available), that would be a good step in the right direction for
getting full support of Flash in the framework.
Thanks!
J.
I just updated my repo with a patch to support -setIdentifier: and -
identifier which adds an id attribute to <object> and a name attribute
to <embed>:
http://github.com/jross/cappuccino/commit/4831c288b0496c23515272b584108a1606298d85
Try that and let me know if that works for you.
J.
Hi Jesse,
I have noticed one readily testable difference between platforms,
which is that you can set the Flash background to grey and it will
show up in Safari but not in IE7. This affects mouse events as well,
as Flash picks up clicks on the grey for the whole box in Safari, but
only on anything drawn in Flash with IE7.
It's taking a while for me to set up Cappuccino for development, as I
didn't have macports or git or any of the other things installed. They
have been installed and I'm building Cappuccino from source now. Then
I'll be able to download your code and give it a go!
I suspect that returning the DOM element itself would work better than
needing to look it up by unique id? I'll soon find out. :)
Hi Jesse,
I don't have github set up, so I'll annoy everyone and post it here. :)
_DOMEmbedElement is the same as document.getElementById("moviename")
I also need to do this:
param = document.createElement("param");
param.name = "allowScriptAccess";
param.value = "sameDomain";
_DOMObjectElement.appendChild(param);
and then:
_DOMEmbedElement.allowScriptAccess = "sameDomain";
Then something like this works:
var blue = [[CPButton alloc] initWithFrame:CGRectMake(width-60,
10, 50, 18)];
[blue setTitle:"blue"];
[blue setTarget:self];
[blue setAction:"blue"];
[blue setAutoresizingMask:CPViewMinXMargin];
[contentView addSubview:blue];
- (void)blue
{
flash._DOMEmbedElement.blue();
}
So that suggests the CPFlashView class could be improved by:
1) Returning _DOMEmbedElement for communicating with the flash object
without need for unique id.
2) Adding the method setAllowScriptAccess:(CPString)value
Hope this helps!
In the latest version of my code on GitHub [1], I've added a -
setParams: method which will let you add any arbitrary parameter you
need, including allowScriptAccess. If you could try that code and see
if it works, that would be great. I've tested it on my end, and it
worked perfectly, allowing communication to the SWF from Obj-J.
You'll need to use a CPDictionary to set the params [2].
Also, I added an -identifier method which will return a unique id
that you can use to communicate to the SWF, rather than just
returning the embed element (since we can't guarantee that the embed
will be there once this code is modify to support platform-specific
code, ie: object or embed). If you could try that, and the
accompanying setter, setIdentifier:, and let me know if it works for
you, that would be great.
Also, starting today, I'm going to be out of the country with
intermittent internet access for the rest of the month, so please be
patient if I don't get back to you right away with updates.
Thanks!
J.
[1] http://github.com/jross/cappuccino/tree/master
[2] The code in my AppController test file looks something like this:
@implementation AppController : CPObject
{
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
var theWindow = [[CPWindow alloc]
initWithContentRect:CGRectMakeZero()
styleMask:CPBorderlessBridgeWindowMask],
contentView = [theWindow contentView],
flash = [[CPFlashMovie alloc] initWithFile:"flash.swf"],
flashView = [[CPFlashView alloc] initWithFrame:CGRectMake
(0,0,300,300)],
flashVars = [[CPDictionary alloc] init],
params = [[CPDictionary alloc] init];
[flashVars setObject:"0x0000FF" forKey:"color"];
[flashView setFlashVars:flashVars];
[params setObject:"l" forKey:"align"];
[params setObject:"default" forKey:"scale"];
[flashView setParams:params];
[flashView setFlashMovie:flash];
[flashView setIdentifier:"myFlash"];
[contentView addSubview:flashView];
[theWindow orderFront:self];
}
@end