A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [RESOLVED] Referencing the root frame label in a switch test expression

  1. #1
    Instructional Designer
    Join Date
    Feb 2005
    Location
    Whidbey Island: north of Seattle, east of Victoria, south of Vancouver
    Posts
    299

    resolved [RESOLVED] Referencing the root frame label in a switch test expression

    Question: How do I reference the root frame label in a function for event dispatching using a switch statement.

    SUMMARY: This is simple, but as I've stepped away from ActionScript for too long, I'm having trouble figuring out the proper test expression to reference the root timeline frame label (e.g., switch(the root frame label)).

    Nothing i've tried works:
    switch(this.label)://obviously this would look at the button timeline
    switch(event.root.label)://player says there is no "root" property
    ...
    STRUCTURE: I have five MCs, one on each of five frames. I have a forward button and a back button. I created a switch statement to specify different actions, based on the root frame label. Frame labels are f1, f2, f3, f4, fend.

    THE RELEVANT CODE on Frame one ("f1"):
    Code:
    stop();
    nexter.addEventListener(MouseEvent.CLICK, onNexter);
    
    nexter.buttonMode = true;
    backer.gotoAndStop("subdued");
    
    function onNexter(event:MouseEvent):void
    {
    	switch(event.root.label)
    	{
    		case "f1":
    			trace("f1 click recognized");
    			backer.buttonMode = true;
    			backer.gotoAndStop("bright");
    			backer.addEventListener(MouseEvent.CLICK, onBacker);
    			root.nextFrame();
    			break;
    		case "f2":
    			nextFrame();
    			break;
    		case "f3":
    			nextFrame();
    			break;
    		case "f4":
    			nexter.removeEventListener();
    			nexter.gotoAndStop("subdued");
    			nextFrame();
    			break;
    		case "fend":
    			break;
    	}
    }
    function onBacker(event:MouseEvent):void
    {
    	switch(this.frame)
    	{
    		case "f1":
    			break;
    		case "f2":
    			backer.gotoAndStop("subdued");
    			prevFrame();
    			break;
    		case "f3":
    			prevFrame();
    			break;
    		case "f4":
    			prevFrame();
    			break;
    		case "fend":
    			nexter.gotoAndStop("bright");
    			prevFrame();
    			break;
    	}
    }
    Tomas

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    switch(currentFrameLabel)

    currentFrameLabel gives you the label of a frame in which the cursor is.
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Instructional Designer
    Join Date
    Feb 2005
    Location
    Whidbey Island: north of Seattle, east of Victoria, south of Vancouver
    Posts
    299
    Thank you cancerinform. It was rude of me not to reply with my thanks sooner. As it happens, I was off-tasked for a while and when I came back, the question returned - and here waits the answer. Much appreciated!
    Tomas

  4. #4
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Don't worry
    - The right of the People to create Flash movies shall not be infringed. -

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