Highlighted

Using NavigateToURL to open a file at the end of an animation

Explorer ,
Apr 09, 2020

Copy link to clipboard

Copied

Hello. I am having a real battle trying to get a file to open using the NavigateToURL command.  This is the code I am using:

Untitled-1.jpg

This is the file I am trying to open (in the same directory as the .fla and .swf file):

Untitled-2.jpg

I get this appearing and when I press either Yes or No nothing happens:

Untitled-3.jpg

Any suggestions?

It worked. Thank you JC.

 

If I wanted to open a file in another directory would I be able to use relative addressing (e.g. ../../House.doc) or would it have to be an absolute address?

TOPICS
ActionScript

Views

779

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Using NavigateToURL to open a file at the end of an animation

Explorer ,
Apr 09, 2020

Copy link to clipboard

Copied

Hello. I am having a real battle trying to get a file to open using the NavigateToURL command.  This is the code I am using:

Untitled-1.jpg

This is the file I am trying to open (in the same directory as the .fla and .swf file):

Untitled-2.jpg

I get this appearing and when I press either Yes or No nothing happens:

Untitled-3.jpg

Any suggestions?

It worked. Thank you JC.

 

If I wanted to open a file in another directory would I be able to use relative addressing (e.g. ../../House.doc) or would it have to be an absolute address?

TOPICS
ActionScript

Views

780

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 09, 2020 0
Adobe Community Professional ,
Apr 11, 2020

Copy link to clipboard

Copied

Hi.

 

If you want to just display an external image, I think using the Loader and URLRequest classes are a better approach. For example:

import flash.display.Loader;
import flash.net.URLRequest;

var loader:Loader = new Loader();
loader.load(new URLRequest("Tree.png"));
addChild(loader);

 

Please let us know if this works.

 

 

Regards,

JC

__________________________________________
HTML5, JSFL, and AS3 samples: http://bit.ly/2mJgDoG

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 11, 2020 0
Explorer ,
Apr 11, 2020

Copy link to clipboard

Copied

Hello JC. Thanks for the reply. Unfortunately, nothing seems to happen.

This is a screen shot of the code and the timeline showing what frame the action is on:

Untitled-1.jpg

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 11, 2020 0
Adobe Community Professional ,
Apr 11, 2020

Copy link to clipboard

Copied

Is the timeline stopped at the frame you want to load the image?

__________________________________________
HTML5, JSFL, and AS3 samples: http://bit.ly/2mJgDoG

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 11, 2020 0
Explorer ,
Apr 11, 2020

Copy link to clipboard

Copied

No. Would that make a difference?

 

I'm looking for the file to open in its default program so I could this code to get a .doc to open in Word, a .ppt to open in PowerPoint,  etc.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 11, 2020 0
Adobe Community Professional ,
Apr 11, 2020

Copy link to clipboard

Copied

It does because loading an image is an asynchronous operation wich means the asset you want to load won't be immediately available. But in your case as you want to open with a default application the code I provided won't achieve the goal.

 

Also this navigateToURL method seems to have been created initally taking only or mostly browsers into account, IMHO.

 

But now that Flash Player applications cannot run inside of mainstrem browsers anymore, the AIR runtime is the best option for desktop and mobile applications. Applications created with AIR for desktop are native so you should have more power to read and write files from/to the user's local storage

 

Please try the following:

 

- Switch to the AIR runtime in the Publish Settings (Ctrl/Cmd + Shift + F12).

image.png

 

- Code something like this:

import flash.filesystem.File;
import flash.net.navigateToURL;
import flash.net.URLRequest;

function openImage(fileName:String):void
{
	var file:File = File.applicationDirectory;
	var url:String = file.nativePath + File.separator + fileName;
	
	navigateToURL(new URLRequest(url));
}

openImage("Tree.png");

 

Please let us know if this solves your issue.

 

 

Regards,

JC

__________________________________________
HTML5, JSFL, and AS3 samples: http://bit.ly/2mJgDoG

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 11, 2020 0
Explorer ,
Apr 11, 2020

Copy link to clipboard

Copied

I don't have AIR as a target option within Publish Settings.  How do I get it?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 11, 2020 0
Adobe Community Professional ,
Apr 13, 2020

Copy link to clipboard

Copied

Hi.

 

Starting from Animate 20.0.2, the AIR SDK must be enabled manually. Please checkout this tutorial by Joseph Labrecque.

__________________________________________
HTML5, JSFL, and AS3 samples: http://bit.ly/2mJgDoG

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 13, 2020 0
Explorer ,
Apr 14, 2020

Copy link to clipboard

Copied

I've downloaded and unzipped Adobe AIR SDK.  Do I need to place it in my Animate folder and how do I get it to connect with Animate?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 14, 2020 0
Adobe Community Professional ,
Apr 14, 2020

Copy link to clipboard

Copied

Hi.

 

Go to Help > Manage Adobe AIR SDK..., click the + button and add the folder containing the AIR SDK you've downloaded.

 

Here is another video from Joseph Labrecque with more info about this process:

__________________________________________
HTML5, JSFL, and AS3 samples: http://bit.ly/2mJgDoG

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 14, 2020 0
Explorer ,
Apr 14, 2020

Copy link to clipboard

Copied

It worked. Thank you JC.

 

If I wanted to open a file in another directory would I be able to use relative addressing (e.g. ../../House.doc) or would it have to be an absolute address?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 14, 2020 0