-
Accessing buttons in external swf from main timeline
Hello,
I am loading external swfs into a main swf. So I have main.swf which loads menu.swf, along with ssp_home.swf and home.swf.
These all load at the beginning.
I also have two other swfs - transition.swf and writing.swf - and when you click on the writing button in the menu.swf I want to load the transition, followed by the writing.swf into the main timeline.
I am really struggling - how to you tell a button in menu.swf to do load something into main.swf from main.swf?
Thanks and best wishes,
-
Senior Member
menue.writing_btn.addEventListener(MouseEvent.CLIC K,myFunction);
function myFunction(evt:MouseEvent):void{
addChild(swiftName);
}
-
Hello,
Many thanks for your reply.
I tried accessing it using the dot syntax as you suggested but it throws an error:
1120: Access of undefined property test1.
I've taken it all into a new swf called test.swf, which is loaded another swf called test1.swf with a button inside with the instance name writing.
Here's the code:
//loading the swf
var menu:URLRequest = new URLRequest ("test1.swf");
var menuLoader: Loader = new Loader();
menuLoader.contentLoaderInfo.addEventListener(Prog ressEvent.PROGRESS, loadProgress);
menuLoader.contentLoaderInfo.addEventListener(Even t.COMPLETE, loadComplete);
function loadProgress(event:ProgressEvent):void
{
var percentLoaded:Number = event.bytesLoaded/event.bytesTotal;
percentLoaded = Math.round(percentLoaded * 100);
trace("Loading: "+percentLoaded+"%");
}
function loadComplete(event:Event):void {
trace("Complete");
}
menuLoader.load(menu);
addChild(menuLoader);
//access writing button
test1.writing.addEventListener(MouseEvent.CLICK, writingClick);
function writingClick(evt:MouseEvent):void
{
trace("the button is working")
}
Any help would be much appreciated.
best
-
Senior Member
var menu:URLRequest = new URLRequest ("menue.swf");
var menuLoader:Loader = new Loader();
addChild(menuLoader);
function loadComplete(e:Event):void {
e.target.content.writing.addEventListener(MouseEve nt.CLICK, writingClick);}
menuLoader.contentLoaderInfo.addEventListener(Even t.COMPLETE, loadComplete);
menuLoader.load(menu);
function writingClick(evt:MouseEvent):void{
trace("the button is working")}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|