AS3 help
- Started
- Last post
- 16 Responses
- moldero
the AS2 to AS3 transition is uhh, fun.
does this look right? im not getting any errors on flash perview, but im not getting my trace either, path issue on if statement maybe?import flash.events.MouseEvent;
hitPlay.addEventListener(MouseEv... hitOnplay);
function hitOnplay(event:MouseEvent):void {
if (MovieClip(root).navContent.uppe... {
trace("play was hit");
}
}
- moldero0
crap all the code's not showing up
- moldero0
[code]
//start MOUSE_DOWN play
import flash.events.MouseEvent;
hitPlay.addEventListener(MouseEv... hitOnplay);
function hitOnplay(event:MouseEvent):void {
if (MovieClip(root).navContent.uppe... {
trace("play was hit");
}
}
//end MOUSE_DOWN play
[/code]
- Pupsipu0
it will trace outside the if right? MovieClip(root) wtf is that? There is no root in AS3.
- Pupsipu0
just take out MovieClip root part. What is it comparing it to? "b2p" is a string, you're comparing a string to a MovieClip? Not gonna happen. What are you trying to achieve with that?
- moldero0
The MovieClip(root) syntax is almost the equivalent to _root in AS3
it works everywhere im using it, just not in the above code lol.
- moldero0
I took it out as so:
im getting this:
1120:Access of undefined property navContent.
- moldero0
in AS2 i would have done something like:
in a movie clip located here: navContent.upper.rotater
I have this code on a key frame:
http://pastie.org/409779in a movie clip located here on a higher level: navContent.
I have this code on a key frame:
http://pastie.org/409781in AS3 I am attempting this:
in a movie clip located here: navContent.upper.rotater
I have this code on a key frame:
http://pastie.org/409782in a movie clip located here on a higher level: navContent.
I have this code on a key frame:
http://pastie.org/409784
- Pupsipu0
where is navContent? what is it? is it on stage? does it have the right instance name? are you adding it through AS3 elsewhere?
If that's all right, it might be throwing that error because you're comparing a MovieClip to a String, again. Does that whole navContent.where reference a String? Post more code around that if there is any and tell me what you're trying to do
- moldero0
"navContent" is just a movieclip on the main timeline with the right instance name, im calling various things to"navContent" already using
MovieClip(root) and its all working, just the if statement thing isn't working.
- moldero0
"where" is a var im trying to label as "b2p" (not sure thats the right way to say it. but in AS3 im using this:
http://pastie.org/409782
where as AS2 I would have used this:
http://pastie.org/409779
- Pupsipu0
In AS3 to do that where part you have to use classes and extend Sprite.
Make a new .as file, name it WSprite.as. Paste this in http://pastie.org/409791
To use that paste this into timeline actions http://pastie.org/409792
To use that with a library symbol, change the properties of the library symbol from flash.display.Sprite to WSprite.
- Pupsipu0
is that var where:String working the way you do it if you say trace(navContent.blah.where) ?
I guess it's the same concept as classes, but you have to be pasting it in the right place, and I'm not sure if AS3 strict will accept that as a property.
- moldero0
this:
http://pastie.org/409806
works when i have it on the same frame, (i see the trace)
but when im trying to call it from a movie clip on a higher level with my code anyway
http://pastie.org/409784
I dont get a trace, I dont get an error, but no trace either
- Pupsipu0
i don't think you can have an If outside a function, you have to put it in a function blah(){} then say blah() and it will run fo sho