AS3 - URLRequest not working - cross-domain

My flash SWF needs to load "photo.jpg" using URLRequest but in vain. Heres how I am doing it
imLoader = new Loader();
imLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
imLoader.load(new URLRequest("photo.jpg"));
The SWF and photo are both located in the same directory on my localhost server. When i render it in the browser, photo doesn't load. But when i do it manually by simply opening the SWF, photo loads up properly.
Is it something related to crossdomain or what is the problem?

The path is relative to the HTML document. So if your image and SWF are not in the same directory as the HTML you need to provide a path (absolute or relative to the HTML).
So if your SWF and image are in 'media' directory you would need:
imLoader.load(new URLRequest("media/photo.jpg"));
//or
imLoader.load(new URLRequest("/media/photo.jpg"));
//or (if SWF and image are on different server)
imLoader.load(new URLRequest("http://www.domain.com/media/photo.jpg"));

Related

Non-english url path

In next.js that uses php-like approach - files in pages folder became url paths. Like /pages/reader.js will be loaded by url http://localhost/reader.
Problem is that i can't undersand how to use non-english url path in next.js?
Codesandbox example. (Update page to load from server)
Url example:
http://localhost/читатель
That changes internally by chrome to:
http://localhost/%D1%87%D0%B8%D1%82%D0%B0%D1%82%D0%B5%D0%BB%D1%8C
In next.js pages folder file named:
pages/читатель.tsx // not working
pages/%D1%87%D0%B8%D1%82%D0%B0%D1%82%D0%B5%D0%BB%D1%8C.tsx //working but i can't name files like that, i will not find what i need later.
Maybe php users resolved this somehow ;)
try to use encodeURI() of core javascript which can convert the specific characters to the required url form
const url=encodeURI('читатель.tsx');
console.log(url);//%D1%87%D0%B8%D1%82%D0%B0%D1%82%D0%B5%D0%BB%D1%8C.tsx
Then we can use this path to navigate

Image(s) not showing when using nodejs with handlebars (.hbs)

I have tried to search for an answer here but nothing so far worked, not many threads about handlebars. Im at my 2nd year of coding and struggling to get images to show up on my node app.
I have this on app.js and below that the code im trying to get image to show up on the .hbs file:
app.use(express.static('img/'));
<img src="bckground.jpg" alt="teeest" />
Thank you in advance if someone knows what to do.
Supposing that you are serving your application at "http://localhost:3000", and your web page is "http://localhost:3000/index.html", you are requesting the image "bckground.jpg", so the browser will try to load "http://localhost:3000/bckground.jpg". This is wrong, because you are serving the static images folder under the "img" path, so the image is available at "http://localhost:3000/img/bckground.jpg".
If your application is being served at the "root" path of the domain, then this should work for you:
<img src="/img/bckground.jpg" />
Note the initial "/" at the image path. This means that the path will be calculated from the root folder of the domain. You should take this into account if you are serving your application in a subfolder.

Can't show static loaded videos by Express.js

I'm serving some static HTML, CSS and JS files and also a folder called tmp with some images and video files using Express.js for my Node app:
app.use(express.static("build"));
app.use(express.static("../tmp"));
When I go to http://localhost:3003, it loads up my app very nicely and it loads all the images on my webpage(located in the tmp folder) but the problem is every video file looks like this:
If I press fullscreen on the video player or even visit the url directly http://localhost:3003/video_1.mp4, it works.
Is this a problem with Express.js trying to stream the video data from the tmp folder? I really don't know how to solve this issue. I tried to delay the playback and use a 3rd party library to play the video but no luck.
Seems to work when I directly specify the whole path localhost:3003/picture.png in src of the video element

Image is not loaded in MVC5 JQuery during initial Load requested via IIS

1.When pointing the URL as "http:/servername/virtualdirectory" and for example i am setting image path as ../Content/Images/xx.png using jquery in js file then the images is not loaded
2.When pointing the URL as "http:/servername/virtualdirectory/controllername/action" and for example i am setting image path as ../Content/Images/xx.png using jQuery in js file then the Images is loaded.
Questions is why the image is not loaded during IIS request from routeconfig.cs ie 'http:/servername/virtualdirectory' in MVC5
Try using <img src="~/Content/Images/xx.png"> in your Razor syntax. This will generate a correct path to your image.

Image in Local Folder from WebView

I am working on a project where I need to access an image stored in the applications local folder from within a webview control. When I try to use the ms-appdata:/// scheme it does not work.
I should also mention that I have no control over what content is loaded into the webview and so I must assume that there is no reference to base.js.
I guess my question is, is there any folder where I can store images on the device that I can access from within a webview.
I have tried:
ms-appdata:///local/
ms-appx-web:///local/
file://[path]
Update
This project is done using WinJS and Universal Apps. So it is written entirely in JavaScript.
I use this :
StorageFile file = await dir.GetFileAsync(name + ".jpg");
and I set this
"ms-appdata:///local/" + file.Name
in the "src" attribute of my image tag.

Resources