-
Error "Variable navigateToURL is not defined"
ReferenceError: Error #1065: Variable navigateToURL is not defined.
at XmlMenu/::_mouseClickHandler()
for code:
private function _mouseClickHandler(event:MouseEvent):void {
navigateToURL(event.target.href);
}
Last edited by wdv; 09-02-2008 at 01:25 PM.
-
lemon juice hurts your eyes
In AS3 you have to use this:
Code:
var request:URLRequest=new URLRequest("http://www.mysite.com");
navigateToURL(request,"NameOfTheFrame");
And the error you get is probably located at that event.target.href, but I don't know what that "href" means, is it a variable you pass into the function?
EDIT: Ok .. I don't know why you chose to remove your message, but I think you just found a solution?
Florian Vanthuyne
WAR AGAINST SOLVED THREADS
mark yours as Resolved under Thread Tools!
-
hey Florian Vanthuyne, yes the href is in a xml file
-
navigateToURL is a public static function so if you're working in a class you'll need to import the class before you call navigateToURL():
import flash.net.navigateToURL;
-
hey thanks neznein now i get this error
TypeError: Error #1034: Type Coercion failed: cannot convert XMLList@cdc7fb1 to flash.net.URLRequest.
at XmlMenu/::_mouseClickHandler()
my code
package {
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.net.URLLoader;
import flash.net.navigateToURL;
import flash.net.URLRequest;
public class XmlMenu extends Sprite {
private var _xml:XML;
public function XmlMenu(data:*) {
switch (typeof data) {
case "string":
data = new URLRequest(data);
case "object":
var urlLoader:URLLoader = new URLLoader();
urlLoader.addEventListener(Event.COMPLETE, _completeHandler);
urlLoader.load(data);
break;
case "xml":
xml = data;
break;
default:
throw new Error("Wrong argument");
}
}
private function get xml():XML {
return _xml;
}
private function set xml(data:XML):void {
_xml = data;
var xPos:Number = 0;
for each (var node:XML in _xml.menu) {
var menuMC:MovieClip = new menu_mc();
menuMC.buttonMode = true;
menuMC.href = node.@href;
menuMC.label_txt.selectable = false;
menuMC.label_txt.mouseEnabled = false;
menuMC.label_txt.text = node.@name;
menuMC.x = xPos;
xPos += menuMC.width;
var container:Sprite=new Sprite();
container.y = menuMC.height;
container.visible = false;
var yPos:Number = 0;
for each (var subnode:XML in node.submenu) {
var linkMC:MovieClip = new link_mc();
linkMC.buttonMode = true;
linkMC.y = yPos;
yPos += linkMC.height;
linkMC.href = subnode.@href;
linkMC.label_txt.text = subnode.@name;
linkMC.label_txt.mouseEnabled = false;
container.addChild(linkMC);
}
container.graphics.beginFill(0x000000, 0);
container.graphics.drawRect(0, 0, container.width + 1, container.height + 1);
container.graphics.endFill();
menuMC.addChild(container);
addChild(menuMC);
menuMC.addEventListener(MouseEvent.ROLL_OVER, _rollOverHandler);
menuMC.addEventListener(MouseEvent.ROLL_OUT, _rollOutHandler);
menuMC.addEventListener(MouseEvent.CLICK, _mouseClickHandler);
}
}
private function _completeHandler(event:Event):void {
xml = new XML(event.target.data);
}
private function _rollOverHandler(event:MouseEvent):void {
event.currentTarget.getChildAt(2).visible=true;
}
private function _rollOutHandler(event:MouseEvent):void {
event.currentTarget.getChildAt(2).visible=false;
}
private function _mouseClickHandler(event:MouseEvent):void {
navigateToURL(event.target.href);
}
}
}
-
lemon juice hurts your eyes
Neznein9 is correct, I've looked at the files you attached in your other thread and by adding that to the other imports in the XmlMenu.as file you will have solved your problem!
Florian Vanthuyne
WAR AGAINST SOLVED THREADS
mark yours as Resolved under Thread Tools!
-
lemon juice hurts your eyes
private function _mouseClickHandler(event:MouseEvent):void {
var request:URLRequest=new URLRequest(event.target.href);
navigateToURL(request);
//trace(event.target.href);
}
And it's not your code, it Adobe's code
Florian Vanthuyne
WAR AGAINST SOLVED THREADS
mark yours as Resolved under Thread Tools!
-
wow! thanks florianvanthuyn, you are are all amazing thank you so much!, i ordered oreileys learning action 3 for beginners, hopefully I can help in the future.
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
|