Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Explorer ,
Apr 09, 2020 Apr 09, 2020

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.jpgexpand image

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

Untitled-2.jpgexpand image

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

Untitled-3.jpgexpand image

Any suggestions?

TOPICS
ActionScript
1.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Apr 14, 2020 Apr 14, 2020

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?

Translate
Community Expert ,
Apr 11, 2020 Apr 11, 2020

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 11, 2020 Apr 11, 2020

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.jpgexpand image

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 11, 2020 Apr 11, 2020

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 11, 2020 Apr 11, 2020

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 11, 2020 Apr 11, 2020

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.pngexpand image

 

- 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 11, 2020 Apr 11, 2020

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 13, 2020 Apr 13, 2020

Hi.

 

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 14, 2020 Apr 14, 2020

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 14, 2020 Apr 14, 2020

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:

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 14, 2020 Apr 14, 2020
LATEST

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?

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