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

Launch Android application that has been installed with navigateToURL() ?

Mentor ,
Nov 14, 2013 Nov 14, 2013

Copy link to clipboard

Copied

I have seen some mention of a method for Java called "intent" but I don't know how to implement this in AS3 (either Flash or Flash Builder).

I am trying to launch an SWF that is unable to be launched via the load() method.  For some reason, even though I can view the SWF file in an HTML wrapper and separately using the Flash debugger, when I try to use the load() method it does not load.  I get some AS3 errors in debugging that have to do with the Classes that the SWF file is using.

So I figured, if I installed the apk of the SWF file and launched the apk with navigateToURL it should work.  But I need the right arguments.  I have also considered fscommand.  When I say arguments, I guess I'm talking more about the specific filename and path that the installed Android app is registered to.

Thanks in advance,

markerline

TOPICS
ActionScript

Views

2.5K

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
community guidelines

correct answers 1 Correct answer

Community Expert , Nov 14, 2013 Nov 14, 2013

you probably have a reference to the stage or something on-stage BEFORE your loaded swf is added to the stage.  that's why you have no problem when testing the swf as a stand-alone and you have a problem when loading it.

to remedy, use an Event.ADDED_TO_STAGE listener before trying to reference the above.  if you don't understand the issue/how to resolve, copy and past the first 90 or so lines in FontExtrusionDemo.as

Votes

Translate

Translate
Community Expert ,
Nov 14, 2013 Nov 14, 2013

Copy link to clipboard

Copied

you have an android app that launches when tapped in an android device, correct?

if so, what exactly do you mean by, "I am trying to launch an SWF.."?

and what is the relationship between that swf and your android app?

Votes

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
community guidelines
Mentor ,
Nov 14, 2013 Nov 14, 2013

Copy link to clipboard

Copied

My android app loads SWF's.  But there is one SWF that will not load using the load() method.  For this I am trying to use a button with navigateToURL instead of load().  When I say that the android app loads swfs, I mean that it is an Adobe AIR APK installed application that loads SWFs directly into the application.  I am taking care of this with Flash Builder but have also built a parallel application in Flash Pro to see if there was something wrong with my load method in Flash Builder.  They both produce the same error with the intended SWF that won't load.

So then I will install the intended SWF as a separate AIR APK and then launch that APK from within my master (first) Android app that loads the other SWF's.  My reason for doing it this way is for usability.  I want the user to be able to launch the master APK and have access to all of the buttons that it provides and only if they are interested in seeing that second APK they can use the navigateToURL button to launch it and then switch back to the master application when they are finished.

Votes

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
community guidelines
Community Expert ,
Nov 14, 2013 Nov 14, 2013

Copy link to clipboard

Copied

why won't that one swf load into your app?  copy and paste the error message(s).

Votes

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
community guidelines
Mentor ,
Nov 14, 2013 Nov 14, 2013

Copy link to clipboard

Copied

TypeError: Error #1009: Cannot access a property or method of a null object reference.

    at FontExtrusionDemo/setString()

    at FontExtrusionDemo/initScene()

    at Away3DTemplate()

    at FontExtrusionDemo()

Those are the error messages.  However when I try to compile the same file that I'm loading from an empty FLA sourcing the "FontExtrusionDemo.as" file as the Document Class, I can compile successfully without errors.  That's why I'm puzzled about these errors.

-markerline

Votes

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
community guidelines
Community Expert ,
Nov 14, 2013 Nov 14, 2013

Copy link to clipboard

Copied

you probably have a reference to the stage or something on-stage BEFORE your loaded swf is added to the stage.  that's why you have no problem when testing the swf as a stand-alone and you have a problem when loading it.

to remedy, use an Event.ADDED_TO_STAGE listener before trying to reference the above.  if you don't understand the issue/how to resolve, copy and past the first 90 or so lines in FontExtrusionDemo.as

Votes

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
community guidelines
Mentor ,
Nov 14, 2013 Nov 14, 2013

Copy link to clipboard

Copied

To understand that event I looked up this article:

http://www.emanueleferonato.com/2009/12/03/understand-added_to_stage-event/

And I have this code....

import flash.display.Loader;

import flash.events.MouseEvent;

import flash.net.URLRequest;

import flash.events.Event;

var loader:Loader= new Loader();

loadBtn.addEventListener(MouseEvent.CLICK, onLoadEvent);

function onLoadEvent(e:MouseEvent):void{

   

   

    addEventListener(Event.ADDED_TO_STAGE, init);

   

   

}

