Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Problem displaying user-created .cdf files

  • To: mathgroup at smc.vnet.net
  • Subject: [mg122938] Re: Problem displaying user-created .cdf files
  • From: John Fultz <jfultz at wolfram.com>
  • Date: Thu, 17 Nov 2011 06:05:02 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Reply-to: jfultz at wolfram.com

Does the content appear in a *fresh* session of Mathematica, after you've newly 
opened the notebook and have evaluated no cells at all (including initialization 
cells)?

One common failure that happens in this regard is that the CDF relies on some 
state in the kernel which is not automatically established, but requires 
Shift+Enter evaluations to establish.  Here's a very simple example:

(* Bad!! *)
f[x_] := Sin[x]
Manipulate[f[x], {x, 0, 10}]

The definition of f will be lost in any new session of Mathematica or Player.  
But, of course, it will appear to have worked while you were authoring it.

In the specific case of Manipulate, there are generally two ways to resolve
this.  You can use the "automatic" method...the SaveDefinitions option:

(* Good example #1 *)
f[x_] := Sin[x]
Manipulate[f[x], {x, 0, 10}, SaveDefinitions->True]

This works quite nicely, but for very complex examples (particularly when 
packages need to be loaded), SaveDefinitions automatic methods can either fail 
or produce an unnecessarily large (in terms of file size) result.

The other method involves making sure that you properly localize everything.
Depending upon your code, this might involve the use of DynamicModules, 
Initialization options, or other devices.  In this case of the example I 
provide, it's a fairly straightforward Initialization option:

(* Good example #2 *)
Manipulate[f[x], {x, 0, 10}, Initialization:>(f[x_] := Sin[x])]

I am guessing a bit as to the exact nature of your problem based upon your 
description.  It's possible that it might be some other sort of issue which I 
didn't describe, like for example a limitation of the sandbox environment that 
the web browser plugin runs in.  If my explanation above didn't help, then what 
you really need to send for people to help debug your problem is the CDF itself.

Sincerely,

John Fultz
jfultz at wolfram.com
User Interface Group
Wolfram Research, Inc.


On Wed, 16 Nov 2011 04:46:46 -0500 (EST), Gary wrote:
> The cdf. files that I create do not display properly. They can be
> opened, viewed, and manipulated with Mathematica, but CDF Player is
> able to display them only partially, even after enabling Dynamics. The
> same problem occurs when they open in a web page.
>
> I get the right size box and properly labeled axes, but a tan
> background (the intended one is light yellow). The four sliders appear
> properly labeled above the display window, but none of the real
> content (a disk, three arrows, and a sphere) of the demonstration
> appears. The slider buttons slide, but since there are no objects in
> the display, they can't do anything.
>
> To the best of my knowledge, I followed all the instructions for
> preparing the .cdf file: close unwanted cells, hide brackets, enable
> Deployed in Cell Options --> General Properties --> Deployed, making
> sure that the file "rotate_demo.cdf" was selected in the menu of the
> Options for Global Preferences dialog. I saved the file as .cdf using
> the menu choice in the save dialog. I tried each of the following two
> html tags in a web page.
>
> <script src="http://www.wolfram.com/cdf-player/plugin/v1.0/
> cdfplugin.js"
> type="text/javascript"></script><script type="text/javascript">// <!
> [CDATA[
> var cdf = new cdf_plugin();
> cdf.addCDFObject("rotate_demo_applet", "rotate_demo.cdf", 800, 800);
> // ]]></script>
>
> <embed src="rotate_demo.cdf" width="1000" height="1000">
>
> Files downloaded from Wolfram's demonstration .cdf files and opened in
> in either a browser or the CDF Player display and operate properly, so
> it seems the error must occur when the files are created.  Any ideas?
>
> Mathematica 8, iMac, OS X 10.6.8, Chrome, Firefox





  • Prev by Date: Re: Solve for parameters of a truncated normal
  • Next by Date: Re: Problem displaying user-created .cdf files
  • Previous by thread: Re: Problem displaying user-created .cdf files
  • Next by thread: Re: Problem displaying user-created .cdf files