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

Home_btn to reload iOS app is not working???

Explorer ,
Aug 10, 2016 Aug 10, 2016

hello again,

I can't find the solution.

I hope someone can help me because I'm desparate.

I  have a main-SFW within several levels-SWF's.

Now I want on each level a Home_btn so I can reload the app.

Here is my code in some SWF-level:

Home_btn.addEventListener(MouseEvent.CLICK, go_home);

function go_home(event: MouseEvent) {

  var appDomain_1:ApplicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);

var context1:LoaderContext = new LoaderContext(false, appDomain_1);

var loader1:Loader = new Loader();

var file1: File = File.applicationDirectory.resolvePath("main.swf");

loader1.load(new URLRequest (file1.url), context1);

  addChild(loader1);

}

in the main.SWF the level_SWF's won"t open again.

I have included all SWF's in the MainSWF and the main SWF also.

I hope someone can help me.

TOPICS
ActionScript
3.1K
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

Community Expert , Aug 17, 2016 Aug 17, 2016

attach a screenshot of your air for ios settings panel that shows your included files.

Translate
Community Expert ,
Aug 17, 2016 Aug 17, 2016

oops, we failed to add the loadercontext to the load method:

function load_levelF(e:MouseEvent):void{

loader.load(new URLRequest('level'+MovieClip(e.currentTarget).level+'.swf'));

addChild(loader);

}

should be

function load_levelF(e:MouseEvent):void{

loader.load(new URLRequest('level'+MovieClip(e.currentTarget).level+'.swf', loaderContext));

addChild(loader);

}

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 ,
Aug 18, 2016 Aug 18, 2016

tnx a lot kglad,

when I put the new code from above I get an error: expected 1 argument.

so I change the code into:

loader.load(new URLRequest('level'+MovieClip(e.currentTarget).level+'.swf'), loaderContext);

it works great. Thanks for that. the go_1 movie clip is working.

But the main question remains:

How to reload my iOS app????????

} else {

current_level=1;

goF(current_level);

}

is not working.

Error #2044: Unhandled IOErrorEvent:. text=Error #3764: Reloading a SWF is not supported on this operating system.

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 ,
Aug 18, 2016 Aug 18, 2016

does your go_1 button appear when you expect?

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 ,
Aug 18, 2016 Aug 18, 2016

yes the button appears on the Ipad. But when you click on it I get  when in the debugging screen the error above:

Error #2044: Unhandled IOErrorEvent:. text=Error #3764: Reloading a SWF is not supported on this operating system.

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 ,
Aug 18, 2016 Aug 18, 2016

that's disappointing but this might be a work-around.  you'll need to explicitly stop all streams (eg, sounds & video) in your loaded swfs.

stop();

import flash.display.MovieClip

import flash.net.URLRequest;

import flash.system.ApplicationDomain;

import flash.system.LoaderContext;

import flash.events.Event;

import flash.display.Loader;

import flash.events.MouseEvent;

var current_loader:Loader;

var current_level:int = 1;

var num_levels:int = 10;

var loaderContext: LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);

loader.addEventListener('level_completeE',level_completeF);

goF(current_level);

function goF(n:int):void{

for(var i:int=0;i<num_levels;i++){

this['go_'+(i+1)].visible =false;

if(!this['go_'+(i+1)].hasEventListener(MouseEvent.MOUSE_DOWN)){

this['go_'+(i+1)].level = i+1; // assuming these are movieclips

this['go_'+(i+1)].loader = new Loader();

this['go_'+(i+1)].addEventListener(MouseEvent.MOUSE_DOWN,load_levelF);

}

}

this['go_'+ n].visible = true;

}

function load_levelF(e:MouseEvent):void{

current_loader=Loader(e.currentTarget.loader);

if(!e.currentTarget.loaded){

e.currentTarget.loaded=true;

current_loader.load(new URLRequest('level'+MovieClip(e.currentTarget).level+'.swf'),loaderContext);

}

addChild(current_loader);

}

function level_completeF(e:Event):void{

removeChild(current_loader);

current_level++;

if(current_level<=num_levels){

goF(current_level);

} else {

current_level=1;

goF(current_level);

}

}

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 ,
Aug 19, 2016 Aug 19, 2016

tnx again kglad,

thanks again you are very helpful. I have only  a question about the loader , I got the error:1120

error :1120 actionscript 3 use of undefined property loader.

when I declare the loader. var loader=new Loader(); the error disappears  but then

this.parent.dispatchEvent(new Event('level_completeE',true)); on the levels.SWF

didn't work.

There is a conflict with the loader(s). I don't know how to fix that.

Debugging  on ipad and computer it doesn't give a report.

Do you know what the problem is?