function init(e:Event):void{

    loader.load(new URLRequest("test_reference_document_class.swf"));

    addChild(loader);

}

But nothing seems to load and I don't get any errors either.  I must be implementing the ADDED_TO_STAGE event incorrectly but don't really know how to solve it.

Votes

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
community guidelines
Community Expert ,
Nov 14, 2013 Nov 14, 2013

Copy link to clipboard

Copied

that listener and init() need to be in the loaded swf that's triggering the error.  ie, in the document class FontExtrusionDemo.as

again, if you need help, copy and paste the first 80 or so lines of FontExtrusionDemo.as

Votes

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
community guidelines
Mentor ,
Nov 14, 2013 Nov 14, 2013

Copy link to clipboard

Copied

Yes, I do need some help..  The AS file has some declarations such as "super()" so I'm not sure exactly where to put the ADDED_TO_STAGE event listener and dependant function.

package

{

   

    import away3d.containers.ObjectContainer3D;

    import away3d.extrusions.TextExtrusion;

    import away3d.primitives.TextField3D;

   

    import flash.events.Event;

   

    import flash.display.MovieClip;

    import flash.display.Shape;

   

    import wumedia.vector.VectorText;

    import flash.text.TextField;

    import flash.text.TextFieldType;

    import flash.events.MouseEvent;

   

    public dynamic class FontExtrusionDemo extends Away3DTemplate

    {

        [Embed(source="Fonts4.swf", mimeType="application/octet-stream")]

        protected var Fonts4:Class;

        protected var container:ObjectContainer3D;

        protected var extrusion:TextExtrusion;

        protected var text:TextField3D;

        public var txtFld:TextField;

        public var myString:String;

        public var myStringBoolean:Boolean;

        public function FontExtrusionDemo()

        {

            super();

        }

        protected override function initEngine():void{

            super.initEngine();

            myStringBoolean=false;

            this.camera.z=0;

            VectorText.extractFont(new Fonts4());

        }

        public function setString():void{

            this.myString=myString;

            txtFld= new TextField();

            txtFld.x=txtFld.y=20;

            txtFld.width =100;

            txtFld.height=20;

            txtFld.border=txtFld.background=true;

            txtFld.type=TextFieldType.INPUT;

           

            addChild(txtFld);

            stage.focus=txtFld;

            var my_cont:MovieClip=new MovieClip();

            var my_shape:Shape = new Shape();

            my_cont.addChild(my_shape);

            my_cont.buttonMode=true;

            addChild(my_cont);

            my_shape.graphics.lineStyle(1, 0xFF0000, 1);

            my_shape.graphics.beginFill(0x000000,1);

            my_shape.graphics.drawRect(150, 50, 50, 50);

            my_shape.graphics.endFill();

            my_cont.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDownEvent);

            my_cont.addEventListener(MouseEvent.MOUSE_UP, onMouseUpEvent);

        }

        public function onMouseUpEvent(e:MouseEvent):void{

            myStringBoolean=false;

        }

        public function onMouseDownEvent(e:MouseEvent):void{

            myStringBoolean=true;

        }

        protected override function initScene():void{

            super.initScene();

            myString="1";

            setString();

            text = new TextField3D("myAlphabet_04",{

                text:myString,

                align: VectorText.CENTER}

                );

            extrusion = new TextExtrusion(text, {

                depth: 10,

                bothsides:true}

                );

            container = new ObjectContainer3D(text, extrusion, { z:300 });

            scene.addChild(container);

           

        }

        protected override function onEnterFrameEvent(event:Event):void{

            super.onEnterFrameEvent(event);

           

            text = new TextField3D("myAlphabet_04",{

                text:String(txtFld.text),

                align: VectorText.CENTER}

                );

               

            extrusion = new TextExtrusion(text, {

                depth: 10,

                bothsides:true}

                );

            if(myStringBoolean){

                scene.removeChild(container);

            container = new ObjectContainer3D(text, extrusion, { z:300 });

            scene.addChild(container);

            }

            container.rotationY=(container.rotationY+1)%360;

           

            if (container.rotationY>90&&container.rotationY<270){

                text.screenZOffset=10;

            } else {

                text.screenZOffset=-10;

            }

        }

    }

}

Votes

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
community guidelines
Community Expert ,
Nov 14, 2013 Nov 14, 2013

Copy link to clipboard

Copied

