Copy link to clipboard
Copied
hi
so am running a project on flash cs5 contain 4 scene
scene 4 is a a flash game with 2 classes
after finishing the game codes and testing and work fine
i found that the hole document using the class of the game
so when testing movie many errors appears
is there any way to link this class to the game scene only ?
or any another solution makes the project work ????
no, don't import the swf, load the swf:
on scene4:
var loader:Loader=new Loader();
addChild(loader);
loader.load(new URLRequest("game.swf")); // assuming you created game.swf as suggested in message 1.
Copy link to clipboard
Copied
create a new fla, assign your game class to the document class of the new fla and publish a game swf. then load that game swf in scene 4.
Copy link to clipboard
Copied
well i had a problem adding swf to my main project ( i made the game 3 times because of that ) !
can u tell me how to add swf to my scene
what i want in my main project
i need the use when going into scene 3 click on the button and go to scene 4 and play the game ?
Copy link to clipboard
Copied
any help !!
Copy link to clipboard
Copied
i just explained how to do that. what is that you don't understand?
Copy link to clipboard
Copied
I'm Sorry I'm Biggner
i meant
before i faced this problem i tried to create a scene including the game swf but its not working
i need to know the way to create the scene that load swf and work correctly
am i supposed to import the swf into stage and nothing else
or there a working way that i dont know about
Copy link to clipboard
Copied
no, don't import the swf, load the swf:
on scene4:
var loader:Loader=new Loader();
addChild(loader);
loader.load(new URLRequest("game.swf")); // assuming you created game.swf as suggested in message 1.
Copy link to clipboard
Copied
really i dont know how to thank u
u r genius
thank u so much
Copy link to clipboard
Copied
you're welcome.
Copy link to clipboard
Copied
its me again :S
i load the swf file and its work perfect
but i want to set a back button
make the user go to scene 3 any time in the game
but it didnet work i try :
- in the game fla i set the button from code snippts but not working may be i should put the code on the class but i dont know the code ??
in the main fla i set the back button on the scene that load swf bit its not working
so any chance i can find a help :s ?
Copy link to clipboard
Copied
where is the back button?
in your main swf or in the loaded swf?
Copy link to clipboard
Copied
in the loaded swf
Copy link to clipboard
Copied
if it's on the main timeline of the loaded swf use:
back_btn.addEventListener(MouseEvent.CLICK,backF);
function backF(e:MouseEvent):void{
Loader(this.parent).unloadAndStop();
}
Copy link to clipboard
Copied
where i put that code
on code snippets of the button
or in the game class ?
Copy link to clipboard
Copied
put that on the main timeline of the loaded swf. make sure you button's reference matches the code reference.
Copy link to clipboard
Copied
i got so many errors when using the unload code u gave me but may be i do it wrong
look
i'm in my main fla project
scene 4 have that code i get it from u in the first frame to load game.swf
in scene 4 i set a button (instance name "back_bt") to get back to scene 3
what i should do exactly ! is there any way to use code snippts i tried the load/unload but still dont know how toggle it to unload !!
Copy link to clipboard
Copied
in message 11 you told me the back button is in the loaded swf.
if it's not, use:
back_bt.addEventListener(MouseEvent.CLICK,backF);
function backF(e:MouseEvent):void{
loader.unloadAndStop();
}
Copy link to clipboard
Copied
wired thing just happen
every time i click to the button in scene 3 to go to scene 4 (the game )
it gives me another scene
even when i delete the load code and scene 4 become empty scene
still when testing the movie gave me another scene
i checked to click and go to scene again and again every thing fine the names of scenes the code from code snippts
Copy link to clipboard
Copied
go back to a previous fla version where your scene 3 to scene4 button worked.
Copy link to clipboard
Copied
from where i can do that ?
Copy link to clipboard
Copied
that's programming 101.
101a: save your work frequently.
101b: use a naming scheme that reveals advancing versions (eg, myproject_01, myproject_02, etc)
you apparently have not learned that yet. so, start now.
what code does your scene 3 button use to advance to scene 4?
Copy link to clipboard
Copied
yeah seems i have long way to learn flash
in scene 3 code to scene 4
game_bt.addEventListener(MouseEvent.CLICK, fl_ClickToGoToScene_15);
function fl_ClickToGoToScene_15(event:MouseEvent):void
{
MovieClip(this.root).gotoAndPlay(1, "shgame");
}
and thats code from code snippts
Copy link to clipboard
Copied
great news
i fix the latest problem and its work again and save it
now i used ur code to unload the swf and back to scene 3
and its worked fine its unload and got me back to scene 3 "but"
its back to scene 3 and delete the button that advance to scene 4 ?
i put the code after the load code
and after it i put the code
click to scene
Copy link to clipboard
Copied
thats the error after getting back to scene 3 and delete the button
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at shdone_fla::MainTimeline/frame340()
at flash.display::MovieClip/gotoAndPlay()
at shdone_fla::MainTimeline/fl_ClickToGoToScene_19()
Copy link to clipboard
Copied
what button are you trying to "delete" and what code are you using?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now