I have a path problem when using loadImage() and loadStrings() in Processingjs. I would like to have my sketches and their associated files (images, text files) in one place and to be able to call them from another on my site.
For example, I am trying to run a Processingjs sketch located at
www.example.com/sketches/mysketch.pde from the page www.example.com. This works fine when there are no external files.
Alas the problem starts when I need to use loadImage() and loadStrings() to look for images and texts to load. It defaults to www.example.com/image.jpg and not to the sketch location, www.example.com/sketches/image.jpg.
The need for #pjs preload makes matters worse.
Without moving the files and without hardcoding, is there a way to
tell Processingjs to look for the files to load in the same folder as
the .pde and not the .html?
I hope this is clear. Any help would be appreciated!
Short answer: no.
Even native Processing won't behave the way you want in this sense, because you'll be executing your sketch from [...]/sketches/ and any resource call is local to that directory.
Similarly, with processing.js your resources are located relative to the "directory" you're in, which for www.example.com/ is just the base dir. What you can do, however, is place your .pde file in the same dir as your .html file, or vice versa.
#pjs preload is necessary to effect "immediate" file loading. If you don't preload it, your sketch will have to deal with asynchronous load instructions. Quite literally, loadImage without a preload directive behaves the same as requestImage (http://processing.org/reference/requestImage_.html)
Related
In a UWP app using cppwinrt I want to use WebView to display contents of a book kept in the Assets folder. I read that it is necessary to reference an html asset this way for use as a Uri argument to the Navigate method in web view:
TheWebView.Navigate(Uri(L"ms-appx-web:///SampleBook/PageOne.html"));
This produces an empty view, while
TheWebView.Navigate(Uri(L"ms-appx:///SampleBook/PageOne.html"));
crashes. Msdn says that for files "that will be loaded into the web compartment" one must use ms-appx-web, and I've seen mention that this is a security issue. But does that mean the files are in a special location within the project - i.e. not merely in the Assets folder - or does it only mean that the path must begin with ms-appx-web independent of the file's location? "Web compartment" is not explained but seems to be not a location but rather a classification of the type of resource. At any rate, neither of the above approaches works, so I'm curious to know the recommended way to store and access a collection of html files in the package. In the assets folder? A special folder within assets? In Solution Explorer the html file is listed, "content" is True, and the file is Included In Project. Thanks.
My mistake: ms-appx-web does not point to the assets folder, but to its parent. The correct path for content of this type would be ms-appx-web///Assets/SampleBook/PageOne.html. The reference to material to be "loaded to the web compartment" apparently is just a way of saying: stuff to be loaded with WebViewer.
I have developed an app using the GEPlugin located at https://code.google.com/p/winforms-geplugin-control-library/.
I use the GEWebBrowser and the GETreeView, and both works nicely.
I only load local kml files on the controls, so the way to do this, is to copy the "KML_Samples.kml" file into the webroot directory, and call the function as follows:
GeWebBrowser.FetchKml(http://localhost:8080/KML_Samples.kml)
Each time I call this method, the event GeWebBrowser_KmlLoaded is launched in the correct way.
However, I have checked lately that this works fine for the two or three first kml files loaded. After this two or three files, when I try to load a new kml file, I can see that the the KML_Samples.kml file has been updated, but the GeWebBrowser_KmlLoaded event IS NOT LAUNCHED!
I have tried to execute the app step by step setting a breakpoint on the line
GeWebBrowser.FetchKml(http://localhost:8080/KML_Samples.kml)
and in this case, I can load the kml files!!.
I have tried to execute some code after this line in order to execute all the pending events, with the following line:
Application.DoEvents()
However, this has not the expected result, and the trouble remains: I'm only able to load the two or three first kml files.
I wonder if something is missing by my side using this control, but I have not found anything on the documentation that could help me.
If anyone could help me with this issue, I would be very thankful .
I answer my own question.
I have detected the GEControl does not works fine with the built-in server. I can load local kml files by sopying them at webroot\KML_Samples.kml, but this only works for the first two or three files to be loaded.
For the following kml files, it doesn't work. I suppose there is some mistake inside the control, so I'm going to develop all the code that load the kml file into a TreeView (I'll try to use the KmlTreeView), and load all the separated points of each kml file into the plugin.
I need some help for my OS X program.
I need the URL of a file inside the supporting files.
I have an array in which I save URLs from images and add them to a table view and if no images are chosen I want to add a question mark image (it is called "bild.jpg")
This bild.jpg is inside the supporting files but for later use I can't just save the name of the image because the array stores also URLs.
I need to have the URL of that image in the supporting file because it's easier to use the array for image initialization.
Is there a function to get the path or is there a standard path to the supporting files? I already search on the net but couldn't find anything that could help.
You seem to be talking about the application bundle and its resources directory rather than, say, a subdirectory in ~/Library/Application Support/..., in which case you probably want something like:
[[NSBundle mainBundle] URLForResource:#"bild" withExtension:#"jpg"]
(See the documentation for NSBundle.)
From this page,
http://www.yiiframework.com/wiki/23/how-to-create-a-breadcrumb-widget/
It seems it suggests that we should put the files in the component folder. But if my widget contains javascript and css files, where should these files be placed?
By the way, is this a good idea that I create it as an extension? If I go this way, all widget files are more self-contained in a folder inside the extension folder. But since the widget I am going to work on is very customized, it's unlikely that it will be useful to other people or my other projects. Making it an extension seems a little bit strange.
I understand that it does not really matter where I put these files as long as the paths I am using in the codes are correct but I would like to know the common practice.
I think the common practice is to put the widget in extensions folder with js & css files in an folder named asset. In the php class file, you do initialization first by publishing the asset with yii asset manager.
The file structure may be like
extensions/
widget_name/
widget.class.php
assets/
plugin.js
style.css
I would join the recommendation to put the widget under /protected/extensions.
I put the assets in a slightly more detailed manner: /protected/extensions/WidgetClassName/assets/ and the widget view files in /protected/extensions/WidgetClassName/views/...
Don't forget to edit your /protected/config/main.php and add a row in the 'import' section (for autoloading of the widget): 'ext.WidgetClassName.WidgetClassName.*'
Few facts first:
1. I can only use ActionScript 2.
2. All files are within the same domain (i.e "http://www.example.com").
I have a loader SWF which acts as a selection tool ("auto_magic.swf") located at "/" in the website (the root folder).
A User selects the tool he needs (it's a mechanical diagnostic system) and the main movie loads it (currently I use loadMovie() - suggest else if needed).
That tool is located at "/tools/[tools_name]/tool_main.swf".
Now, the "tool_main.swf" is loading just fine.
The problem is that "tool_main.swf" needs to load other files located in its folder, so for example it tries to load "config.xml", BUT Flash isn't looking for "config.xml" in the tool's dedicated folder - instead it's looking for this file at the root folder "/" where "auto_magic.swf" is located, probably because the movie's main swf is coming from there.
To make it even worst I cannot modify the tool's SWF ("tool_main.swf") because it's coming from a third party.
Is there any solution? As far as I see this I need one of these solutions;
1. Be able to set the base url of the loaded swf.
2. *Change* the whole movie's base url at run-time because it needs to load several tools from different folders.
Trying to solve this for several good hours. Help will be highly appriciated!
relative paths are always relative to where the main swf exists. so as your load chain expands, '/' always refers to the location of the Main.swf.
in AS2, you can inspect a swfs _url property to determine its fully qualified url location, and determine its parent folder.
In the AS2 child swf, you can use this:
var myfolder = this._url.slice(0, this._url.lastIndexOf('/') + 1);
and then use that to load in further assets relative to itself.
hope that helps.