you need to use the addedtostage listener in your super class to prevent the problem on line 22 of your super class.  that will solve these errors:

    at Away3DTemplate()

    at FontExtrusionDemo()

and you need to delay calling setString() until your swf is added to the display list which call solve this part:


at FontExtrusionDemo/setString()

and you need to delay calling initScene() until your swf is added to the display list to prevent this error:

  at FontExtrusionDemo/initScene()

Votes

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
community guidelines
Mentor ,
Nov 14, 2013 Nov 14, 2013

Copy link to clipboard

Copied

I've tried to implement your recommendation but I have apparently done so incorrectly:

public function Away3DTemplate()

        {

            addEventListener(Event.ADDED_TO_STAGE, myinit);

           

        }

        public function myinit(e:Event):void{

            initUI();

            initEngine();

            initScene();

            initListeners();

        }

and

package

{

   

    import away3d.containers.ObjectContainer3D;

    import away3d.extrusions.TextExtrusion;

    import away3d.primitives.TextField3D;

   

    import flash.events.Event;

   

    import flash.display.MovieClip;

    import flash.display.Shape;

   

    import wumedia.vector.VectorText;

    import flash.text.TextField;

    import flash.text.TextFieldType;

    import flash.events.MouseEvent;

   

    public dynamic class FontExtrusionDemo extends Away3DTemplate

    {

        [Embed(source="Fonts4.swf", mimeType="application/octet-stream")]

        protected var Fonts4:Class;

        protected var container:ObjectContainer3D;

        protected var extrusion:TextExtrusion;

        protected var text:TextField3D;

        public var txtFld:TextField;

        public var myString:String;

        public var myStringBoolean:Boolean;

        public var myDelay:Boolean;

        public function FontExtrusionDemo()

        {

            super();

        }

        protected override function initEngine():void{

            super.initEngine();

            myStringBoolean=false;

            this.camera.z=0;

            VectorText.extractFont(new Fonts4());

           myAddedToStage();

        }

        public function myAddedToStage():void{

            myDelay=false;

           addEventListener(Event.ADDED_TO_STAGE, delaySetString);

        }

        public function delaySetString(e:Event):void{

           myDelay=true;

        }

        public function setString():void{

            this.myString=myString;

            txtFld= new TextField();

            txtFld.x=txtFld.y=20;

            txtFld.width =100;

            txtFld.height=20;

            txtFld.border=txtFld.background=true;

            txtFld.type=TextFieldType.INPUT;

           

            addChild(txtFld);

            stage.focus=txtFld;

            var my_cont:MovieClip=new MovieClip();

            var my_shape:Shape = new Shape();

            my_cont.addChild(my_shape);

            my_cont.buttonMode=true;

            addChild(my_cont);

            my_shape.graphics.lineStyle(1, 0xFF0000, 1);

            my_shape.graphics.beginFill(0x000000,1);

            my_shape.graphics.drawRect(150, 50, 50, 50);

            my_shape.graphics.endFill();

            my_cont.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDownEvent);

            my_cont.addEventListener(MouseEvent.MOUSE_UP, onMouseUpEvent);

        }

        public function onMouseUpEvent(e:MouseEvent):void{

            myStringBoolean=false;

        }

        public function onMouseDownEvent(e:MouseEvent):void{

            myStringBoolean=true;

        }

        protected override function initScene():void{

           if(myDelay){

            super.initScene();

            myString="1";

            }

            if(myDelay){

            setString();

            }

            text = new TextField3D("myAlphabet_04",{

                text:myString,

                align: VectorText.CENTER}

                );

            extrusion = new TextExtrusion(text, {

                depth: 10,

                bothsides:true}

                );

            container = new ObjectContainer3D(text, extrusion, { z:300 });

            scene.addChild(container);

           

        }

        protected override function onEnterFrameEvent(event:Event):void{

            super.onEnterFrameEvent(event);

           

            text = new TextField3D("myAlphabet_04",{

                text:String(txtFld.text),

                align: VectorText.CENTER}

                );

               

            extrusion = new TextExtrusion(text, {

                depth: 10,

                bothsides:true}

                );

            if(myStringBoolean){

                scene.removeChild(container);

            container = new ObjectContainer3D(text, extrusion, { z:300 });

            scene.addChild(container);

            }

            container.rotationY=(container.rotationY+1)%360;

           

            if (container.rotationY>90&&container.rotationY<270){

                text.screenZOffset=10;

            } else {

                text.screenZOffset=-10;

            }

        }

    }

}

