-
[FLASH CS5][AS 3.0] link in a picture
hey,
this a pretty stupid qeustion but how do i link in a picture to flash.
i got a URL to an image in an XML File thats on the internet,
i can get the link of that image to display with this code:
Code:
Profile_IMG.text = myXML.status[0].user.profile_image_url;
but i want that link that i get to be the picture itself, how do i do this
THANKS to everybody who helps!
-
Senior Member
You need to create a Mouse eventlistener to the loader where the image is loaded in, however you have to make sure the image is loaded, which you do by the COMPLETE event listener.
- The right of the People to create Flash movies shall not be infringed. -
-
Originally Posted by cancerinform
You need to create a Mouse eventlistener to the loader where the image is loaded in, however you have to make sure the image is loaded, which you do by the COMPLETE event listener.
this may sound even stopider then the original qeustion but can you give me a script to do this
-
Senior Member
PHP Code:
import flash.display.Loader; import flash.events.Event; import flash.display.Bitmap; import flash.events.MouseEvent;
var myLoader:Loader = new Loader(); addChild (myLoader); myLoader.contentLoaderInfo.addEventListener (Event.COMPLETE, completeHandler); myLoader.load (Profile_IMG.text);
function completeHandler (event:Event):void { var myLoader:Loader = event.currentTarget.parent as Loader; myLoader.addEventListener (MouseEvent.CLICK, clickHandler); }
function clickHandler (event:MouseEvent):void { //whatever }
Last edited by cancerinform; 03-23-2011 at 04:35 AM.
- The right of the People to create Flash movies shall not be infringed. -
-
i get this error Scene 1,
1067: Implicit coercion of a value of type String to an unrelated type flash.net:URLRequest.
-
Senior Member
I forgot something:
myLoader.load (new URLRequest(Profile_IMG.text));
- The right of the People to create Flash movies shall not be infringed. -
-
i still get the same error i dont get it
the script is inside the FLA and not a external class.
-
Senior Member
You should not get the error, since now you have a URLRequest unless you have something similar somewhere else.
- The right of the People to create Flash movies shall not be infringed. -
-
so now i have this code in there: (ERROR IN LINE 9)
Code:
import flash.display.Loader;
import flash.events.Event;
import flash.display.Bitmap;
import flash.events.MouseEvent;
var myLoader:Loader = new Loader();
addChild (myLoader);
myLoader.contentLoaderInfo.addEventListener (Event.COMPLETE, completeHandler);
myLoader.load (Profile_IMG.text);
function completeHandler (event:Event):void
{
var myLoader:Loader = event.currentTarget.parent as Loader;
myLoader.addEventListener (MouseEvent.CLICK, clickHandler);
myLoader.load (new URLRequest(Profile_IMG.text));
}
function clickHandler (event:MouseEvent):void
{
//whatever
}
and this is the other code i have running:
Code:
var myXMLLoader:URLLoader = new URLLoader();
myXMLLoader.load(new URLRequest("http://twitter.com/statuses/user_timeline.xml?screen_name=TWITTERNAME"));
myXMLLoader.addEventListener(Event.COMPLETE, processXML);
function processXML(e:Event):void{
var myXML:XML = new XML(e.target.data);
tweet_1.text = myXML.status[0].text;
tweet_2.text = myXML.status[1].text;
tweet_3.text = myXML.status[2].text;
tweet_4.text = myXML.status[3].text;
tweet_5.text = myXML.status[4].text;
follow_box.text = myXML.status[0].user.followers_count;
Profile_IMG.text = myXML.status[0].user.profile_image_url;
}
follow_btn.addEventListener(MouseEvent.CLICK, onFollow);
function onFollow(e:MouseEvent):void{
navigateToURL(new URLRequest("http:///twitter.com/TWITTERNAME"));
}
follow_btn.buttonMode = true;
is there a way to combine those 2 scripts to make it work properly im not very good at this yet but im learning ^^
and the instace name where the link is is not "Profile_IMG.text" but "Profile_IMG" (didnt know if you knew that)
but already thx for all the help and i hope you can help me some more
-
Senior Member
No, replace this line
myLoader.load (Profile_IMG.text);
with
myLoader.load (new URLRequest(Profile_IMG.text));
and delete the
myLoader.load (new URLRequest(Profile_IMG.text));
inside the function.
- The right of the People to create Flash movies shall not be infringed. -
-
i am sorry if i sound REALT stupid now but i get this error:
Code:
Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL not found.
the error is translated with google translate so sorry if it isnt the fully correct one
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
|