-----------------------------------------------------------------------------------------------------------
LOAD IMAGE WITHOUT MOVIE CLIP OR UI LOADER COMPONENT IN AS3
--------------------------------------------------------------------------------------------------------------
COPY AND PASTE BELOW CODE AND TEST MOVIE
READ MORE
http://www.adobe.com/devnet/flash/articles/first_as3_application.html
-----------------------------------------------------------------------------------------------------------------
import flash.display.Loader;
import flash.net.URLRequest;
var request:URLRequest = new URLRequest("https://fbstatic-a.akamaihd.net/rsrc.php/v2/yx/r/pyNVUg5EM0j.png");
var loader:Loader = new Loader();
loader.load(request)
addChild(loader)
// Center the image on stage
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded)
function onImageLoaded(event:Event):void{
loader.x = (stage.stageWidth - loader.width) / 2
loader.y = (stage.stageHeight - loader.height) / 2
}
-----------------------------------------------------------------------------------------------------------------------
ActionScript3:Using the Loader Class to load an external swf
http://www.virtualmv.com/wiki/index.php?title=ActionScript3:Using_addChild_and_removeChild
http://www.virtualmv.com/wiki/index.php?title=ActionScript3%3AUsing_the_Loader_Class_to_load_an_external_swf
http://homepages.paradise.net.nz/hesperid/flash/main.swf
http://homepages.paradise.net.nz/hesperid/flash/myMovie.swf
http://homepages.paradise.net.nz/hesperid/flash/contactMovie.swf
-----------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------
OR USE MAIN CLASS
http://www.showmycode.com/
---------------------------------------------------------------------------------------------------------------------
package main_fla {
import flash.events.*;
import flash.display.*;
import flash.net.*;
public dynamic class MainTimeline extends MovieClip {
public var worldbutton:SimpleButton;
public var swfholder:Loader;
public var homeButton:SimpleButton;
public var contactButton:SimpleButton;
public function MainTimeline(){
addFrameScript(0, this.frame1);
}
function frame1(){
this.swfholder = new Loader();
this.worldbutton.addEventListener(MouseEvent.CLICK, this.loadWorld);
this.contactButton.addEventListener(MouseEvent.CLICK, this.loadContact);
}
public function loadWorld(_arg1:MouseEvent):void{
this.addChild(this.swfholder);
this.swfholder.load(new URLRequest("myMovie.swf"));
this.swfholder.x = 6;
this.swfholder.y = 45;
this.homeButton.addEventListener(MouseEvent.CLICK, this.unloadthis);
this.worldbutton.removeEventListener(MouseEvent.CLICK, this.loadWorld);
this.contactButton.addEventListener(MouseEvent.CLICK, this.loadContact);
}
public function loadContact(_arg1:MouseEvent):void{
this.addChild(this.swfholder);
this.swfholder.load(new URLRequest("contactMovie.swf"));
this.swfholder.x = 6;
this.swfholder.y = 45;
this.homeButton.addEventListener(MouseEvent.CLICK, this.unloadthis);
this.worldbutton.addEventListener(MouseEvent.CLICK, this.loadWorld);
this.contactButton.removeEventListener(MouseEvent.CLICK, this.loadContact);
}
public function unloadthis(_arg1:Event):void{
removeChild(this.swfholder);
this.homeButton.removeEventListener(MouseEvent.CLICK, this.unloadthis);
this.worldbutton.addEventListener(MouseEvent.CLICK, this.loadWorld);
this.contactButton.addEventListener(MouseEvent.CLICK, this.loadContact);
}
}
}//package main_fla
ActionScript3:Using the Loader Class to load an external swf
http://www.virtualmv.com/wiki/index.php?title=ActionScript3:Using_addChild_and_removeChild
http://www.virtualmv.com/wiki/index.php?title=ActionScript3%3AUsing_the_Loader_Class_to_load_an_external_swf
http://homepages.paradise.net.nz/hesperid/flash/main.swf
http://homepages.paradise.net.nz/hesperid/flash/myMovie.swf
http://homepages.paradise.net.nz/hesperid/flash/contactMovie.swf
-----------------------------------------------------------------------------------------------------------------------
var swfholder:Loader=new Loader(); worldbutton.addEventListener(MouseEvent.CLICK, loadWorld); contactButton.addEventListener(MouseEvent.CLICK, loadContact); function loadWorld(event:MouseEvent):void { this.addChild(swfholder); // adds the swfholder loader swfholder.load(new URLRequest("worldMovie.swf")); // loads the required swf swfholder.x =6; //sets the x position of the loader swfholder.y =45;//sets the y position of the loader homeButton.addEventListener(MouseEvent.CLICK, unloadthis); // adds an eventlistener to the homebutton worldButton.removeEventListener(MouseEvent.CLICK, loadWorld); // disables the current swfs button contactButton.addEventListener(MouseEvent.CLICK, loadContact); // adds an eventlistener to the contactButton } function loadContact(event:MouseEvent):void { this.addChild(swfholder); swfholder.load(new URLRequest("contactMovie.swf")); swfholder.x =6; swfholder.y =45; homeButton.addEventListener(MouseEvent.CLICK, unloadthis); worldButton.addEventListener(MouseEvent.CLICK, loadWorld); contactButton.removeEventListener(MouseEvent.CLICK, loadContact); } function unloadthis(event:Event):void { removeChild(swfholder); homeButton.removeEventListener(MouseEvent.CLICK, unloadthis); worldbutton.addEventListener(MouseEvent.CLICK, loadWorld); contactButton.addEventListener(MouseEvent.CLICK, loadContact); }
--------------------------------------------------------------------------------------------------------------------
OR USE MAIN CLASS
http://www.showmycode.com/
---------------------------------------------------------------------------------------------------------------------
package main_fla {
import flash.events.*;
import flash.display.*;
import flash.net.*;
public dynamic class MainTimeline extends MovieClip {
public var worldbutton:SimpleButton;
public var swfholder:Loader;
public var homeButton:SimpleButton;
public var contactButton:SimpleButton;
public function MainTimeline(){
addFrameScript(0, this.frame1);
}
function frame1(){
this.swfholder = new Loader();
this.worldbutton.addEventListener(MouseEvent.CLICK, this.loadWorld);
this.contactButton.addEventListener(MouseEvent.CLICK, this.loadContact);
}
public function loadWorld(_arg1:MouseEvent):void{
this.addChild(this.swfholder);
this.swfholder.load(new URLRequest("myMovie.swf"));
this.swfholder.x = 6;
this.swfholder.y = 45;
this.homeButton.addEventListener(MouseEvent.CLICK, this.unloadthis);
this.worldbutton.removeEventListener(MouseEvent.CLICK, this.loadWorld);
this.contactButton.addEventListener(MouseEvent.CLICK, this.loadContact);
}
public function loadContact(_arg1:MouseEvent):void{
this.addChild(this.swfholder);
this.swfholder.load(new URLRequest("contactMovie.swf"));
this.swfholder.x = 6;
this.swfholder.y = 45;
this.homeButton.addEventListener(MouseEvent.CLICK, this.unloadthis);
this.worldbutton.addEventListener(MouseEvent.CLICK, this.loadWorld);
this.contactButton.removeEventListener(MouseEvent.CLICK, this.loadContact);
}
public function unloadthis(_arg1:Event):void{
removeChild(this.swfholder);
this.homeButton.removeEventListener(MouseEvent.CLICK, this.unloadthis);
this.worldbutton.addEventListener(MouseEvent.CLICK, this.loadWorld);
this.contactButton.addEventListener(MouseEvent.CLICK, this.loadContact);
}
}
}//package main_fla
EmoticonEmoticon