Votes

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
community guidelines
Community Expert ,
Nov 14, 2013 Nov 14, 2013

Copy link to clipboard

Copied

what's calling initScene() in FontExtrusionDemo.as?

Votes

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
community guidelines
Mentor ,
Nov 14, 2013 Nov 14, 2013

Copy link to clipboard

Copied

As far as I can tell, initScene() is being called from within the function itself as super.initScene();  and the constructor function is calling super(); by itself with nothing else.

The AS file is extending Away3DTemplate.as and in the constructor function for that file originally initScene() was being called but I moved 4 init functions out of the constructor and replaced it with the ADDED_TO_STAGE event listener and then called the 4 functions that were moved from within a new function from the event listener.

Votes

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
community guidelines
Community Expert ,
Nov 15, 2013 Nov 15, 2013

Copy link to clipboard

Copied

if that were true you'd essentially have

function initScene(){

initScene();

}

which would trigger an infinite loop/stack overflow error.

i think you need to dig deeper into your files to see what you're doing.  in particular, you need to check initScene in the away3d class.

Votes

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
community guidelines
Mentor ,
Nov 15, 2013 Nov 15, 2013

Copy link to clipboard

Copied

Hi kglad.  Thanks for your reply.  But you can see the entire FontExtrusionDemo.as above posted and the first few lines of the Away3DTemplate.as file posted as well.

In the Away3DTemplate.as file initScene was originally being called by "public function Away3DTemplate()" but I moved it out to make way for the addEventListener(Event.ADDED_TO_STAGE, myinit) call.

I really don't know where else to look or even if your answer means that I have or have not properly insantiated the event listener.

It's pretty obvious by my troubles that I am not really well-versed in working with external classes, especially if there is more than one referencing another class in a branching format.

-markerline

Votes

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
community guidelines
Community Expert ,
Nov 15, 2013 Nov 15, 2013

Copy link to clipboard

Copied

you could copy and paste your away3d class and i'll try and check it but this is getting too complicated for a forum.  i find it difficult to scroll up and down to find the code needed to follow what you're doing.

Votes

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
community guidelines
Mentor ,
Nov 15, 2013 Nov 15, 2013

Copy link to clipboard

Copied

I certainly can understand the usability issue of the forum.  Thankfully the following code is only 46 lines long:

package

{

    import away3d.cameras.Camera3D;

    import away3d.containers.Scene3D;

    import away3d.containers.View3D;

   

    import flash.display.Sprite;

    import flash.events.Event;

    import flash.events.*;

   

   

    public class Away3DTemplate extends Sprite

    {

        protected var scene:Scene3D;

        protected var camera:Camera3D;

        protected var view:View3D;

       

        public function Away3DTemplate()

        {

            initUI();

            initEngine();

            initScene();

            initListeners();

        }

        protected function initEngine():void{

            view = new View3D();

            scene = view.scene;

            camera = view.camera;

            addChild(view);

            view.x=250;

            view.y=200;

        }

        protected function initListeners():void{

            addEventListener(Event.ENTER_FRAME, onEnterFrameEvent);

        }

        protected function onEnterFrameEvent(event:Event):void{

            view.render();

        }

        protected function initScene():void{

           

        }

        protected function initUI():void{

           

        }

    }

}

And I BELIEVE I have found the source of the problem in the copy-and-paste.

It seems that initScene and initUI are functions that do not contain any content.  Could that be the source of the issue I'm having?

Votes

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
community guidelines
Community Expert ,
Nov 15, 2013 Nov 15, 2013

Copy link to clipboard

Copied

in Away3DTemplate, use this:

public function Away3DTemplate() {

            this.addEventListener(Event.ADDED_TO_STAGE,init);

        }

        private function init(e:Event):void{

            initUI();

            initEngine();

            initScene();

            initListeners();

        }

Votes

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
community guidelines
Mentor ,
Nov 15, 2013 Nov 15, 2013

Copy link to clipboard

Copied

kGlad!!! Thank you!  using the "this" prefix to reference the Class (is that what "this" does?) seems to work wonders.  I can now Load the file and it does not throw errors!

Hopefully others running into a similar situation as the one outlined in this thread will be able to use the information and solve the problem they are experiencing.

Thanks again for your excellent help.

-markerline

Votes

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
community guidelines
Community Expert ,
Nov 15, 2013 Nov 15, 2013

Copy link to clipboard

Copied

LATEST

you're welcome.

p.s.  that code should work without the "this", too.

Votes

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
community guidelines