Hi,
I recently had to move to as3 on a project because they wanted some special transition effects but now I can’t figure out the parent/child stuff as I am new to as3. Basically this is what I am trying to do.
I have a layout.swf where I load different swf files into a container called content_area. The code I use in the main layout file is this;
stop();
// Container
var imageLoader:Loader = new Loader();
// Url Requests
var imageRequest:URLRequest = new URLRequest("front.swf");
var imageRequestWishlist:URLRequest = new URLRequest("wishlist3.swf");
var imageRequestWishlistTwo:URLRequest = new URLRequest("wishlist3.swf");
var imageRequestAbout:URLRequest = new URLRequest("about.swf");
var imageRequestDesign:URLRequest = new URLRequest("design.swf");
var imageRequestContact:URLRequest = new URLRequest("contact.swf");
// Intial Page Loaded
imageLoader.load(imageRequest);
content_area.addChild(imageLoader)
imageLoader.x = 0;
imageLoader.y = 0;
// Button Functions
function goFront (e:MouseEvent):void{
imageLoader.load(imageRequest)
content_area.addChild(imageLoader)
imageLoader.x = 0;
imageLoader.y = 0;
}
front_btn.addEventListener(MouseEvent.CLICK, goFront);
function goWishlist (e:MouseEvent):void{
imageLoader.load(imageRequestWishlist);
content_area.addChild(imageLoader);
imageLoader.x = -1;
imageLoader.y = -1;
}
wishlist_btn.addEventListener(MouseEvent.CLICK, goWishlist);
function goAbout (e:MouseEvent):void{
imageLoader.load(imageRequestAbout);
content_area.addChild(imageLoader);
}
about_btn.addEventListener(MouseEvent.CLICK, goAbout);
function goDesign (e:MouseEvent):void{
imageLoader.load(imageRequestDesign);
content_area.addChild(imageLoader);
}
design_btn.addEventListener(MouseEvent.CLICK, goDesign);
function goContact (e:MouseEvent):void{
imageLoader.load(imageRequestContact);
content_area.addChild(imageLoader);
}
contact_btn.addEventListener(MouseEvent.CLICK, goContact);
Now this one is working as it should. It loads the movies when I click on the buttons. BUT…
In the default loaded page, front.swf I have a button that should target the same content_area inside the layout.swf file. I have tried various ways of adding the actionscript inside the front.swf file, at the moment I have this;
var imageLoaderOne:Loader = new Loader();
// Url Requests
var imageRequestWishlistTwo:URLRequest = new URLRequest("wishlist3.swf");
function wishlistButton (e:MouseEvent):void{
imageLoaderOne.load(imageRequestWishlistTwo);
content_area(this.parent).addChild(imageLoaderOne);
imageLoaderOne.x = -1;
imageLoaderOne.y = -1;
}
wishlist2_btn.addEventListener(MouseEvent.CLICK, wishlistButton);
Basically I want wishlist3.swf to load into content_area of the layout.swf from the loaded front.swf.
Can any kind soul help me out with this one? I have read books, tutorials, forum posts but I just don’t get it.