p.s. i have stopped all actions eg sounds on the last frame levels.

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 ,
Aug 19, 2016 Aug 19, 2016

use:

stop();

import flash.display.MovieClip

import flash.net.URLRequest;

import flash.system.ApplicationDomain;

import flash.system.LoaderContext;

import flash.events.Event;

import flash.display.Loader;

import flash.events.MouseEvent;

var current_loader:Loader;

var current_level:int = 1;

var num_levels:int = 10;

var loaderContext: LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);

loader.addEventListener('level_completeE',level_completeF);

goF(current_level);

function goF(n:int):void{

for(var i:int=0;i<num_levels;i++){

this['go_'+(i+1)].visible =false;

if(!this['go_'+(i+1)].hasEventListener(MouseEvent.MOUSE_DOWN)){

this['go_'+(i+1)].level = i+1; // assuming these are movieclips

this['go_'+(i+1)]._loader = new Loader();

this['go_'+(i+1)].addEventListener(MouseEvent.MOUSE_DOWN,load_levelF);

}

}

this['go_'+ n].visible = true;

}

function load_levelF(e:MouseEvent):void{

current_loader=Loader(e.currentTarget._loader);

if(!e.currentTarget.loaded){

e.currentTarget.loaded=true;

current_loader.load(new URLRequest('level'+MovieClip(e.currentTarget).level+'.swf'),loaderContext);

}

addChild(current_loader);

}

function level_completeF(e:Event):void{

removeChild(current_loader);

current_level++;

if(current_level<=num_levels){

goF(current_level);

} else {

current_level=1;

goF(current_level);

}

}

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 ,
Aug 20, 2016 Aug 20, 2016

oh oh i'm here again on the forum.

This code (above) and the code above this code gives the same problem.

The dispatcherEvent doesn't work.

The debug gives no report. not on the ipad. not on the computer.

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 ,
Aug 20, 2016 Aug 20, 2016

use the trace function to make sure that the loader is dispatching the expected event.

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 ,
Aug 22, 2016 Aug 22, 2016

hello kglad,

tnx!!

The trace function didn't work. I'm also worried about unloading SWF's.

In connection with the slowness app.

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 ,
Aug 22, 2016 Aug 22, 2016

why didn't the trace function work?  did you use debug>debug movie>via connected usb?

show the trace code and the code near the trace.

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 ,
Aug 23, 2016 Aug 23, 2016

The dipatcherEvent don't work.

the debugsession gives no reply.

Code debug via  usb connected ipad:

Wachten op verbinding door speler...

[SWF] main.swf - 3095615 bytes na decompressie

[SWF] level1.swf - 4905281 bytes na decompressie

Code debug computer:

Bezig verbinding te maken met speler via URL /Users/../Desktop/project/main-app.xml

[SWF] main.swf - 3106786 bytes na decompressie

[SWF] level1.swf - 4945006 bytes na decompressie

code in level1.SWF:

stop();

import flash.display.MovieClip;

import flash.display.DisplayObject;

import flash.events.Event;

import flash.events.EventDispatcher;

this.parent.dispatchEvent(new Event('level_completeE',true));

code in main.SWF:

function level_completeF(e:Event):void{

trace("loader works");

removeChild(current_loader);

current_level++;

if(current_level<=num_levels){

goF(current_level);

} else {

current_level=1;

goF(current_level);

}

}

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 ,
Aug 23, 2016 Aug 23, 2016

add:

code in level1.SWF:

stop();

import flash.display.MovieClip;

import flash.display.DisplayObject;

import flash.events.Event;

import flash.events.EventDispatcher;

trace('dispatching event',this);

this.parent.dispatchEvent(new Event('level_completeE',true));

code in main.SWF:

trace('testing trace',this);

function level_completeF(e:Event):void{

trace("loader works");

removeChild(current_loader);

current_level++;

if(current_level<=num_levels){

goF(current_level);

} else {

current_level=1;

goF(current_level);

}

}

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 ,
Aug 24, 2016 Aug 24, 2016

tnx!!

Code debug via  usb connected ipad now is:

Wachten op verbinding door speler...

[SWF] main.swf - 3095619 bytes na decompressie

[SWF] level1.swf - 4905314 bytes na decompressie

dispatching event [object star_60]

De foutopsporingssessie is beëindigd.

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 ,
Aug 24, 2016 Aug 24, 2016

why isn't trace code working in your main (loading swf)?

ie, did you this line execute:

trace('testing trace',this);

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 ,
Aug 24, 2016 Aug 24, 2016

I'm sorry i made a mistake:

Code debug via  usb connected ipad:

Wachten op verbinding door speler...

[SWF] main.swf - 3095619 bytes na decompressie

testing trace [object MainTimeline]

