Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to make a MovieClip from image thats loading from XML

Guest
May 31, 2016 May 31, 2016

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();
urlLoader.addEventListener(Event.COMPLETE,f);
urlLoader.load(new URLRequest("images.xml"));

var ldr:Loader = new Loader();

function f(e:Event){
    var xml = XML(urlLoader.data);
    ldr.load(new URLRequest(xml.image.attribute("url")));
}

xml
<images>
<image url="image1.jpg"/>
</images>

@kglad

TOPICS
ActionScript
766
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 31, 2016 May 31, 2016

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);

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 31, 2016 May 31, 2016

Can i add this code after that?

mc.addEventListener(MouseEvent.CLICK, nextpage);

function nextpage(event:MouseEvent)

{

    gotoAndStop(1,"Scene 2");

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 31, 2016 May 31, 2016

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);

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 31, 2016 May 31, 2016

Get error :

QQQQ.png

Code:

wwwww.png

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 31, 2016 May 31, 2016

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 31, 2016 May 31, 2016

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);

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 31, 2016 May 31, 2016

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")));

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 01, 2016 Jun 01, 2016

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 01, 2016 Jun 01, 2016

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 04, 2016 Jun 04, 2016

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 05, 2016 Jun 05, 2016
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines