dcsimg
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: [RESOLVED] as3(new project) load image from an xml created menu

Threaded View

  1. #1
    Junior Member
    Join Date
    Aug 2010
    Posts
    12

    resolved [RESOLVED] as3(new project) load image from an xml created menu

    I'm trying to load an image from a xml created menu
    my menu is created and when I press a button within the menu my text in my linkTo node appears in my textfield called contents. this part works great.
    but when I try to load my image that goes with the text is where my problem is.

    EDIT: when I trace (item.image); I get " images/20.jpg" on first button and the second button traces "images/21.jpg" so the xml nodes are correct.
    Please can someone help me THANKS A MILLION in advance
    Sincerely Xiaz


    1st try
    Code:
    //assign a "linkTo" variable. this contains the url where the menu will link to when clicked
    menuItem.linkTo = button.linkTo.toString();
    //assign a "image" variable. this contains the url where the menu will link to when clicked
    menuItem.image = button.image.toString();
    
    function itemClicked(e:Event):void (
         var item:MenuItem = e.target as MenuItem;
         contents.htmlText = item.linkTo;
    
    /////////PROBLEM AREA////////////////////////////////////////////////////////
         imageloader.load(new URLRequest (item.image));
         trace (item.image);
    //traces Error#1034: Type Coercion failed: cannot convert "images/20.jpg" to flash.net.URLRequest. 
    at Vertical_fla::MainTimeline/itemClicked
    2nd try
    Code:
    var urlRequest:URLRequest = new URLRequest(item.image);
     imageloader.load(urlRequest);
     trace(urlRequest);
    //traces "[object URLRequest]"
    3rd try
    Code:
    var request:URLRequest = new URLRequest(item.image);
    var variables:URLVariables = new URLVariables();
    request.data = variables;
    imageloader.load(request);
    trace(request)
    //traces "[object URLRequest]" and "Error #2044 Unhandled IOErrorEvent:.text=Error #2035: URL Not Found"
    Last edited by Xiaz; 08-20-2010 at 04:52 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center