Copy link to clipboard
Copied
How to make a MovieClip from an image thats loading from XML? and how to put an images in a designated place on a flash worksheet , and turn it into movie clip or button?
AS3 |
---|
var urlLoader:URLLoader = new URLLoader(); |
xml |
---|
<images> <image url="image1.jpg"/> </images> |
Copy link to clipboard
Copied
you can't turn the loader to a movieclip but you can add the loader to a movieclip parent using addChild:
var mc:MovieClip=new MovieClip();
function f(e:Event):void{
mc.addChild(ldr);
}
Copy link to clipboard
Copied
Can i add this code after that?
mc.addEventListener(MouseEvent.CLICK, nextpage);
function nextpage(event:MouseEvent)
{
gotoAndStop(1,"Scene 2");
}
Copy link to clipboard
Copied
sure:
var urlLoader:URLLoader = new URLLoader();
urlLoader.addEventListener(Event.COMPLETE,f);
urlLoader.load(new URLRequest("images.xml"));
var ldr:Loader = new Loader();var mc:MovieClip=new MovieClip();
mc.addEventListener(MouseEvent.CLICK, nextpage);
function nextpage(event:MouseEvent)
{
gotoAndStop(1,"Scene 2");
}
function f(e:Event):void{
mc.addChild(ldr);
}
Copy link to clipboard
Copied
Get error :
Code:
Copy link to clipboard
Copied
don't use the same function name.
and if you copy and paste code instead of embedding a screenshot of it, i can edit your code to show exactly how to do that.
Copy link to clipboard
Copied
okey, i'm sorry
import flash.net.URLLoader;
import flash.events.Event;
import flash.net.URLRequest;
import flash.display.Loader;
import flash.events.MouseEvent;
stop();
var urlLoader:URLLoader=new URLLoader();
urlLoader.addEventListener(Event.COMPLETE,f);
urlLoader.load(new URLRequest("file.xml"));
var ldr:Loader=new Loader();
var mc:MovieClip=new MovieClip();
mc.addEventListener(MouseEvent.CLICK, nextpage);
function nextpage(event:MouseEvent)
{
gotoAndStop(1,"profil");
}
addChild(ldr);
function f(e:Event)
{
var xml=XML(urlLoader.data);
ldr.load(new URLRequest(xml.image.attribute("url")));
}
function f(e:Event):void
{
mc.addChild(ldr);
}
Copy link to clipboard
Copied
use:
import flash.net.URLLoader;
import flash.events.Event;
import flash.net.URLRequest;
import flash.display.Loader;
import flash.events.MouseEvent;
stop();
var urlLoader:URLLoader=new URLLoader();
urlLoader.addEventListener(Event.COMPLETE,urlloadcompleteF);
urlLoader.load(new URLRequest("file.xml"));
var ldr:Loader=new Loader();
var mc:MovieClip=new MovieClip();
mc.addChild(ldr);
addChild(mc);
mc.addEventListener(MouseEvent.CLICK, nextpage);
function nextpage(event:MouseEvent)
{
gotoAndStop(1,"profil");
}
function urlloadcompleteF(e:Event)
{
var xml=XML(urlLoader.data);
ldr.load(new URLRequest(xml.image.attribute("url")));
}
Copy link to clipboard
Copied
its work to add a movie clip, but the image still on the profile's scene that should not there. How to clear it? And how to put that image into somewhere i want?
Copy link to clipboard
Copied
remove the movieclip (and its listener so it can be gc'd).
and if you mean you want to change the position of the image, assign the loader (or better, the movieclip) x and y properties.
Copy link to clipboard
Copied
there is an error "Error #1009: Cannot access a property or method of a null object reference". Can you fix it for me please ?
Link for my file flash: Dropbox - flash.rar
thanks before
Copy link to clipboard
Copied
i don't download and fix files unless i'm hired.
free help i offer via the adobe forums. your problem should be fixable via the forums unless you're in a rush.
to start solving that problem via the forums, click file>publish settings>swf>tick 'permit debugging'>retest.
the line number of your problematic code will be in the error message. if that doesn't help you solve the problem yourself, copy and paste the line of code is referenced in the error message.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now