Embedding links in flash buttons - html

I'm making a flash website, I know the basics of html and AS3, but this is my first time trying to use them together. I need only two interactions between the swf file and the server:
The .swf needs to be able to grab image files from a directory hosted on the server
The .swf file needs to be able to change the URL
I'm not sure how complex these things are to do, but I'd like the simplest solution possible. Direct me to a tutorial if you think it is necessary, but the quick and dirty would be appreciated.

Loading images
Changing URL

If you want to interact between flash and the browser you can use ExternalInterface. Here is a simple tutorial on it:
ExternalInterface
Flash can access directory hosted on the same server as long as you have permission, and you can do redirect in AS3 w/ the following code:
var page3URL:String = "http://example.com?" + "x=" +id;
navigateToURL( new URLRequest( page3URL ) );

Related

I keep getting a 404 from the youTube API V3 in AS3

We are actively working on moving our product from AS3 to HTML5, but until we complete the process we still have many clients using the Flash version of the Youtube API V3. We have gotten our project Key and are making the request with https://www.youtube.com/apiplayer?version=3&key=[key], it returns a 404 when the AS3 goes to get it, but returns the flash API when pasted into the browser directly.
We have Security.allowDomain("www.youtube.com"); in the code.
Here is how we are loading the API, which has worked for years.
_loader = new Loader();
_loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);
var url:String = "https://www.youtube.com/apiplayer?version=3&key=*[key]*";
_loader.load(new URLRequest(url));
Trying to figure out what i'm missing.
The Youtube API is no longer working with AS3 code.
I don't think any remaining SWF versions of player will last long. Consider for any video ID, Having /embed/ used to give the HTML5 player or else using /v/ gave you SWF player. Now both link types return an HTML5 player. They have already started changing things.
Examples:
HTML5 : https://www.youtube.com/embed/1SnPedRxEIU
SWF (but now changed to HTML5) : https://www.youtube.com/v/1SnPedRxEIU ( edit: Seems this URL returned a direct link to the SWF file. Now Chrome browser asks to download, with no browser view unless contained in html file).
The only solution is to move faster to HTML5 (Youtube expects this for browser playback).
For anyone else interested, there's the final option to just extract video file path directly from the video page's source code or instead get a JSON by using http://youtube.com/get_video_info?video_id=xxxx. From either returned text (site source or JSON) you can decode the Unicode & HTML entities to reveal the file URL. The advantage of parsing page source is that you'll find even 1080p links, but JSON version is easier to work with.
you can try this solution, for me it worked https://github.com/myflashlab/AS3-youtube-parser-video-link

HTML Hyperlink to a specific scene in a swf file

I have an swf file with many scenes. I would like to be able to add multiple hyperlinks to a company Intranet site (set up on SharePoint) that link to specific scenes in the swf file. Is this possible? Thank you!
It's do-able... it's going to depend on how much access you have to the actionscript, the javascript, etc. In short you'll need to be able to add the necessary listeners required to do what you want to do.
I found an example of communication between JavaScript and Flash here: http://code.tutsplus.com/tutorials/quick-tip-how-to-communicate-between-flash-and-javascript--active-3370
Yes, first you need to setup deep-linking in your SWF. Check out swfaddress. This will make it easier to create deep-links (using the browser address hash) into your SWF file. For example, a url such as my/site.html#scene3 could gotoAndPlay(1, "scene3") in your SWF. Swfaddress has various examples to get you started.
Once you have your swf setup to support deep-linking, you can simply create HTML links with the desired url, like <a href="my/site.html#scene3">.

Hide mp3 url while playing audio file

I have a webpage that offers dynamic downloading of mp3 files through mobile phones. I would like to add a feature where someone can listen to the song through their desktops before downloading the file.
The challenge is, I don't want the mp3 file link to be displayed in the page code, I would prefer a different url e.g
<a href='http://mysvr.com/getfile/121233444/'>Preview song</a>
which is passed on to a player that expects an mp3 file source and get it to play the file.
I don't want the person previewing the file not know the real url of the file that is playing to prevent unauthorised downloads.
What do I need to do?
First deny all the access to the directory which has mp3 files through the internet. Then write a handler file to play the mp3's. The handler file will get the name of the mp3 from query string and play the file on player. Taking the url , parsing and playing will be done in codebehind so users wont be able to see the url of the mp3
hope it helps.
This would depend on your setup. The only real way to not make it visible would be to use server side code (php, asp etc). Any client side code is by definition visible to the end user. You could try to obfuscate the link e.g. using some minimized JavaScript hidden away somewhere, but it will always be visible to anyone who searches hard enough.

ActionScript don't load HTML resources with HTMLLoader

I'm currently downloading website via an ActionScript HTMLLoader to later have access to the DOM to get some information out of the page.
The problem is: each resource that is linked on the page (images, stylesheets, javascript) is also loaded which takes some additional time. I don't really need those resources, because only the plain HTML/DOM is interesting.
Is there any way to disable loading of linked resources? At first I tried using an URLLoader and parse the result as XML, but when the website isn't valid this doesn't work. I also didn't find a library that validates/parses a given HTML-string into valid XML.
I'm using Adobe AIR on desktop.
Perhaps convoluted, but you could load the file with URLLoader, convert it to a string, use regex to remove links to the external resources you don't want, and then load the result into the HTMLLoader.

Embedding a Video on an ASP.NET MVC Website

I have created a SWF file using Flash that loads an FLV file on my local development machine. When publishing the SWF file and generating the appropriate HTML, I can successfully load the video by opening the generated HTML page that Flash creates. However, when placing the generated HTML code in my View, the Flash is loading, but the video is not playing. I think it's a reference error to the location of the FLV file, but I've tried every combination I can think of. I placed the SWF and FLV in the corresponding View folder where I want the video to load, but to no avail. Does anyone have a working example that I can look at, or any suggestions? Thanks.
I think it's a reference error to the location of the FLV file, but I've tried every combination I can think of.
Yes, I think so as well. Have you tried using Url helpers to reference static resources on your site, like
#Url.Content("~/Content/Videos/MySupervideo.flv")
The actual solution to this for me was this...
In your Flash file, the Component Inspector should point to the location on the web server where the FLV file is located...
Publish the SWF, copy the appropriate HTML to the View you would like the video to play in...
And just as Darin has pointed out, use the Helpers to write the path to the SWF file on your web server where it is located. The only difference is this (which I discovered using Google's 'Inspect Element' feature and then clicking on the 'Network' item, then clicking the path loaded on the left for the 'SWF'... on the right it stated 404 Status Not Found... why?
#Url.Content("~/Content/video/name-of-swf.swf") actually produced
src='http://localhost/content/video/name-of-swf.swf.swf'
This obviously incorrect... so here is the correct way to use the Helpers...
#Url.Content("~/Content/video/name-of-swf")
Hope this helps someone... I am giving Darin credit because he pushed me in the right direction...