[SWF] level1.swf - 4905314 bytes na decompressie

dispatching event [object star_60]

De foutopsporingssessie is beëindigd.

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 ,
Aug 24, 2016 Aug 24, 2016

your code should be:

kglad wrote:

use:

stop();

import flash.display.MovieClip

import flash.net.URLRequest;

import flash.system.ApplicationDomain;

import flash.system.LoaderContext;

import flash.events.Event;

import flash.display.Loader;

import flash.events.MouseEvent;

var current_loader:Loader;

var current_level:int = 1;

var num_levels:int = 10;

var loaderContext: LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);

goF(current_level);

function goF(n:int):void{

for(var i:int=0;i<num_levels;i++){

this['go_'+(i+1)].visible =false;

if(!this['go_'+(i+1)].hasEventListener(MouseEvent.MOUSE_DOWN)){

this['go_'+(i+1)].level = i+1; // assuming these are movieclips

this['go_'+(i+1)]._loader = new Loader();

this['go_'+(i+1)]._loader.addEventListener('level_completeE',level_completeF);

this['go_'+(i+1)].addEventListener(MouseEvent.MOUSE_DOWN,load_levelF);

}

}

this['go_'+ n].visible = true;

}

function load_levelF(e:MouseEvent):void{

current_loader=Loader(e.currentTarget._loader);

if(!e.currentTarget.loaded){

e.currentTarget.loaded=true;

current_loader.load(new URLRequest('level'+MovieClip(e.currentTarget).level+'.swf'),loaderContext);

}

addChild(current_loader);

}

function level_completeF(e:Event):void{

removeChild(current_loader);

current_level++;

if(current_level<=num_levels){

goF(current_level);

} else {

current_level=1;

goF(current_level);

}

}

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 ,
Aug 27, 2016 Aug 27, 2016

hello kglad tnx a lot voor code.

it works. Tnx for that!

But I have 2 problems:

1-when the  last level turn to level1 again, he stops at the last frame of level1 with the "score" of that level.

2-because there isn't a unload function the app becomes slower and slower.

I'm trying now to fix the problems. But I haven't not yet a solution.

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 ,
Aug 27, 2016 Aug 27, 2016

on the last frame of your loaded swf's, explicitly stop any running processes (eg, enterframe loops).

use:

stop();

import flash.display.MovieClip

import flash.net.URLRequest;

import flash.system.ApplicationDomain;

import flash.system.LoaderContext;

import flash.events.Event;

import flash.display.Loader;

import flash.events.MouseEvent;

var current_loader:Loader;

var current_level:int = 1;

var num_levels:int = 10;

var loaderContext: LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);

goF(current_level);

function goF(n:int):void{

for(var i:int=0;i<num_levels;i++){

this['go_'+(i+1)].visible =false;

if(!this['go_'+(i+1)].hasEventListener(MouseEvent.MOUSE_DOWN)){

this['go_'+(i+1)].level = i+1; // assuming these are movieclips

this['go_'+(i+1)]._loader = new Loader();

this['go_'+(i+1)]._loader.addEventListener('level_completeE',level_completeF);

this['go_'+(i+1)].addEventListener(MouseEvent.MOUSE_DOWN,load_levelF);

}

}

this['go_'+ n].visible = true;

}

function load_levelF(e:MouseEvent):void{

current_loader=Loader(e.currentTarget._loader);

if(!e.currentTarget.loaded){

e.currentTarget.loaded=true;

current_loader.load(new URLRequest('level'+MovieClip(e.currentTarget).level+'.swf'),loaderContext);

}

MovieClip(current_loader.content).gotoAndPlay(1);  // or use gotoAndStop(1)

addChild(current_loader);

}

function level_completeF(e:Event):void{

removeChild(current_loader);

current_level++;

if(current_level<=num_levels){

goF(current_level);

} else {

current_level=1;

goF(current_level);

}

}

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 ,
Aug 29, 2016 Aug 29, 2016

hello kglad,

The code works great, tnx a lot!!!!

The only thing that rest is the

problem that the app becomes slower and slower.

There isn't a unload code.

I am afraid that it is the one or the other for iOS.

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 ,
Aug 29, 2016 Aug 29, 2016

are you stopping all the running processes in the loaded swfs?

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 ,
Aug 30, 2016 Aug 30, 2016

i have to check my code again!!

is the problem solved when the running processes are stopped??

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 ,
Aug 30, 2016 Aug 30, 2016

i don't know.

you'll need to find the reason a swf that's removed from the stage is still using cpu.

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 ,
Aug 30, 2016 Aug 30, 2016

oke tnx!!

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 ,
Aug 30, 2016 Aug 30, 2016
LATEST

you're welcome.

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